--- a/hald/hald.c +++ b/hald/hald.c @@ -214,6 +214,7 @@ "\n" " --daemon=yes|no Become a daemon\n" " --verbose=yes|no Print out debug (overrides HALD_VERBOSE)\n" + " --retain-privileges Retain privileges (for debugging)\n" " --use-syslog Print out debug messages to syslog instead of stderr.\n" " Use this option to get debug messages if HAL runs as\n" " daemon.\n" @@ -232,6 +233,9 @@ usage () /** If #TRUE, we will daemonize */ static dbus_bool_t opt_become_daemon = TRUE; +/** If #TRUE, we will retain privs */ +static dbus_bool_t opt_retain_privileges = FALSE; + /** If #TRUE, we will spew out debug */ dbus_bool_t hald_is_verbose = FALSE; dbus_bool_t hald_use_syslog = FALSE; @@ -408,6 +412,7 @@ main (int argc, char *argv[]) {"exit-after-probing", 0, NULL, 0}, {"daemon", 1, NULL, 0}, {"verbose", 1, NULL, 0}, + {"retain-privileges", 0, NULL, 0}, {"use-syslog", 0, NULL, 0}, {"help", 0, NULL, 0}, {"version", 0, NULL, 0}, @@ -449,6 +454,8 @@ main (int argc, char *argv[]) usage (); return 1; } + } else if (strcmp (opt, "retain-privileges") == 0) { + opt_retain_privileges = TRUE; } else if (strcmp (opt, "use-syslog") == 0) { hald_use_syslog = TRUE; } @@ -581,7 +588,11 @@ main (int argc, char *argv[]) /* initialize privileged operating system specific parts */ osspec_privileged_init (); - drop_privileges(0); + /* sometimes we don't want to drop root privs, for instance + if we are profiling memory usage */ + if (opt_retain_privileges == FALSE) { + drop_privileges(0); + } /* initialize operating system specific parts */ osspec_init ();