Skip to content

Commit

Permalink
Fix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
wkennington committed Mar 22, 2017
1 parent dc1d97e commit 265d787
Show file tree
Hide file tree
Showing 50 changed files with 85 additions and 185 deletions.
3 changes: 1 addition & 2 deletions man/sysctl.d.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<refsynopsisdiv>
<para><filename>/etc/sysctl.d/*.conf</filename></para>
<para><filename>/run/sysctl.d/*.conf</filename></para>
<para><filename>/usr/lib/sysctl.d/*.conf</filename></para>
</refsynopsisdiv>

<refsect1>
Expand Down Expand Up @@ -128,7 +127,7 @@
</para>

<programlisting>ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", \
RUN+="/usr/lib/systemd/systemd-sysctl --prefix=/net/bridge"
RUN+="/run/current-system/sw/lib/systemd/systemd-sysctl --prefix=/net/bridge"
</programlisting>

<para><filename>/etc/sysctl.d/bridge.conf</filename>:
Expand Down
23 changes: 4 additions & 19 deletions src/basic/def.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,8 @@
#define SIGNALS_CRASH_HANDLER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
#define SIGNALS_IGNORE SIGPIPE

#ifdef HAVE_SPLIT_USR
#define KBD_KEYMAP_DIRS \
"/usr/share/keymaps/\0" \
"/usr/share/kbd/keymaps/\0" \
"/usr/lib/kbd/keymaps/\0" \
"/lib/kbd/keymaps/\0"
#else
#define KBD_KEYMAP_DIRS \
"/usr/share/keymaps/\0" \
"/usr/share/kbd/keymaps/\0" \
"/usr/lib/kbd/keymaps/\0"
#endif
#define KBD_KEYMAP_DIRS \
"/run/current-system/sw/share/keymaps/\0"

#define UNIX_SYSTEM_BUS_ADDRESS "unix:path=/var/run/dbus/system_bus_socket"
#define KERNEL_SYSTEM_BUS_ADDRESS "kernel:path=/sys/fs/kdbus/0-system/bus"
Expand All @@ -74,11 +64,7 @@
#define NOTIFY_FD_MAX 768
#define NOTIFY_BUFFER_MAX PIPE_BUF

#ifdef HAVE_SPLIT_USR
# define _CONF_PATHS_SPLIT_USR(n) "/lib/" n "\0"
#else
# define _CONF_PATHS_SPLIT_USR(n)
#endif
#define _CONF_PATHS_SPLIT_USR(n)

/* Return a nulstr for a standard cascade of configuration paths,
* suitable to pass to conf_files_list_nulstr() or config_parse_many_nulstr()
Expand All @@ -87,6 +73,5 @@
#define CONF_PATHS_NULSTR(n) \
"/etc/" n "\0" \
"/run/" n "\0" \
"/usr/local/lib/" n "\0" \
"/usr/lib/" n "\0" \
"/run/current-system/sw/lib/" n "\0" \
_CONF_PATHS_SPLIT_USR(n)
4 changes: 2 additions & 2 deletions src/basic/locale-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int add_locales_from_archive(Set *locales) {
unsigned i;
int r;

fd = open("/usr/lib/locale/locale-archive", O_RDONLY|O_NOCTTY|O_CLOEXEC);
fd = open("/run/current-system/sw/lib/locale/locale-archive", O_RDONLY|O_NOCTTY|O_CLOEXEC);
if (fd < 0)
return errno == ENOENT ? 0 : -errno;

Expand Down Expand Up @@ -146,7 +146,7 @@ static int add_locales_from_libdir (Set *locales) {
struct dirent *entry;
int r;

dir = opendir("/usr/lib/locale");
dir = opendir("/run/current-system/sw/lib/locale");
if (!dir)
return errno == ENOENT ? 0 : -errno;

Expand Down
3 changes: 1 addition & 2 deletions src/basic/path-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@ static int binary_is_good(const char *binary) {
return r;

return !PATH_IN_SET(d, "true"
"/bin/true",
"/usr/bin/true",
"/run/current-system/sw/bin/true",
"/dev/null");
}

Expand Down
2 changes: 1 addition & 1 deletion src/basic/path-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "time-util.h"

#define DEFAULT_PATH_NORMAL "/no-such-path"
#define DEFAULT_PATH_SPLIT_USR DEFAULT_PATH_NORMAL ":/sbin:/bin"
#define DEFAULT_PATH_SPLIT_USR DEFAULT_PATH_NORMAL

#ifdef HAVE_SPLIT_USR
# define DEFAULT_PATH DEFAULT_PATH_SPLIT_USR
Expand Down
13 changes: 4 additions & 9 deletions src/basic/stat-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,10 @@ int path_is_os_tree(const char *path) {
if (laccess(path, F_OK) < 0)
return -errno;

/* We use /usr/lib/os-release as flag file if something is an OS */
r = chase_symlinks("/usr/lib/os-release", path, CHASE_PREFIX_ROOT, NULL);
if (r == -ENOENT) {

/* Also check for the old location in /etc, just in case. */
r = chase_symlinks("/etc/os-release", path, CHASE_PREFIX_ROOT, NULL);
if (r == -ENOENT)
return 0; /* We got nothing */
}
/* Also check for the old location in /etc, just in case. */
r = chase_symlinks("/etc/os-release", path, CHASE_PREFIX_ROOT, NULL);
if (r == -ENOENT)
return 0; /* We got nothing */
if (r < 0)
return r;

Expand Down
1 change: 1 addition & 0 deletions src/basic/user-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ int get_user_creds_clean(

if (shell &&
(isempty(*shell) || PATH_IN_SET(*shell,
"/run/current-system/sw/bin/nologin",
"/bin/nologin",
"/sbin/nologin",
"/usr/bin/nologin",
Expand Down
13 changes: 4 additions & 9 deletions src/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1251,11 +1251,6 @@ static int status_welcome(void) {
"PRETTY_NAME", &pretty_name,
"ANSI_COLOR", &ansi_color,
NULL);
if (r == -ENOENT)
r = parse_env_file("/usr/lib/os-release", NEWLINE,
"PRETTY_NAME", &pretty_name,
"ANSI_COLOR", &ansi_color,
NULL);

if (r < 0 && r != -ENOENT)
log_warning_errno(r, "Failed to read os-release file: %m");
Expand Down Expand Up @@ -1543,7 +1538,7 @@ int main(int argc, char *argv[]) {
/* But at the same time, turn off the core_pattern logic by default, so that no coredumps are stored
* until the systemd-coredump tool is enabled via sysctl. */
if (!skip_setup)
(void) write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0);
(void) write_string_file("/proc/sys/kernel/core_pattern", "|/run/current-system/sw/bin/false", 0);
}

if (arg_system) {
Expand Down Expand Up @@ -2119,18 +2114,18 @@ int main(int argc, char *argv[]) {
log_warning_errno(errno, "Failed to execute configured init, trying fallback: %m");
}

args[0] = "/sbin/init";
args[0] = "/no-such-path/init";
(void) execv(args[0], (char* const*) args);

if (errno == ENOENT) {
log_warning("No /sbin/init, trying fallback");
log_warning("No /no-such-path/init, trying fallback");

args[0] = "/bin/sh";
args[1] = NULL;
(void) execv(args[0], (char* const*) args);
log_error_errno(errno, "Failed to execute /bin/sh, giving up: %m");
} else
log_warning_errno(errno, "Failed to execute /sbin/init, giving up: %m");
log_warning_errno(errno, "Failed to execute /no-such-path/init, giving up: %m");
}

arg_serialization = safe_fclose(arg_serialization);
Expand Down
4 changes: 2 additions & 2 deletions src/core/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -3015,16 +3015,16 @@ static bool generator_path_any(const char* const* paths) {
}

static const char* system_env_generator_binary_paths[] = {
"/run/systemd/system-environment-generators",
"/etc/systemd/system-environment-generators",
"/run/systemd/system-environment-generators",
"/usr/local/lib/systemd/system-environment-generators",
SYSTEM_ENV_GENERATOR_PATH,
NULL
};

static const char* user_env_generator_binary_paths[] = {
"/run/systemd/user-environment-generators",
"/etc/systemd/user-environment-generators",
"/run/systemd/user-environment-generators",
"/usr/local/lib/systemd/user-environment-generators",
USER_ENV_GENERATOR_PATH,
NULL
Expand Down
4 changes: 2 additions & 2 deletions src/core/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ static bool mount_is_extrinsic(Mount *m) {

if (PATH_IN_SET(m->where, /* Don't bother with the OS data itself */
"/",
"/nix",
"/nix/store",
"/nix",
"/nix/store",
"/usr"))
return true;

Expand Down
2 changes: 2 additions & 0 deletions src/core/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ static const MountEntry protect_home_yes_table[] = {

/* ProtectSystem=yes table */
static const MountEntry protect_system_yes_table[] = {
{ "/nix/store", READONLY, true },
{ "/usr", READONLY, false },
{ "/boot", READONLY, true },
{ "/efi", READONLY, true },
};

/* ProtectSystem=full includes ProtectSystem=yes */
static const MountEntry protect_system_full_table[] = {
{ "/nix/store", READONLY, false },
{ "/usr", READONLY, false },
{ "/boot", READONLY, true },
{ "/efi", READONLY, true },
Expand Down
2 changes: 1 addition & 1 deletion src/core/org.freedesktop.systemd1.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

[D-BUS Service]
Name=org.freedesktop.systemd1
Exec=/bin/false
Exec=/run/current-system/sw/bin/false
User=root
4 changes: 2 additions & 2 deletions src/core/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ static void swap_enter_activating(Swap *s) {
}
}

r = exec_command_set(s->control_command, "/sbin/swapon", NULL);
r = exec_command_set(s->control_command, "/run/current-system/sw/bin/swapon", NULL);
if (r < 0)
goto fail;

Expand Down Expand Up @@ -799,7 +799,7 @@ static void swap_enter_deactivating(Swap *s) {
s->control_command = s->exec_command + SWAP_EXEC_DEACTIVATE;

r = exec_command_set(s->control_command,
"/sbin/swapoff",
"/run/current-system/sw/bin/swapoff",
s->what,
NULL);
if (r < 0)
Expand Down
2 changes: 1 addition & 1 deletion src/coredump/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ static int gather_pid_metadata(
/* If this is PID 1 disable coredump collection, we'll unlikely be able to process it later on. */
if (is_pid1_crash((const char**) context)) {
log_notice("Due to PID 1 having crashed coredump collection will now be turned off.");
(void) write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0);
(void) write_string_file("/proc/sys/kernel/core_pattern", "|/run/current-system/sw/bin/false", 0);
}

set_iovec_field(iovec, n_iovec, "COREDUMP_UNIT=", context[CONTEXT_UNIT]);
Expand Down
4 changes: 2 additions & 2 deletions src/cryptsetup/cryptsetup-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ static int create_disk(

if (tmp)
fprintf(f,
"ExecStartPost=/sbin/mke2fs '/dev/mapper/%s'\n",
"ExecStartPost=/run/current-system/sw/bin/mke2fs '/dev/mapper/%s'\n",
name);

if (swap)
fprintf(f,
"ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
"ExecStartPost=/run/current-system/sw/bin/mkswap '/dev/mapper/%s'\n",
name);

r = fflush_and_check(f);
Expand Down
8 changes: 1 addition & 7 deletions src/delta/delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@
static const char prefixes[] =
"/etc\0"
"/run\0"
"/usr/local/lib\0"
"/usr/local/share\0"
"/usr/lib\0"
"/usr/share\0"
#ifdef HAVE_SPLIT_USR
"/lib\0"
#endif
"/run/current-software/sw/lib\0"
;

static const char suffixes[] =
Expand Down
7 changes: 0 additions & 7 deletions src/firstboot/firstboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ static void print_welcome(void) {
r = parse_env_file(os_release, NEWLINE,
"PRETTY_NAME", &pretty_name,
NULL);
if (r == -ENOENT) {

os_release = prefix_roota(arg_root, "/usr/lib/os-release");
r = parse_env_file(os_release, NEWLINE,
"PRETTY_NAME", &pretty_name,
NULL);
}

if (r < 0 && r != -ENOENT)
log_warning_errno(r, "Failed to read os-release file: %m");
Expand Down
4 changes: 3 additions & 1 deletion src/fstab-generator/fstab-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ static bool mount_in_initrd(struct mntent *me) {
assert(me);

return fstab_test_option(me->mnt_opts, "x-initrd.mount\0") ||
streq(me->mnt_dir, "/usr");
streq(me->mnt_dir, "/usr") ||
streq(me->mnt_dir, "/nix") ||
streq(me->mnt_dir, "/nix/store");
}

static int write_timeout(FILE *f, const char *where, const char *opts,
Expand Down
5 changes: 0 additions & 5 deletions src/hostname/hostnamed.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ static int context_read_data(Context *c) {
"PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
"CPE_NAME", &c->data[PROP_OS_CPE_NAME],
NULL);
if (r == -ENOENT)
r = parse_env_file("/usr/lib/os-release", NEWLINE,
"PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
"CPE_NAME", &c->data[PROP_OS_CPE_NAME],
NULL);

if (r < 0 && r != -ENOENT)
return r;
Expand Down
2 changes: 1 addition & 1 deletion src/hostname/org.freedesktop.hostname1.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

[D-BUS Service]
Name=org.freedesktop.hostname1
Exec=/bin/false
Exec=/run/current-system/sw/bin/false
User=root
SystemdService=dbus-org.freedesktop.hostname1.service
2 changes: 1 addition & 1 deletion src/import/org.freedesktop.import1.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

[D-BUS Service]
Name=org.freedesktop.import1
Exec=/bin/false
Exec=/run/current-system/sw/bin/false
User=root
SystemdService=dbus-org.freedesktop.import1.service
3 changes: 1 addition & 2 deletions src/journal-remote/journal-gatewayd.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,7 @@ static int request_handler_machine(
if (r < 0)
return mhd_respondf(connection, r, MHD_HTTP_INTERNAL_SERVER_ERROR, "Failed to determine disk usage: %m");

if (parse_env_file("/etc/os-release", NEWLINE, "PRETTY_NAME", &os_name, NULL) == -ENOENT)
(void) parse_env_file("/usr/lib/os-release", NEWLINE, "PRETTY_NAME", &os_name, NULL);
(void) parse_env_file("/etc/os-release", NEWLINE, "PRETTY_NAME", &os_name, NULL);

get_virtualization(&v);

Expand Down
2 changes: 1 addition & 1 deletion src/journal/cat.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ int main(int argc, char *argv[]) {
fd = -1;

if (argc <= optind)
(void) execl("/bin/cat", "/bin/cat", NULL);
(void) execl("/run/current-system/sw/bin/cat", "/run/current-system/sw/bin/cat", NULL);
else
(void) execvp(argv[optind], argv + optind);
r = -errno;
Expand Down
3 changes: 1 addition & 2 deletions src/journal/catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
#include "util.h"

const char * const catalog_file_dirs[] = {
"/usr/local/lib/systemd/catalog/",
"/usr/lib/systemd/catalog/",
"/run/current-system/sw/lib/systemd/catalog/",
NULL
};

Expand Down
3 changes: 1 addition & 2 deletions src/kernel-install/kernel-install
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ ret=0

readarray -t PLUGINS <<<"$(
dropindirs_sort ".install" \
"/etc/kernel/install.d" \
"/usr/lib/kernel/install.d"
"/etc/kernel/install.d"
)"

case $COMMAND in
Expand Down
4 changes: 0 additions & 4 deletions src/libsystemd/sd-hwdb/sd-hwdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,6 @@ static int trie_search_f(sd_hwdb *hwdb, const char *search) {
static const char hwdb_bin_paths[] =
"/etc/systemd/hwdb/hwdb.bin\0"
"/etc/udev/hwdb.bin\0"
"/usr/lib/systemd/hwdb/hwdb.bin\0"
#ifdef HAVE_SPLIT_USR
"/lib/systemd/hwdb/hwdb.bin\0"
#endif
UDEVLIBEXECDIR "/hwdb.bin\0";

_public_ int sd_hwdb_new(sd_hwdb **ret) {
Expand Down
Loading

0 comments on commit 265d787

Please sign in to comment.