aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-08-08 03:07:42 +0000
committerRoy Marples <roy@marples.name>2007-08-08 03:07:42 +0000
commit94c6ff7bb70b8bf3af0b69cf490b36eb98a34be7 (patch)
treec87378f401fbe829c334f3fa8b76331612e1d862
parent30853d7473a502248c87f0a743090df8d7d6a81f (diff)
Plug a leek for non selinux linux systems
-rw-r--r--src/runscript.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/runscript.c b/src/runscript.c
index 69d302b3..14d3c7bf 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -71,27 +71,29 @@ static void setup_selinux (int argc, char **argv);
static void setup_selinux (int argc, char **argv)
{
void *lib_handle = NULL;
+
+ if (! rc_exists (SELINUX_LIB))
+ return;
lib_handle = dlopen (SELINUX_LIB, RTLD_NOW | RTLD_GLOBAL);
- if (lib_handle) {
- /*
- * FIXME: the below code generates the warning
- * ISO C forbids assignment between function pointer and 'void *'
- * which sucks ass
- * http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html
- */
- selinux_run_init_old = (void (*)(void)) dlfunc (lib_handle, "selinux_runscript");
- selinux_run_init_new = (void (*)(int, char **)) dlfunc (lib_handle, "selinux_runscript2");
-
- /* Use new run_init if it rc_exists, else fall back to old */
- if (selinux_run_init_new)
- selinux_run_init_new (argc, argv);
- else if (selinux_run_init_old)
- selinux_run_init_old ();
- else
- /* This shouldnt happen... probably corrupt lib */
- eerrorx ("run_init is missing from runscript_selinux.so!");
+ if (! lib_handle) {
+ eerror ("dlopen: %s", dlerror ());
+ return;
}
+
+ selinux_run_init_old = (void (*)(void)) dlfunc (lib_handle, "selinux_runscript");
+ selinux_run_init_new = (void (*)(int, char **)) dlfunc (lib_handle, "selinux_runscript2");
+
+ /* Use new run_init if it rc_exists, else fall back to old */
+ if (selinux_run_init_new)
+ selinux_run_init_new (argc, argv);
+ else if (selinux_run_init_old)
+ selinux_run_init_old ();
+ else
+ /* This shouldnt happen... probably corrupt lib */
+ eerrorx ("run_init is missing from runscript_selinux.so!");
+
+ dlclose (lib_handle);
}
#endif