From 43638332c4236ac2db44b0524ea5ade4f918e602 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 15 Sep 2013 11:56:19 -0400 Subject: [PATCH] man: add a list of environment variables --- man/systemd.exec.xml | 138 +++++++++++++++++++++++++++++++++++-------- src/core/manager.c | 5 +- 2 files changed, 117 insertions(+), 26 deletions(-) diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index 5721dc155..ba4e808dd 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -57,7 +57,7 @@ Description Unit configuration files for services, sockets, - mount points and swap devices share a subset of + mount points, and swap devices share a subset of configuration options which define the execution environment of spawned processes. @@ -76,27 +76,6 @@ configuration options are configured in the [Service], [Socket], [Mount], or [Swap] sections, depending on the unit type. - - Processes started by the system systemd instance - are executed in a clean environment in which only the - $PATH and $LANG - variables are set by default. In order to add - additional variables, see the - Environment= and - EnvironmentFile= options below. To - specify variables globally, see - DefaultEnvironment= in - systemd-system.conf5 - or the kernel option - systemd.setenv= in - systemd1. Processes - started by the user systemd instances inherit all - environment variables from the user systemd instance, - and have $HOME, - $USER, - $XDG_RUNTIME_DIR defined, among - others. In addition, $MANAGERPID - contains the PID of the user systemd instance. @@ -1005,6 +984,118 @@ + + Environment variables in spawned processes + + Processes started by the system are executed in + a clean environment in which select variables + listed below are set. System processes started by systemd + do not inherit variables from PID 1, but processes + started by user systemd instances inherit all + environment variables from the user systemd instance. + + + + + $PATH + + Colon-separated list + of directiories to use when launching + executables. Systemd uses a fixed + value of + /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin. + + + + + $LANG + + Locale. Can be set in + locale.conf5 + or on the kernel command line (see + systemd1 + and + kernel-command-line7). + + + + + $USER + $HOME + + User name and home + directory. Set for the units which + have User= set, + which includes user + systemd instances. + See + passwd5. + + + + + $XDG_RUNTIME_DIR + + The directory for volatile + state. Set for the user systemd + instance, and also in user sessions. + See + pam_systemd8. + + + + + $XDG_SESSION_ID + $XDG_SEAT + $XDG_VTNR + + The identifier of the + session, and the seat name, and + virtual terminal of the session. Set + by + pam_systemd8 + for login sessions. + $XDG_SEAT and + $XDG_VTNR will be + only set when attached to a seat and a + tty. + + + + $MANAGERPID + + The PID of the user + systemd instance, + set for processes spawned by it. + + + + + $LISTEN_FDS + $LISTEN_PID + + Information about file + descriptors passed to a service for + socket activation. See + sd_listen_fds3. + + + + + Additional variables may be configured by the + following means: for processes spawned in specific + units, use the Environment= and + EnvironmentFile= options above; to + specify variables globally, use + DefaultEnvironment= (see + systemd-system.conf5) + or the kernel option + systemd.setenv= (see + systemd1). Additional + variables may also be set through PAM, + c.f. pam_env8. + + See Also @@ -1018,7 +1109,8 @@ systemd.mount5, systemd.kill5, systemd.cgroup5, - systemd.directives7 + systemd.directives7, + exec3 diff --git a/src/core/manager.c b/src/core/manager.c index 669af1524..079db4157 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -456,8 +456,6 @@ static int manager_setup_signals(Manager *m) { } static int manager_default_environment(Manager *m) { - const char *path = "PATH=" DEFAULT_PATH; - assert(m); if (m->running_as == SYSTEMD_SYSTEM) { @@ -468,7 +466,8 @@ static int manager_default_environment(Manager *m) { * 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, NULL); + m->environment = strv_new("PATH=" DEFAULT_PATH, + NULL); /* Import locale variables LC_*= from configuration */ locale_setup(&m->environment); -- 2.30.2