mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
Merge pull request #14003 from keszybz/user-path-configurable
meson: make user $PATH configurable
This commit is contained in:
commit
67f5b9e06e
@ -2384,10 +2384,9 @@ StandardInputData=SWNrIHNpdHplIGRhIHVuJyBlc3NlIEtsb3BzLAp1ZmYgZWVtYWwga2xvcHAncy
|
||||
in the system manager. When compiled for systems with "unmerged /usr" (<filename>/bin</filename> is
|
||||
not a symlink to <filename>/usr/bin</filename>),
|
||||
<literal>:<filename>/sbin</filename>:<filename>/bin</filename></literal> is appended. In case of the
|
||||
the user manager, each <filename>bin/</filename> and <filename>sbin/</filename> pair is switched, so
|
||||
that programs from <filename>/usr/bin</filename> have higher priority than programs from
|
||||
<filename>/usr/sbin</filename>, etc. It is recommended to not rely on this in any way, and have only
|
||||
one program with a given name in <varname>$PATH</varname>.</para></listitem>
|
||||
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
|
||||
<varname>$PATH</varname>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
11
meson.build
11
meson.build
@ -834,6 +834,16 @@ 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)
|
||||
default_user_path_display = default_user_path
|
||||
else
|
||||
# meson 0.49 fails when ?: is used in .format()
|
||||
default_user_path_display = '(same as system services)'
|
||||
endif
|
||||
|
||||
|
||||
#####################################################################
|
||||
|
||||
threads = dependency('threads')
|
||||
@ -3129,6 +3139,7 @@ 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_display),
|
||||
'systemd service watchdog: @0@'.format(watchdog_opt)]
|
||||
|
||||
alt_dns_servers = '\n '.join(dns_servers.split(' '))
|
||||
|
@ -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')
|
||||
|
@ -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_;
|
||||
|
@ -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]);
|
||||
|
Loading…
Reference in New Issue
Block a user