mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
meson: make user $PATH configurable
This partially reverts db11487d10
(the logic to
calculate the correct value is removed, we always use the same setting as for
the system manager). Distributions have an easy mechanism to override this if
they wish.
I think making this configurable is better, because different distros clearly
want different defaults here, and making this configurable is nice and clean.
If we don't make it configurable, distros which either have to carry patches,
or what would be worse, rely on some other configuration mechanism, like
/etc/profile. Those other solutions do not apply everywhere (they usually
require the shell to be used at some point), so it is better if we provide
a nice way to override the default.
Fixes #13469.
This commit is contained in:
parent
9e9dd3e329
commit
3602ca6f0c
@ -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>
|
||||
|
@ -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(' '))
|
||||
|
@ -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