Skip to content

Commit

Permalink
path: use ROOTPREFIX properly
Browse files Browse the repository at this point in the history
ROOTPREFIX doesn't include the trailing /, hence add it in where needed.

Also, given that sysctl.d/, binfmt.d/, sysusers.d/ are generally
accessed before /var/ is up they should use ROOTPREFIX rather than
PREFIX. Fix that.
  • Loading branch information
poettering committed May 28, 2020
1 parent 08b8f29 commit 4a56315
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/core/systemd.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ systemdshutdowndir=${systemd_shutdown_dir}
tmpfiles_dir=${prefix}/lib/tmpfiles.d
tmpfilesdir=${tmpfiles_dir}

sysusers_dir=${prefix}/lib/sysusers.d
sysusers_dir=${rootprefix}/lib/sysusers.d
sysusersdir=${sysusers_dir}

sysctl_dir=${prefix}/lib/sysctl.d
sysctl_dir=${rootprefix}/lib/sysctl.d
sysctldir=${sysctl_dir}

binfmt_dir=${prefix}/lib/binfmt.d
binfmt_dir=${rootprefix}/lib/binfmt.d
binfmtdir=${binfmt_dir}

modules_load_dir=${prefix}/lib/modules-load.d
modules_load_dir=${rootprefix}/lib/modules-load.d
modulesloaddir=${modules_load_dir}

catalog_dir=${prefix}/lib/systemd/catalog
Expand Down
18 changes: 9 additions & 9 deletions src/libsystemd/sd-path/sd-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,23 +321,23 @@ static int get_path(uint64_t type, char **buffer, const char **ret) {
return from_user_dir("XDG_DESKTOP_DIR", buffer, ret);

case SD_PATH_SYSTEMD_UTIL_DIR:
*ret = ROOTPREFIX "lib/systemd";
*ret = ROOTPREFIX "/lib/systemd";
return 0;

case SD_PATH_SYSTEMD_SYSTEM_UNIT_DIR:
*ret = SYSTEM_DATA_UNIT_PATH;
return 0;

case SD_PATH_SYSTEMD_SYSTEM_PRESET_DIR:
*ret = ROOTPREFIX "lib/systemd/system-preset";
*ret = ROOTPREFIX "/lib/systemd/system-preset";
return 0;

case SD_PATH_SYSTEMD_USER_UNIT_DIR:
*ret = USER_DATA_UNIT_DIR;
return 0;

case SD_PATH_SYSTEMD_USER_PRESET_DIR:
*ret = ROOTPREFIX "lib/systemd/user-preset";
*ret = ROOTPREFIX "/lib/systemd/user-preset";
return 0;

case SD_PATH_SYSTEMD_SYSTEM_CONF_DIR:
Expand All @@ -357,11 +357,11 @@ static int get_path(uint64_t type, char **buffer, const char **ret) {
return 0;

case SD_PATH_SYSTEMD_SLEEP_DIR:
*ret = ROOTPREFIX "lib/systemd/system-sleep";
*ret = ROOTPREFIX "/lib/systemd/system-sleep";
return 0;

case SD_PATH_SYSTEMD_SHUTDOWN_DIR:
*ret = ROOTPREFIX "lib/systemd/system-shutdown";
*ret = ROOTPREFIX "/lib/systemd/system-shutdown";
return 0;

/* FIXME: systemd.pc uses ${prefix}, but CONF_PATHS_NULSTR doesn't.
Expand All @@ -371,19 +371,19 @@ static int get_path(uint64_t type, char **buffer, const char **ret) {
return 0;

case SD_PATH_SYSUSERS_DIR:
*ret = "/usr/lib/sysusers.d";
*ret = ROOTPREFIX "/lib/sysusers.d";
return 0;

case SD_PATH_SYSCTL_DIR:
*ret = "/usr/lib/sysctl.d";
*ret = ROOTPREFIX "/lib/sysctl.d";
return 0;

case SD_PATH_BINFMT_DIR:
*ret = "/usr/lib/binfmt.d";
*ret = ROOTPREFIX "/lib/binfmt.d";
return 0;

case SD_PATH_MODULES_LOAD_DIR:
*ret = "/usr/lib/modules-load.d";
*ret = ROOTPREFIX "/lib/modules-load.d";
return 0;

case SD_PATH_CATALOG_DIR:
Expand Down

3 comments on commit 4a56315

@mbiebl
Copy link
Contributor

@mbiebl mbiebl commented on 4a56315 Sep 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really make sense to me. We require initramfs to pre-mount /usr, if it's separate.
So why move the files from /usr to /?

@keszybz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, sure, the split into / and /usr makes no sense and things don't really work with the split. But we're trying to pretend that it does for the sake of those distros that require it. And conceptually, those files are part of early root. Hopefully we can drop the split soon.

@poettering
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbiebl: so if we'd drop rootprefixdir entirely, and install everything in /usr/bin/, would debian be upset? do you still support systems with unmerged /usr?

I mean, as long as we keep the support for rootprefixdir in the codebase we should probably do something vaguely sensible and not something entirely random. Because if it would be random then it would be useless and we could just drop it entirely. Can we?

Please sign in to comment.