[systemd-devel] [PATCH] Just list all the variables

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Mon Sep 16 06:26:00 PDT 2013


On Thu, Sep 12, 2013 at 03:37:14PM +0200, Zbigniew Jędrzejewski-Szmek wrote:
> On Thu, Sep 12, 2013 at 03:32:12PM +0200, Zbigniew Jędrzejewski-Szmek wrote:
> > On Fri, Jul 26, 2013 at 11:24:44AM +0100, Colin Guthrie wrote:
> > > +                <para>All processes are executed in a clean environment in
> > > +                which only the TERM, PATH, USER, and HOME variables are
> > > +                inherited (from PID1) by default. In order to set additional
> > > +                variables, see the Environment= and EnvironmentFile= options
> > > +                below. To specify variables globally, you can configure
> > > +                DefaultEnvironment= in
> > > +                <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
> > Hi,
> > I pushed something like this now, but with completely different text,
> > since variables exported have changed significantly, and in addition
> > the behaviour for PID 1 and user instances is significantly different.
> Hm, looking at the other part of this thread, Kay and Lennart have provided
> a full list of variables. It is too long for one or two paragraphs, so
> maybe a separate section describing all variables and circumstances in
> which they are set should be added.
I compiled a list of the variables. It is kind of hard to provide
some meaningful text without being either very verbose or trivial,
and I feel the text still awkward. Comments, suggestions?

Zbyszek

---
 man/systemd.exec.xml | 133 ++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 111 insertions(+), 22 deletions(-)

diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
index 5721dc1..2a950cf 100644
--- a/man/systemd.exec.xml
+++ b/man/systemd.exec.xml
@@ -57,7 +57,7 @@
                 <title>Description</title>
 
                 <para>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.</para>
 
@@ -76,27 +76,6 @@
                 configuration options are configured in the [Service],
                 [Socket], [Mount], or [Swap] sections, depending on the unit
                 type.</para>
-
-                <para>Processes started by the system systemd instance
-                are executed in a clean environment in which only the
-                <varname>$PATH</varname> and <varname>$LANG</varname>
-                variables are set by default. In order to add
-                additional variables, see the
-                <varname>Environment=</varname> and
-                <varname>EnvironmentFile=</varname> options below. To
-                specify variables globally, see
-                <varname>DefaultEnvironment=</varname> in
-                <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
-                or the kernel option
-                <varname>systemd.setenv=</varname> in
-                <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>. Processes
-                started by the user systemd instances inherit all
-                environment variables from the user systemd instance,
-                and have <varname>$HOME</varname>,
-                <varname>$USER</varname>,
-                <varname>$XDG_RUNTIME_DIR</varname> defined, among
-                others. In addition, <varname>$MANAGERPID</varname>
-                contains the PID of the user systemd instance.</para>
         </refsect1>
 
         <refsect1>
@@ -1006,6 +985,116 @@
         </refsect1>
 
         <refsect1>
+                <title>Environment variables in spawned processes</title>
+
+                <para>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.
+                </para>
+
+                <variablelist class='environment-variables'>
+                        <varlistentry>
+                                <term><varname>$PATH</varname></term>
+
+                                <listitem><para>Colon-separated list
+                                of directiories to use when launching
+                                executables. Set for all units.
+                                </para></listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                                <term><varname>$LANG</varname></term>
+
+                                <listitem><para>Locale. Can be set in
+                                <citerefentry><refentrytitle>locale.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+                                or on the kernel command line (see
+                                <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+                                and
+                                <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry>).
+                                </para></listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                                <term><varname>$USER</varname></term>
+                                <term><varname>$HOME</varname></term>
+
+                                <listitem><para>User name and home
+                                directory.  Set for the units which
+                                have <varname>User=</varname> set,
+                                which includes user
+                                <command>systemd</command> instances.
+                                See
+                                <citerefentry><refentrytitle>passwd</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
+                                </para></listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                                <term><varname>$XDG_RUNTIME_DIR</varname></term>
+
+                                <listitem><para>The directory for volatile
+                                state. Set for the user <command>systemd</command>
+                                instance, and also in user sessions.
+                                See
+                                <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
+                                </para></listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                                <term><varname>$XDG_SESSION_ID</varname></term>
+                                <term><varname>$XDG_SEAT</varname></term>
+                                <term><varname>$XDG_VTNR</varname></term>
+
+                                <listitem><para>The identifier of the
+                                session, and the seat name, and
+                                virtual terminal of the session. Set
+                                by
+                                <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+                                for login sessions.
+                                <varname>$XDG_SEAT</varname> and
+                                <varname>$XDG_VTNR</varname> will be
+                                only set when attached to a seat and a
+                                tty.</para></listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                                <term><varname>$MANAGERPID</varname></term>
+
+                                <listitem><para>The PID of the user
+                                <command>systemd</command> instance,
+                                set for processes spawned by it.
+                                </para></listitem>
+                        </varlistentry>
+
+                        <varlistentry>
+                                <term><varname>$LISTEN_FDS</varname></term>
+                                <term><varname>$LISTEN_PID</varname></term>
+
+                                <listitem><para>Information about file
+                                descriptors passed to a service for
+                                socket activation.  See
+                                <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
+                                </para></listitem>
+                        </varlistentry>
+                </variablelist>
+
+                <para>Additional variables may be configured by the
+                following means: for processes spawned in specific
+                units, use the <varname>Environment=</varname> and
+                <varname>EnvironmentFile=</varname> options above; to
+                specify variables globally, use
+                <varname>DefaultEnvironment=</varname> (see
+                <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>)
+                or the kernel option
+                <varname>systemd.setenv=</varname> (see
+                <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>). Additional
+                variables may also be set through PAM,
+                c.f. <citerefentry><refentrytitle>pam_env</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
+        </refsect1>
+
+        <refsect1>
                   <title>See Also</title>
                   <para>
                           <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
-- 
1.8.3.1



More information about the systemd-devel mailing list