[systemd-devel] [PATCH] Just list all the variables
Colin Guthrie
gmane at colin.guthr.ie
Tue Sep 17 01:56:53 PDT 2013
'Twas brillig, and Zbigniew Jędrzejewski-Szmek at 16/09/13 14:26 did
gyre and gimble:
> 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?
Maybe a little awkward but I still think it's better than what is there
currently!
Some minor comments below.
> ---
> 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>
It's possibly worth mentioning that variables are not set from the
underlying environment. e.g. if a user set "export
PATH=/opt/mystuff/bin:$PATH" in /etc/profile.d/my-stuff.sh, systemd will
not "see" that PATH change.
While it applies to all variables listed here and I know you mention it
at the end, this ($PATH) is the one that most regular users would
probably expect to be inherited (IMO) so it possibly warrants a mention
above the tl;dr fold!
> + </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>
It might make sense to document all the $XDG_* vars in one section?
Otherwise I'd say it's a good improvement!
Cheers
Col
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited http://www.tribalogic.net/
Open Source:
Mageia Contributor http://www.mageia.org/
PulseAudio Hacker http://www.pulseaudio.org/
Trac Hacker http://trac.edgewall.org/
More information about the systemd-devel
mailing list