mirror of
https://github.com/systemd/systemd.git
synced 2024-11-30 22:03:41 +08:00
core: support specifier expansion in DefaultEnvironment= and ManagerEnvironment=
Strictly speaking adding this is a compatibility break, given that previously % weren't special. But I'd argue that was simply a bug, as for the much more prominent Environment= service setting we always resolved specifiers, and DEfaultEnvironment= is explicitly listed as being the default for that. Hence, let's fix that. Replaces: #16787
This commit is contained in:
parent
b3e22322b6
commit
46a9ee5d9b
@ -328,6 +328,9 @@
|
||||
project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
|
||||
details about environment variables.</para>
|
||||
|
||||
<para>Simple <literal>%</literal>-specifier expansion is supported, see below for a list of supported
|
||||
specifiers.</para>
|
||||
|
||||
<para>Example:
|
||||
|
||||
<programlisting>DefaultEnvironment="VAR1=word1 word2" VAR2=word3 "VAR3=word 5 6"</programlisting>
|
||||
@ -349,7 +352,11 @@
|
||||
|
||||
<para>Setting environment variables for the manager process may be useful to modify its behaviour.
|
||||
See <ulink url="https://systemd.io/ENVIRONMENT">ENVIRONMENT</ulink> for a descriptions of some
|
||||
variables understood by <command>systemd</command>.</para></listitem>
|
||||
variables understood by <command>systemd</command>.</para>
|
||||
|
||||
<para>Simple <literal>%</literal>-specifier expansion is supported, see below for a list of supported
|
||||
specifiers.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
@ -440,6 +447,45 @@
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Specifiers</title>
|
||||
|
||||
<para>Specifiers may be used in the <varname>DefaultEnvironment=</varname> and
|
||||
<varname>ManagerEnvironment=</varname> settings. The following expansions are understood:</para>
|
||||
<table class='specifiers'>
|
||||
<title>Specifiers available</title>
|
||||
<tgroup cols='3' align='left' colsep='1' rowsep='1'>
|
||||
<colspec colname="spec" />
|
||||
<colspec colname="mean" />
|
||||
<colspec colname="detail" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Specifier</entry>
|
||||
<entry>Meaning</entry>
|
||||
<entry>Details</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="a"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="A"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="b"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="B"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="H"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="l"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="m"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="M"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="o"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="v"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="w"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="W"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="T"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="V"/>
|
||||
<xi:include href="standard-specifiers.xml" xpointer="percent"/>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See Also</title>
|
||||
<para>
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "signal-util.h"
|
||||
#include "socket-bind.h"
|
||||
#include "socket-netlink.h"
|
||||
#include "specifier.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
@ -2656,15 +2657,15 @@ int config_parse_environ(
|
||||
if (r == 0)
|
||||
return 0;
|
||||
|
||||
if (u) {
|
||||
if (u)
|
||||
r = unit_env_printf(u, word, &resolved);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to resolve unit specifiers in %s, ignoring: %m", word);
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
resolved = TAKE_PTR(word);
|
||||
else
|
||||
r = specifier_printf(word, sc_arg_max(), system_and_tmp_specifier_table, NULL, &resolved);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to resolve specifiers in %s, ignoring: %m", word);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!env_assignment_is_valid(resolved)) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
|
Loading…
Reference in New Issue
Block a user