X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmanager.c;h=f70ff03033f85d58808ec84d40acc427a7b19ea3;hb=c51d84dc09476d9c06b8aac726220bf3c7d62e8d;hp=ad1a8d61797b708d01ec40fd4633a0865d853b57;hpb=31a7eb86f18b0466681d6fbe80c148f96c551c80;p=elogind.git diff --git a/src/core/manager.c b/src/core/manager.c index ad1a8d617..f70ff0303 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -55,6 +55,7 @@ #include "util.h" #include "mkdir.h" #include "ratelimit.h" +#include "locale-setup.h" #include "mount-setup.h" #include "unit-name.h" #include "dbus-unit.h" @@ -69,7 +70,7 @@ #include "cgroup-util.h" #include "path-util.h" #include "audit-fd.h" -#include "efivars.h" +#include "boot-timestamps.h" #include "env-util.h" /* As soon as 5s passed since a unit was added to our GC queue, make sure to run a gc sweep */ @@ -301,8 +302,6 @@ static int manager_watch_idle_pipe(Manager *m) { } log_debug("Set up idle_pipe watch."); - log_debug("m->epoll_fd=%d m->idle_pipe_watch.fd=%d", - m->epoll_fd, m->idle_pipe_watch.fd); return 0; @@ -317,8 +316,6 @@ static void manager_unwatch_idle_pipe(Manager *m) { if (m->idle_pipe_watch.type != WATCH_IDLE_PIPE) return; - log_debug("m->epoll_fd=%d m->idle_pipe_watch.fd=%d", - m->epoll_fd, m->idle_pipe_watch.fd); assert_se(epoll_ctl(m->epoll_fd, EPOLL_CTL_DEL, m->idle_pipe_watch.fd, NULL) >= 0); watch_init(&m->idle_pipe_watch); @@ -458,22 +455,31 @@ static int manager_setup_signals(Manager *m) { return 0; } -static void manager_strip_environment(Manager *m) { +static int manager_default_environment(Manager *m) { assert(m); - /* Remove variables from the inherited set that are part of - * the container interface: - * http://www.freedesktop.org/wiki/Software/systemd/ContainerInterface */ - strv_remove_prefix(m->environment, "container="); - strv_remove_prefix(m->environment, "container_"); + if (m->running_as == SYSTEMD_SYSTEM) { + /* The system manager always starts with a clean + * environment for its children. It does not import + * the kernel or the parents exported variables. + * + * The initial passed environ is untouched to keep + * /proc/self/environ valid; it is used for tagging + * the init process inside containers. */ + m->environment = strv_new("PATH=" DEFAULT_PATH, + NULL); + + /* Import locale variables LC_*= from configuration */ + locale_setup(&m->environment); + } else + /* The user manager passes its own environment + * along to its children. */ + m->environment = strv_copy(environ); - /* Remove variables from the inherited set that are part of - * the initrd interface: - * http://www.freedesktop.org/wiki/Software/systemd/InitrdInterface */ - strv_remove_prefix(m->environment, "RD_"); + if (!m->environment) + return -ENOMEM; - /* Drop invalid entries */ - strv_env_clean(m->environment); + return 0; } int manager_new(SystemdRunningAs running_as, bool reexecuting, Manager **_m) { @@ -490,7 +496,7 @@ int manager_new(SystemdRunningAs running_as, bool reexecuting, Manager **_m) { #ifdef ENABLE_EFI if (detect_container(NULL) <= 0) - efi_get_boot_timestamps(&m->userspace_timestamp, &m->firmware_timestamp, &m->loader_timestamp); + boot_timestamps(&m->userspace_timestamp, &m->firmware_timestamp, &m->loader_timestamp); #endif m->running_as = running_as; @@ -509,12 +515,10 @@ int manager_new(SystemdRunningAs running_as, bool reexecuting, Manager **_m) { 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 */ - m->environment = strv_copy(environ); - if (!m->environment) + r = manager_default_environment(m); + if (r < 0) goto fail; - manager_strip_environment(m); - if (!(m->units = hashmap_new(string_hash_func, string_compare_func))) goto fail; @@ -2655,7 +2659,7 @@ void manager_undo_generators(Manager *m) { remove_generator_dir(m, &m->generator_unit_path_late); } -int manager_set_default_environment(Manager *m, char **environment) { +int manager_environment_add(Manager *m, char **environment) { char **e = NULL; assert(m);