diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
index 3f229908c9..2851bae31e 100644
--- a/man/systemd-system.conf.xml
+++ b/man/systemd-system.conf.xml
@@ -328,6 +328,9 @@
project='man-pages'>environ7 for
details about environment variables.
+ Simple %-specifier expansion is supported, see below for a list of supported
+ specifiers.
+
Example:
DefaultEnvironment="VAR1=word1 word2" VAR2=word3 "VAR3=word 5 6"
@@ -349,7 +352,11 @@
Setting environment variables for the manager process may be useful to modify its behaviour.
See ENVIRONMENT for a descriptions of some
- variables understood by systemd.
+ variables understood by systemd.
+
+ Simple %-specifier expansion is supported, see below for a list of supported
+ specifiers.
+
@@ -440,6 +447,45 @@
+
+ Specifiers
+
+ Specifiers may be used in the DefaultEnvironment= and
+ ManagerEnvironment= settings. The following expansions are understood:
+
+ Specifiers available
+
+
+
+
+
+
+ Specifier
+ Meaning
+ Details
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
See Also
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index ff6eaf32ef..d31d642017 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -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,