diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index 8701005e6b..f31b2a239c 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -2384,10 +2384,9 @@ StandardInputData=SWNrIHNpdHplIGRhIHVuJyBlc3NlIEtsb3BzLAp1ZmYgZWVtYWwga2xvcHAncy in the system manager. When compiled for systems with "unmerged /usr" (/bin is not a symlink to /usr/bin), :/sbin:/bin is appended. In case of the - the user manager, each bin/ and sbin/ pair is switched, so - that programs from /usr/bin have higher priority than programs from - /usr/sbin, etc. It is recommended to not rely on this in any way, and have only - one program with a given name in $PATH. + the user manager, a different path may be configured by the distribution. It is recommended to not + rely on the order of entries, and have only one program with a given name in + $PATH. diff --git a/meson.build b/meson.build index 56b7bfea70..403705a6b1 100644 --- a/meson.build +++ b/meson.build @@ -824,6 +824,11 @@ conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash) conf.set10('VALGRIND', get_option('valgrind')) conf.set10('LOG_TRACE', get_option('log-trace')) +default_user_path = get_option('user-path') +if default_user_path != '' + conf.set_quoted('DEFAULT_USER_PATH', default_user_path) +endif + ##################################################################### threads = dependency('threads') @@ -3119,6 +3124,8 @@ status = [ 'default net.naming-scheme setting: @0@'.format(default_net_naming_scheme), 'default KillUserProcesses setting: @0@'.format(kill_user_processes), 'default locale: @0@'.format(default_locale), + 'default user $PATH: @0@'.format( + default_user_path != '' ? default_user_path : '(same as system services)'), 'systemd service watchdog: @0@'.format(watchdog_opt)] alt_dns_servers = '\n '.join(dns_servers.split(' ')) diff --git a/meson_options.txt b/meson_options.txt index 0919577fd7..79b09e021c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -59,6 +59,8 @@ option('valgrind', type : 'boolean', value : false, description : 'do extra operations to avoid valgrind warnings') option('log-trace', type : 'boolean', value : false, description : 'enable low level debug logging') +option('user-path', type : 'string', + description : '$PATH to use for user sessions') option('utmp', type : 'boolean', description : 'support for utmp/wtmp log handling') diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 71fb7041a3..111d85d445 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -11,41 +11,37 @@ #include "time-util.h" #define PATH_SPLIT_SBIN_BIN(x) x "sbin:" x "bin" -#define PATH_SPLIT_BIN_SBIN(x) x "bin:" x "sbin" #define PATH_SPLIT_SBIN_BIN_NULSTR(x) x "sbin\0" x "bin\0" #define PATH_NORMAL_SBIN_BIN(x) x "bin" -#define PATH_NORMAL_BIN_SBIN(x) x "bin" #define PATH_NORMAL_SBIN_BIN_NULSTR(x) x "bin\0" #if HAVE_SPLIT_BIN # define PATH_SBIN_BIN(x) PATH_SPLIT_SBIN_BIN(x) -# define PATH_BIN_SBIN(x) PATH_SPLIT_BIN_SBIN(x) # define PATH_SBIN_BIN_NULSTR(x) PATH_SPLIT_SBIN_BIN_NULSTR(x) #else # define PATH_SBIN_BIN(x) PATH_NORMAL_SBIN_BIN(x) -# define PATH_BIN_SBIN(x) PATH_NORMAL_BIN_SBIN(x) # define PATH_SBIN_BIN_NULSTR(x) PATH_NORMAL_SBIN_BIN_NULSTR(x) #endif #define DEFAULT_PATH_NORMAL PATH_SBIN_BIN("/usr/local/") ":" PATH_SBIN_BIN("/usr/") -#define DEFAULT_USER_PATH_NORMAL PATH_BIN_SBIN("/usr/local/") ":" PATH_BIN_SBIN("/usr/") #define DEFAULT_PATH_NORMAL_NULSTR PATH_SBIN_BIN_NULSTR("/usr/local/") PATH_SBIN_BIN_NULSTR("/usr/") #define DEFAULT_PATH_SPLIT_USR DEFAULT_PATH_NORMAL ":" PATH_SBIN_BIN("/") -#define DEFAULT_USER_PATH_SPLIT_USR DEFAULT_PATH_NORMAL ":" PATH_BIN_SBIN("/") #define DEFAULT_PATH_SPLIT_USR_NULSTR DEFAULT_PATH_NORMAL_NULSTR PATH_SBIN_BIN_NULSTR("/") #define DEFAULT_PATH_COMPAT PATH_SPLIT_SBIN_BIN("/usr/local/") ":" PATH_SPLIT_SBIN_BIN("/usr/") ":" PATH_SPLIT_SBIN_BIN("/") #if HAVE_SPLIT_USR # define DEFAULT_PATH DEFAULT_PATH_SPLIT_USR -# define DEFAULT_USER_PATH DEFAULT_USER_PATH_SPLIT_USR # define DEFAULT_PATH_NULSTR DEFAULT_PATH_SPLIT_USR_NULSTR #else # define DEFAULT_PATH DEFAULT_PATH_NORMAL -# define DEFAULT_USER_PATH DEFAULT_USER_PATH_NORMAL # define DEFAULT_PATH_NULSTR DEFAULT_PATH_NORMAL_NULSTR #endif +#ifndef DEFAULT_USER_PATH +# define DEFAULT_USER_PATH DEFAULT_PATH +#endif + bool is_path(const char *p) _pure_; int path_split_and_make_absolute(const char *p, char ***ret); bool path_is_absolute(const char *p) _pure_; diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index ece3eb427c..46cdbaf5cc 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -15,6 +15,11 @@ #include "tests.h" #include "util.h" +static void test_print_paths(void) { + log_info("DEFAULT_PATH=%s", DEFAULT_PATH); + log_info("DEFAULT_USER_PATH=%s", DEFAULT_USER_PATH); +} + #define test_path_compare(a, b, result) { \ assert_se(path_compare(a, b) == result); \ assert_se(path_compare(b, a) == -result); \ @@ -659,6 +664,7 @@ static void test_path_startswith_strv(void) { int main(int argc, char **argv) { test_setup_logging(LOG_DEBUG); + test_print_paths(); test_path(); test_path_equal_root(); test_find_binary(argv[0]);