summaryrefslogtreecommitdiffstats
path: root/src/core/load-fragment.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-05-26 17:17:11 +0200
committerLennart Poettering <lennart@poettering.net>2021-05-26 17:20:36 +0200
commit46a9ee5d9b913716205505f84d60d544b76878e7 (patch)
tree57057d93f568d9a3a574788391e9a9310beed947 /src/core/load-fragment.c
parentrepart: resolve $TMP specifiers too (diff)
downloadsystemd-46a9ee5d9b913716205505f84d60d544b76878e7.tar.xz
systemd-46a9ee5d9b913716205505f84d60d544b76878e7.zip
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
Diffstat (limited to '')
-rw-r--r--src/core/load-fragment.c17
1 files changed, 9 insertions, 8 deletions
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,