aboutsummaryrefslogtreecommitdiff
path: root/src/librc/librc.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-02-19 14:15:53 +0000
committerRoy Marples <roy@marples.name>2008-02-19 14:15:53 +0000
commit0364bb2c84bff631e0f765254fc6bf3353950128 (patch)
tree532aa8d419a4647f4ee5134256c75e228b06278e /src/librc/librc.c
parentf95e0b2c3e0192b44d6ac792f40a61a34f8c8b13 (diff)
Add the nojail keyword which excludes services marked as such from the dependency tree when in a jail, #bug 22
Diffstat (limited to 'src/librc/librc.c')
-rw-r--r--src/librc/librc.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/librc/librc.c b/src/librc/librc.c
index 75019eec..f323d0fd 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -32,6 +32,9 @@
const char librc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
#include "librc.h"
+#ifdef __FreeBSD__
+#include <sys/sysctl.h>
+#endif
#include <signal.h>
#define SOFTLEVEL RC_SVCDIR "/softlevel"
@@ -144,6 +147,36 @@ static bool rm_dir (const char *pathname, bool top)
return (true);
}
+const char *rc_sys (void)
+{
+#ifdef __FreeBSD__
+ int jailed = 0;
+ size_t len = sizeof (jailed);
+
+ if (sysctlbyname ("security.jail.jailed", &jailed, &len, NULL, 0) == 0)
+ if (jailed == 1)
+ return (RC_SYS_JAIL);
+#endif
+
+#ifdef __linux__
+ if (exists ("/proc/xen")) {
+ if ((fp = fopen ("/proc/xen/capabilities", "r"))) {
+ fclose (fp);
+ if (file_regex ("/proc/xen/capabilities", "control_d"))
+ return (RC_SYS_XEN0);
+ }
+ if (! sys[0])
+ return (RC_SYS_XENU);
+ } else if (file_regex ("/proc/cpuinfo", "UML"))
+ return (RC_SYS_UML);
+ else if (file_regex ("/proc/self/status",
+ "(s_context|VxID|envID):[[:space:]]*[1-9]"))
+ return (RC_SYS_VPS);
+#endif
+
+ return (NULL);
+}
+
static const char *rc_parse_service_state (rc_service_state_t state)
{
int i;