X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=manager.c;h=4cc7d30e24ef5732df9ad60822e6c11f9869aacf;hp=cf1c1481c12d32859dd6a2449dbac94a9ed2df8c;hb=43aa226daf2abe7af37d86379b4bf69efbc03f78;hpb=db06e3b6a5254ec247de5bc1a1b6a8670c2f4b2b diff --git a/manager.c b/manager.c index cf1c1481c..4cc7d30e2 100644 --- a/manager.c +++ b/manager.c @@ -51,6 +51,7 @@ #include "unit-name.h" #include "dbus-unit.h" #include "dbus-job.h" +#include "missing.h" /* As soon as 16 units are in our GC queue, make sure to run a gc sweep */ #define GC_QUEUE_ENTRIES_MAX 16 @@ -67,7 +68,7 @@ static int enable_special_signals(Manager *m) { if (reboot(RB_DISABLE_CAD) < 0) log_warning("Failed to enable ctrl-alt-del handling: %m"); - if ((fd = open_terminal("/dev/tty0", O_RDWR)) < 0) + if ((fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY)) < 0) log_warning("Failed to open /dev/tty0: %m"); else { /* Enable that we get SIGWINCH on kbrequest */ @@ -148,12 +149,12 @@ static char** session_dirs(void) { } if ((e = getenv("XDG_CONFIG_DIRS"))) - config_dirs = strv_split(e, ":"); - else - config_dirs = strv_new("/etc/xdg", NULL); + if (!(config_dirs = strv_split(e, ":"))) + goto fail; - if (!config_dirs) - goto fail; + /* We don't treat /etc/xdg/systemd here as the spec + * suggests because we assume that that is a link to + * /etc/systemd/ anyway. */ if ((e = getenv("XDG_DATA_HOME"))) { if (asprintf(&data_home, "%s/systemd/session", e) < 0) @@ -253,7 +254,7 @@ static int manager_find_paths(Manager *m) { } if (m->running_as == MANAGER_INIT) { - /* /etc/init.d/ compativility does not matter to users */ + /* /etc/init.d/ compatibility does not matter to users */ if ((e = getenv("SYSTEMD_SYSVINIT_PATH"))) if (!(m->sysvinit_path = split_path_and_make_absolute(e))) @@ -336,6 +337,9 @@ int manager_new(ManagerRunningAs running_as, bool confirm_spawn, Manager **_m) { m->signal_watch.fd = m->mount_watch.fd = m->udev_watch.fd = m->epoll_fd = m->dev_autofs_fd = -1; m->current_job_id = 1; /* start as id #1, so that we can leave #0 around as "null-like" value */ + if (!(m->environment = strv_copy(environ))) + goto fail; + if (!(m->units = hashmap_new(string_hash_func, string_compare_func))) goto fail; @@ -517,6 +521,7 @@ void manager_free(Manager *m) { assert(m); + manager_dispatch_cleanup_queue(m); manager_clear_jobs_and_units(m); for (c = 0; c < _UNIT_TYPE_MAX; c++) @@ -544,6 +549,7 @@ void manager_free(Manager *m) { strv_free(m->unit_path); strv_free(m->sysvinit_path); strv_free(m->sysvrcnd_path); + strv_free(m->environment); free(m->cgroup_controller); free(m->cgroup_hierarchy); @@ -1816,12 +1822,7 @@ static int manager_process_signal_fd(Manager *m) { /* This is a nop on non-init */ break; - case SIGUSR1: - manager_dump_units(m, stdout, "\t"); - manager_dump_jobs(m, stdout, "\t"); - break; - - case SIGUSR2: { + case SIGUSR1: { Unit *u; u = manager_get_unit(m, SPECIAL_DBUS_SERVICE); @@ -1840,6 +1841,11 @@ static int manager_process_signal_fd(Manager *m) { break; } + case SIGUSR2: + manager_dump_units(m, stdout, "\t"); + manager_dump_jobs(m, stdout, "\t"); + break; + case SIGHUP: m->exit_code = MANAGER_RELOAD; break;