From 94c6ff7bb70b8bf3af0b69cf490b36eb98a34be7 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 8 Aug 2007 03:07:42 +0000 Subject: Plug a leek for non selinux linux systems --- src/runscript.c | 38 ++++++++++++++++++++------------------ 1 file 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 -- cgit v1.2.3