From dc04a884e07796335fe0899c74f1c1a3635ce110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 13 Nov 2025 14:02:30 +0100 Subject: [PATCH] systemd-path: add 'system-search-configuration' This provides functionality to replace what was provided by the preceding revert: $ build/systemd-path system-search-configuration --suffix=sysctl.d /etc/sysctl.d:/run/sysctl.d:/usr/local/lib/sysctl.d:/usr/lib/sysctl.d The result is identical, but more generic, since by changing suffix we can also get the answer for sysusers.d, tmpfiles.d, and any other of the directories which follow the same general rule. --- man/sd_path_lookup.xml | 1 + src/libsystemd/sd-path/sd-path.c | 3 +++ src/path/path-tool.c | 2 ++ src/systemd/sd-path.h | 3 +++ test/units/TEST-74-AUX-UTILS.path.sh | 2 ++ 5 files changed, 11 insertions(+) diff --git a/man/sd_path_lookup.xml b/man/sd_path_lookup.xml index fc6bac640c..9190e6b00a 100644 --- a/man/sd_path_lookup.xml +++ b/man/sd_path_lookup.xml @@ -41,6 +41,7 @@ SD_PATH_SYSTEM_STATE_FACTORY, SD_PATH_SYSTEM_CONFIGURATION, + SD_PATH_SYSTEM_SEARCH_CONFIGURATION, SD_PATH_SYSTEM_RUNTIME, SD_PATH_SYSTEM_RUNTIME_LOGS, SD_PATH_SYSTEM_STATE_PRIVATE, diff --git a/src/libsystemd/sd-path/sd-path.c b/src/libsystemd/sd-path/sd-path.c index 0096997135..b80b8ca68d 100644 --- a/src/libsystemd/sd-path/sd-path.c +++ b/src/libsystemd/sd-path/sd-path.c @@ -524,6 +524,9 @@ static int get_search(uint64_t type, char ***ret) { switch (type) { + case SD_PATH_SYSTEM_SEARCH_CONFIGURATION: + return strv_from_nulstr(ret, CONF_PATHS_NULSTR("")); + case SD_PATH_SEARCH_BINARIES: return search_from_environment(ret, NULL, diff --git a/src/path/path-tool.c b/src/path/path-tool.c index 3dc31832b3..227468dfe8 100644 --- a/src/path/path-tool.c +++ b/src/path/path-tool.c @@ -22,6 +22,8 @@ static const char* const path_table[_SD_PATH_MAX] = { [SD_PATH_TEMPORARY] = "temporary", [SD_PATH_TEMPORARY_LARGE] = "temporary-large", + [SD_PATH_SYSTEM_SEARCH_CONFIGURATION] = "system-search-configuration", + [SD_PATH_SYSTEM_BINARIES] = "system-binaries", [SD_PATH_SYSTEM_INCLUDE] = "system-include", [SD_PATH_SYSTEM_LIBRARY_PRIVATE] = "system-library-private", diff --git a/src/systemd/sd-path.h b/src/systemd/sd-path.h index eb42e31a68..2718cf8266 100644 --- a/src/systemd/sd-path.h +++ b/src/systemd/sd-path.h @@ -44,6 +44,9 @@ __extension__ enum { SD_PATH_SYSTEM_STATE_CACHE, SD_PATH_SYSTEM_STATE_SPOOL, + /* generic system configuration */ + SD_PATH_SYSTEM_SEARCH_CONFIGURATION, + /* Vendor supplied data */ SD_PATH_USER_BINARIES, SD_PATH_USER_LIBRARY_PRIVATE, diff --git a/test/units/TEST-74-AUX-UTILS.path.sh b/test/units/TEST-74-AUX-UTILS.path.sh index 79056a5b2b..4547f53e24 100755 --- a/test/units/TEST-74-AUX-UTILS.path.sh +++ b/test/units/TEST-74-AUX-UTILS.path.sh @@ -51,6 +51,8 @@ assert_eq "$(systemd-path --suffix='' system-runtime)" "/run" assert_eq "$(systemd-path --suffix='🤔' system-runtime)" "/run/🤔" assert_eq "$(systemd-path --suffix=hello system-runtime)" "/run/hello" +assert_eq "$(systemd-path system-search-configuration --suffix=sysctl.d)" "/etc/sysctl.d:/run/sysctl.d:/usr/local/lib/sysctl.d:/usr/lib/sysctl.d" + # Note for the stuff below: everything defaults to $HOME, only the desktop # directory defaults to $HOME/Desktop. #