From 969309c2b424f888b7d118e6ae66d4d3f009d91f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 21 Jun 2018 03:20:34 +0900 Subject: [PATCH 1/2] core: add unit specifier for configuration directory root Follow-up for 14068e17f32a06e6a1f8f72416018bc653b8ea2d. --- man/systemd.unit.xml | 5 +++++ src/core/unit-printf.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index 673f5575db..92c0f6297a 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -1535,6 +1535,11 @@ Cache directory root This is either /var/cache (for the system manager) or the path $XDG_CACHE_HOME resolves to (for user managers). + + %E + Configuration directory root + This is either /etc (for the system manager) or the path $XDG_CONFIG_HOME resolves to (for user managers). + %f Unescaped filename diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c index 92896d90be..046e937e92 100644 --- a/src/core/unit-printf.c +++ b/src/core/unit-printf.c @@ -227,6 +227,7 @@ int unit_full_printf(Unit *u, const char *format, char **ret) { * %S: the state directory root (e.g. /var/lib or $XDG_CONFIG_HOME) * %C: the cache directory root (e.g. /var/cache or $XDG_CACHE_HOME) * %L: the log directory root (e.g. /var/log or $XDG_CONFIG_HOME/log) + * %E: the configuration directory root (e.g. /etc or $XDG_CONFIG_HOME) * %T: the temporary directory (e.g. /tmp, or $TMPDIR, $TEMP, $TMP) * %V: the temporary directory for large, persistent stuff (e.g. /var/tmp, or $TMPDIR, $TEMP, $TMP) * @@ -259,6 +260,7 @@ int unit_full_printf(Unit *u, const char *format, char **ret) { { 'S', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_STATE) }, { 'C', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_CACHE) }, { 'L', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_LOGS) }, + { 'E', specifier_special_directory, UINT_TO_PTR(EXEC_DIRECTORY_CONFIGURATION) }, { 'T', specifier_tmp_dir, NULL }, { 'V', specifier_var_tmp_dir, NULL }, From d45e481ed20a3dd10395fbd94e27222a5f51d4be Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 21 Jun 2018 03:24:09 +0900 Subject: [PATCH 2/2] test: add test for specifier of configuration directory root --- test/test-execute/exec-specifier.service | 1 + test/test-execute/exec-specifier@.service | 1 + 2 files changed, 2 insertions(+) diff --git a/test/test-execute/exec-specifier.service b/test/test-execute/exec-specifier.service index e46373ddfe..13ba859879 100644 --- a/test/test-execute/exec-specifier.service +++ b/test/test-execute/exec-specifier.service @@ -16,6 +16,7 @@ ExecStart=test %t = /run ExecStart=test %S = /var/lib ExecStart=test %C = /var/cache ExecStart=test %L = /var/log +ExecStart=test %E = /etc ExecStart=test %T = /tmp ExecStart=test %V = /var/tmp ExecStart=sh -c 'test %u = $$(id -un 0)' diff --git a/test/test-execute/exec-specifier@.service b/test/test-execute/exec-specifier@.service index 5846de1655..174559dbd1 100644 --- a/test/test-execute/exec-specifier@.service +++ b/test/test-execute/exec-specifier@.service @@ -16,6 +16,7 @@ ExecStart=test %t = /run ExecStart=test %S = /var/lib ExecStart=test %C = /var/cache ExecStart=test %L = /var/log +ExecStart=test %E = /etc ExecStart=sh -c 'test %u = $$(id -un 0)' ExecStart=test %U = 0 ExecStart=sh -c 'test %h = $$(getent passwd 0 | cut -d: -f 6)'