From dcf20a0c2348cec9e56314354df3f53ef1c5237d Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 13 Apr 2023 22:35:34 +0200 Subject: [PATCH 1/3] systemd: reflow patches, remove whitespace error in Fix-hwdb-paths.patch --- .../linux/systemd/0003-Fix-NixOS-containers.patch | 6 +++--- ...t-rid-of-a-useless-message-in-user-sessions.patch | 2 +- .../linux/systemd/0007-Fix-hwdb-paths.patch | 9 ++++----- ...8-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch | 12 ++++++------ ...-t-create-statedir-and-don-t-touch-prefixdi.patch | 4 ++-- .../0011-add-rootprefix-to-lookup-dir-paths.patch | 2 +- ...leep-execute-scripts-in-etc-systemd-system-.patch | 4 ++-- ...systemd-environment-when-calling-generators.patch | 2 +- .../0017-core-don-t-taint-on-unmerged-usr.patch | 4 ++-- ...-tpm2_context_init-fix-driver-name-checking.patch | 2 +- 10 files changed, 23 insertions(+), 24 deletions(-) diff --git a/pkgs/os-specific/linux/systemd/0003-Fix-NixOS-containers.patch b/pkgs/os-specific/linux/systemd/0003-Fix-NixOS-containers.patch index 349194fda45a..c0d38c60202c 100644 --- a/pkgs/os-specific/linux/systemd/0003-Fix-NixOS-containers.patch +++ b/pkgs/os-specific/linux/systemd/0003-Fix-NixOS-containers.patch @@ -10,10 +10,10 @@ container, so checking early whether it exists will fail. 1 file changed, 2 insertions(+) diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c -index 36d336dfc8..d62c5173ca 100644 +index a697ea5cb9..65d9e7e398 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c -@@ -5634,6 +5634,7 @@ static int run(int argc, char *argv[]) { +@@ -5635,6 +5635,7 @@ static int run(int argc, char *argv[]) { goto finish; } } else { @@ -21,7 +21,7 @@ index 36d336dfc8..d62c5173ca 100644 _cleanup_free_ char *p = NULL; if (arg_pivot_root_new) -@@ -5648,6 +5649,7 @@ static int run(int argc, char *argv[]) { +@@ -5649,6 +5650,7 @@ static int run(int argc, char *argv[]) { "Directory %s doesn't look like it has an OS tree (/usr/ directory is missing). Refusing.", arg_directory); goto finish; } diff --git a/pkgs/os-specific/linux/systemd/0006-Get-rid-of-a-useless-message-in-user-sessions.patch b/pkgs/os-specific/linux/systemd/0006-Get-rid-of-a-useless-message-in-user-sessions.patch index 336e2b8831e7..0a638dfbf0ea 100644 --- a/pkgs/os-specific/linux/systemd/0006-Get-rid-of-a-useless-message-in-user-sessions.patch +++ b/pkgs/os-specific/linux/systemd/0006-Get-rid-of-a-useless-message-in-user-sessions.patch @@ -13,7 +13,7 @@ in containers. 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/manager.c b/src/core/manager.c -index 7b394794b0..50d092042c 100644 +index 380a4e30d7..817acb87b8 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1437,7 +1437,8 @@ static unsigned manager_dispatch_stop_when_bound_queue(Manager *m) { diff --git a/pkgs/os-specific/linux/systemd/0007-Fix-hwdb-paths.patch b/pkgs/os-specific/linux/systemd/0007-Fix-hwdb-paths.patch index 49e94b019c78..7777ba7e4259 100644 --- a/pkgs/os-specific/linux/systemd/0007-Fix-hwdb-paths.patch +++ b/pkgs/os-specific/linux/systemd/0007-Fix-hwdb-paths.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Fix hwdb paths Patch by vcunat. --- - src/libsystemd/sd-hwdb/hwdb-internal.h | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) + src/libsystemd/sd-hwdb/hwdb-internal.h | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/libsystemd/sd-hwdb/hwdb-internal.h b/src/libsystemd/sd-hwdb/hwdb-internal.h -index 5302679a62..c681f3a984 100644 +index 5302679a62..39e59a527f 100644 --- a/src/libsystemd/sd-hwdb/hwdb-internal.h +++ b/src/libsystemd/sd-hwdb/hwdb-internal.h -@@ -83,8 +83,5 @@ struct trie_value_entry2_f { +@@ -83,8 +83,4 @@ struct trie_value_entry2_f { } _packed_; #define hwdb_bin_paths \ @@ -22,4 +22,3 @@ index 5302679a62..c681f3a984 100644 - _CONF_PATHS_SPLIT_USR_NULSTR("systemd/hwdb/hwdb.bin") \ - UDEVLIBEXECDIR "/hwdb.bin\0" + "/etc/udev/hwdb.bin\0" -+ diff --git a/pkgs/os-specific/linux/systemd/0008-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch b/pkgs/os-specific/linux/systemd/0008-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch index 69823095a59d..ac2b036cb778 100644 --- a/pkgs/os-specific/linux/systemd/0008-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch +++ b/pkgs/os-specific/linux/systemd/0008-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch @@ -35,10 +35,10 @@ index e486474c44..5f373d0723 100644 Etc/UTC. The resulting link should lead to the corresponding binary diff --git a/src/basic/time-util.c b/src/basic/time-util.c -index b700f364ef..116b1cec63 100644 +index 0bea149324..4b16115d43 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c -@@ -1282,7 +1282,7 @@ static int get_timezones_from_zone1970_tab(char ***ret) { +@@ -1283,7 +1283,7 @@ static int get_timezones_from_zone1970_tab(char ***ret) { assert(ret); @@ -47,7 +47,7 @@ index b700f364ef..116b1cec63 100644 if (!f) return -errno; -@@ -1321,7 +1321,7 @@ static int get_timezones_from_tzdata_zi(char ***ret) { +@@ -1322,7 +1322,7 @@ static int get_timezones_from_tzdata_zi(char ***ret) { _cleanup_strv_free_ char **zones = NULL; int r; @@ -56,7 +56,7 @@ index b700f364ef..116b1cec63 100644 if (!f) return -errno; -@@ -1433,7 +1433,7 @@ int verify_timezone(const char *name, int log_level) { +@@ -1434,7 +1434,7 @@ int verify_timezone(const char *name, int log_level) { if (p - name >= PATH_MAX) return -ENAMETOOLONG; @@ -65,7 +65,7 @@ index b700f364ef..116b1cec63 100644 fd = open(t, O_RDONLY|O_CLOEXEC); if (fd < 0) -@@ -1491,7 +1491,7 @@ int get_timezone(char **ret) { +@@ -1492,7 +1492,7 @@ int get_timezone(char **ret) { if (r < 0) return r; /* returns EINVAL if not a symlink */ @@ -88,7 +88,7 @@ index 9e79f84691..1a1c75718c 100644 (void) mkdir_parents(etc_localtime, 0755); r = symlink_atomic(e, etc_localtime); diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c -index d62c5173ca..84beac064b 100644 +index 65d9e7e398..dd44d529ca 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -1915,8 +1915,8 @@ int userns_mkdir(const char *root, const char *path, mode_t mode, uid_t uid, gid diff --git a/pkgs/os-specific/linux/systemd/0010-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch b/pkgs/os-specific/linux/systemd/0010-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch index 01874c2be8e3..eec57111b913 100644 --- a/pkgs/os-specific/linux/systemd/0010-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch +++ b/pkgs/os-specific/linux/systemd/0010-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch @@ -8,10 +8,10 @@ Subject: [PATCH] build: don't create statedir and don't touch prefixdir 1 file changed, 3 deletions(-) diff --git a/meson.build b/meson.build -index bfc86857d6..84e3e4c1db 100644 +index b1f5477836..1a39484855 100644 --- a/meson.build +++ b/meson.build -@@ -4277,9 +4277,6 @@ install_data('LICENSE.GPL2', +@@ -4278,9 +4278,6 @@ install_data('LICENSE.GPL2', install_subdir('LICENSES', install_dir : docdir) diff --git a/pkgs/os-specific/linux/systemd/0011-add-rootprefix-to-lookup-dir-paths.patch b/pkgs/os-specific/linux/systemd/0011-add-rootprefix-to-lookup-dir-paths.patch index 6f64dce5e4b9..6e07928d5fbd 100644 --- a/pkgs/os-specific/linux/systemd/0011-add-rootprefix-to-lookup-dir-paths.patch +++ b/pkgs/os-specific/linux/systemd/0011-add-rootprefix-to-lookup-dir-paths.patch @@ -12,7 +12,7 @@ files that I might have missed. 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/basic/constants.h b/src/basic/constants.h -index 5d68cc6332..a2ccc315e1 100644 +index 5d68cc6332..33c06c1f65 100644 --- a/src/basic/constants.h +++ b/src/basic/constants.h @@ -73,13 +73,15 @@ diff --git a/pkgs/os-specific/linux/systemd/0013-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch b/pkgs/os-specific/linux/systemd/0013-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch index 99c0d93facb7..5fa3fb14f1ff 100644 --- a/pkgs/os-specific/linux/systemd/0013-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch +++ b/pkgs/os-specific/linux/systemd/0013-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch @@ -9,10 +9,10 @@ This is needed for NixOS to use such scripts as systemd directory is immutable. 1 file changed, 1 insertion(+) diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c -index 9c51a3367f..75d6b76a87 100644 +index 288fa4ae84..07deb19d7c 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c -@@ -184,6 +184,7 @@ static int execute( +@@ -186,6 +186,7 @@ static int execute( }; static const char* const dirs[] = { SYSTEM_SLEEP_PATH, diff --git a/pkgs/os-specific/linux/systemd/0016-inherit-systemd-environment-when-calling-generators.patch b/pkgs/os-specific/linux/systemd/0016-inherit-systemd-environment-when-calling-generators.patch index 1cfd939a6392..236af4b2c97b 100644 --- a/pkgs/os-specific/linux/systemd/0016-inherit-systemd-environment-when-calling-generators.patch +++ b/pkgs/os-specific/linux/systemd/0016-inherit-systemd-environment-when-calling-generators.patch @@ -16,7 +16,7 @@ executables that are being called from managers. 1 file changed, 8 insertions(+) diff --git a/src/core/manager.c b/src/core/manager.c -index 50d092042c..898f9ed2f1 100644 +index 817acb87b8..3f31359f8a 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -3714,9 +3714,17 @@ static int build_generator_environment(Manager *m, char ***ret) { diff --git a/pkgs/os-specific/linux/systemd/0017-core-don-t-taint-on-unmerged-usr.patch b/pkgs/os-specific/linux/systemd/0017-core-don-t-taint-on-unmerged-usr.patch index 7a2e8dc670b0..18982ecd04bd 100644 --- a/pkgs/os-specific/linux/systemd/0017-core-don-t-taint-on-unmerged-usr.patch +++ b/pkgs/os-specific/linux/systemd/0017-core-don-t-taint-on-unmerged-usr.patch @@ -17,10 +17,10 @@ See also: https://github.com/systemd/systemd/issues/24191 1 file changed, 4 deletions(-) diff --git a/src/core/manager.c b/src/core/manager.c -index 898f9ed2f1..5040d5b105 100644 +index 3f31359f8a..0c4ec0b4fb 100644 --- a/src/core/manager.c +++ b/src/core/manager.c -@@ -4543,10 +4543,6 @@ char* manager_taint_string(const Manager *m) { +@@ -4556,10 +4556,6 @@ char* manager_taint_string(const Manager *m) { if (m->taint_usr) stage[n++] = "split-usr"; diff --git a/pkgs/os-specific/linux/systemd/0018-tpm2_context_init-fix-driver-name-checking.patch b/pkgs/os-specific/linux/systemd/0018-tpm2_context_init-fix-driver-name-checking.patch index 115ce78d7134..8d6eab5ed847 100644 --- a/pkgs/os-specific/linux/systemd/0018-tpm2_context_init-fix-driver-name-checking.patch +++ b/pkgs/os-specific/linux/systemd/0018-tpm2_context_init-fix-driver-name-checking.patch @@ -27,7 +27,7 @@ filename_is_valid with path_is_valid. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c -index 259f280e0f..142e70a740 100644 +index 4345b95106..424a334df1 100644 --- a/src/shared/tpm2-util.c +++ b/src/shared/tpm2-util.c @@ -176,7 +176,7 @@ int tpm2_context_new(const char *device, Tpm2Context **ret_context) { From 4e0210b76d8e9e69cf901b37cb53f55ff7e022c5 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 13 Apr 2023 22:56:40 +0200 Subject: [PATCH 2/3] systemd: re-do fsck patch This patches some more occurences, addresses upstream feedback, and was sent upstream at https://github.com/systemd/systemd/pull/27274. --- ...004-Look-for-fsck-in-the-right-place.patch | 33 ---- ...ook-for-fsck-binary-not-just-in-sbin.patch | 152 ++++++++++++++++++ pkgs/os-specific/linux/systemd/default.nix | 2 +- 3 files changed, 153 insertions(+), 34 deletions(-) delete mode 100644 pkgs/os-specific/linux/systemd/0004-Look-for-fsck-in-the-right-place.patch create mode 100644 pkgs/os-specific/linux/systemd/0004-fsck-look-for-fsck-binary-not-just-in-sbin.patch diff --git a/pkgs/os-specific/linux/systemd/0004-Look-for-fsck-in-the-right-place.patch b/pkgs/os-specific/linux/systemd/0004-Look-for-fsck-in-the-right-place.patch deleted file mode 100644 index c31b9122b900..000000000000 --- a/pkgs/os-specific/linux/systemd/0004-Look-for-fsck-in-the-right-place.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Eelco Dolstra -Date: Thu, 1 May 2014 14:10:10 +0200 -Subject: [PATCH] Look for fsck in the right place - ---- - src/fsck/fsck.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c -index e25c5d5efa..26f4e5669e 100644 ---- a/src/fsck/fsck.c -+++ b/src/fsck/fsck.c -@@ -351,6 +351,7 @@ static int run(int argc, char *argv[]) { - if (r == 0) { - char dash_c[STRLEN("-C") + DECIMAL_STR_MAX(int) + 1]; - int progress_socket = -1; -+ _cleanup_free_ char *fsck_name = NULL; - const char *cmdline[9]; - int i = 0; - -@@ -371,7 +372,10 @@ static int run(int argc, char *argv[]) { - } else - dash_c[0] = 0; - -- cmdline[i++] = "/sbin/fsck"; -+ r = find_executable("fsck", &fsck_name); -+ if (r < 0) -+ return r; -+ cmdline[i++] = fsck_name; - cmdline[i++] = arg_repair; - cmdline[i++] = "-T"; - diff --git a/pkgs/os-specific/linux/systemd/0004-fsck-look-for-fsck-binary-not-just-in-sbin.patch b/pkgs/os-specific/linux/systemd/0004-fsck-look-for-fsck-binary-not-just-in-sbin.patch new file mode 100644 index 000000000000..617cef50cc3c --- /dev/null +++ b/pkgs/os-specific/linux/systemd/0004-fsck-look-for-fsck-binary-not-just-in-sbin.patch @@ -0,0 +1,152 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Florian Klink +Date: Thu, 13 Apr 2023 22:54:54 +0200 +Subject: [PATCH] fsck: look for fsck binary not just in /sbin + +This removes remaining hardcoded occurences of `/sbin/fsck`, and instead +uses `find_executable` to find `fsck`. + +We also use `fsck_exists_for_fstype` to check for the `fsck.*` +executable, which also checks in `$PATH`, so it's fair to assume fsck +itself is also available. +--- + man/systemd-fsck@.service.xml | 8 ++++---- + src/fsck/fsck.c | 9 ++++++++- + src/home/homework-luks.c | 11 ++++++++++- + src/shared/dissect-image.c | 13 +++++++++++-- + 4 files changed, 33 insertions(+), 8 deletions(-) + +diff --git a/man/systemd-fsck@.service.xml b/man/systemd-fsck@.service.xml +index e928aebdb3..403286829e 100644 +--- a/man/systemd-fsck@.service.xml ++++ b/man/systemd-fsck@.service.xml +@@ -51,17 +51,17 @@ + systemd-fsck does not know any details + about specific filesystems, and simply executes file system + checkers specific to each filesystem type +- (/sbin/fsck.type). These checkers will decide if ++ (fsck.type). These checkers will decide if + the filesystem should actually be checked based on the time since + last check, number of mounts, unclean unmount, etc. + + systemd-fsck-root.service and systemd-fsck-usr.service +- will activate reboot.target if /sbin/fsck returns the "System +- should reboot" condition, or emergency.target if /sbin/fsck ++ will activate reboot.target if fsck returns the "System ++ should reboot" condition, or emergency.target if fsck + returns the "Filesystem errors left uncorrected" condition. + + systemd-fsck@.service will fail if +- /sbin/fsck returns with either "System should reboot" ++ fsck returns with either "System should reboot" + or "Filesystem errors left uncorrected" conditions. For filesystems + listed in /etc/fstab without nofail + or noauto options, local-fs.target +diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c +index e25c5d5efa..0e0e73c9ac 100644 +--- a/src/fsck/fsck.c ++++ b/src/fsck/fsck.c +@@ -351,6 +351,7 @@ static int run(int argc, char *argv[]) { + if (r == 0) { + char dash_c[STRLEN("-C") + DECIMAL_STR_MAX(int) + 1]; + int progress_socket = -1; ++ _cleanup_free_ char *fsck_path = NULL; + const char *cmdline[9]; + int i = 0; + +@@ -371,7 +372,13 @@ static int run(int argc, char *argv[]) { + } else + dash_c[0] = 0; + +- cmdline[i++] = "/sbin/fsck"; ++ r = find_executable("fsck", &fsck_path); ++ if (r < 0) { ++ log_error_errno(r, "Cannot find fsck binary: %m"); ++ _exit(FSCK_OPERATIONAL_ERROR); ++ } ++ ++ cmdline[i++] = fsck_path; + cmdline[i++] = arg_repair; + cmdline[i++] = "-T"; + +diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c +index 2ea9887853..e267457b8e 100644 +--- a/src/home/homework-luks.c ++++ b/src/home/homework-luks.c +@@ -215,6 +215,7 @@ static int block_get_size_by_path(const char *path, uint64_t *ret) { + static int run_fsck(const char *node, const char *fstype) { + int r, exit_status; + pid_t fsck_pid; ++ _cleanup_free_ char *fsck_path = NULL; + + assert(node); + assert(fstype); +@@ -227,6 +228,14 @@ static int run_fsck(const char *node, const char *fstype) { + return 0; + } + ++ r = find_executable("fsck", &fsck_path); ++ /* We proceed anyway if we can't determine whether the fsck ++ * binary for some specific fstype exists, ++ * but the lack of the main fsck binary should be considered ++ * an error. */ ++ if (r < 0) ++ return log_error_errno(r, "Cannot find fsck binary: %m"); ++ + r = safe_fork("(fsck)", + FORK_RESET_SIGNALS|FORK_RLIMIT_NOFILE_SAFE|FORK_DEATHSIG|FORK_LOG|FORK_STDOUT_TO_STDERR|FORK_CLOSE_ALL_FDS, + &fsck_pid); +@@ -234,7 +243,7 @@ static int run_fsck(const char *node, const char *fstype) { + return r; + if (r == 0) { + /* Child */ +- execl("/sbin/fsck", "/sbin/fsck", "-aTl", node, NULL); ++ execl(fsck_path, fsck_path, "-aTl", node, NULL); + log_open(); + log_error_errno(errno, "Failed to execute fsck: %m"); + _exit(FSCK_OPERATIONAL_ERROR); +diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c +index 4749bdd230..2b6e1418dd 100644 +--- a/src/shared/dissect-image.c ++++ b/src/shared/dissect-image.c +@@ -1423,6 +1423,7 @@ static int is_loop_device(const char *path) { + static int run_fsck(int node_fd, const char *fstype) { + int r, exit_status; + pid_t pid; ++ _cleanup_free_ char *fsck_path = NULL; + + assert(node_fd >= 0); + assert(fstype); +@@ -1437,6 +1438,14 @@ static int run_fsck(int node_fd, const char *fstype) { + return 0; + } + ++ r = find_executable("fsck", &fsck_path); ++ /* We proceed anyway if we can't determine whether the fsck ++ * binary for some specific fstype exists, ++ * but the lack of the main fsck binary should be considered ++ * an error. */ ++ if (r < 0) ++ return log_error_errno(r, "Cannot find fsck binary: %m"); ++ + r = safe_fork_full( + "(fsck)", + &node_fd, 1, /* Leave the node fd open */ +@@ -1446,7 +1455,7 @@ static int run_fsck(int node_fd, const char *fstype) { + return log_debug_errno(r, "Failed to fork off fsck: %m"); + if (r == 0) { + /* Child */ +- execl("/sbin/fsck", "/sbin/fsck", "-aT", FORMAT_PROC_FD_PATH(node_fd), NULL); ++ execl(fsck_path, fsck_path, "-aT", FORMAT_PROC_FD_PATH(node_fd), NULL); + log_open(); + log_debug_errno(errno, "Failed to execl() fsck: %m"); + _exit(FSCK_OPERATIONAL_ERROR); +@@ -1454,7 +1463,7 @@ static int run_fsck(int node_fd, const char *fstype) { + + exit_status = wait_for_terminate_and_check("fsck", pid, 0); + if (exit_status < 0) +- return log_debug_errno(exit_status, "Failed to fork off /sbin/fsck: %m"); ++ return log_debug_errno(exit_status, "Failed to fork off %s: %m", fsck_path); + + if ((exit_status & ~FSCK_ERROR_CORRECTED) != FSCK_SUCCESS) { + log_debug("fsck failed with exit status %i.", exit_status); diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index b475b327d62f..51a2c274c541 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -169,7 +169,7 @@ stdenv.mkDerivation (finalAttrs: { ./0001-Start-device-units-for-uninitialised-encrypted-devic.patch ./0002-Don-t-try-to-unmount-nix-or-nix-store.patch ./0003-Fix-NixOS-containers.patch - ./0004-Look-for-fsck-in-the-right-place.patch + ./0004-fsck-look-for-fsck-binary-not-just-in-sbin.patch ./0005-Add-some-NixOS-specific-unit-directories.patch ./0006-Get-rid-of-a-useless-message-in-user-sessions.patch ./0007-Fix-hwdb-paths.patch From 16ee1b18a485568a7c7164e6348f58768338ae2a Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 14 Apr 2023 21:50:05 +0200 Subject: [PATCH 3/3] systemd: re-introduce hostnamed-localed-timedated-disable-methods-that-cha.patch In NixOS, /etc is NOT read-only, and most things in /etc are symlinks to /etc/static, which is a symlink into the nix store - so the upstream systemd "/etc is read-only" detection doesn't work. Fixes #224080. --- ...d-timedated-disable-methods-that-cha.patch | 105 ++++++++++++++++++ ...-paths.patch => 0008-Fix-hwdb-paths.patch} | 0 ...-usr-share-zoneinfo-to-etc-zoneinfo.patch} | 2 +- ...alectl-use-etc-X11-xkb-for-list-x11.patch} | 0 ...e-statedir-and-don-t-touch-prefixdi.patch} | 0 ...-add-rootprefix-to-lookup-dir-paths.patch} | 0 ...execute-scripts-in-etc-systemd-syst.patch} | 0 ...cute-scripts-in-etc-systemd-system-.patch} | 0 ...placeholder-for-DEFAULT_PATH_NORMAL.patch} | 0 ...kg-config-derive-prefix-from-prefix.patch} | 0 ...environment-when-calling-generators.patch} | 0 ...18-core-don-t-taint-on-unmerged-usr.patch} | 0 ...ntext_init-fix-driver-name-checking.patch} | 0 pkgs/os-specific/linux/systemd/default.nix | 25 +++-- 14 files changed, 119 insertions(+), 13 deletions(-) create mode 100644 pkgs/os-specific/linux/systemd/0007-hostnamed-localed-timedated-disable-methods-that-cha.patch rename pkgs/os-specific/linux/systemd/{0007-Fix-hwdb-paths.patch => 0008-Fix-hwdb-paths.patch} (100%) rename pkgs/os-specific/linux/systemd/{0008-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch => 0009-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch} (99%) rename pkgs/os-specific/linux/systemd/{0009-localectl-use-etc-X11-xkb-for-list-x11.patch => 0010-localectl-use-etc-X11-xkb-for-list-x11.patch} (100%) rename pkgs/os-specific/linux/systemd/{0010-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch => 0011-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch} (100%) rename pkgs/os-specific/linux/systemd/{0011-add-rootprefix-to-lookup-dir-paths.patch => 0012-add-rootprefix-to-lookup-dir-paths.patch} (100%) rename pkgs/os-specific/linux/systemd/{0012-systemd-shutdown-execute-scripts-in-etc-systemd-syst.patch => 0013-systemd-shutdown-execute-scripts-in-etc-systemd-syst.patch} (100%) rename pkgs/os-specific/linux/systemd/{0013-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch => 0014-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch} (100%) rename pkgs/os-specific/linux/systemd/{0014-path-util.h-add-placeholder-for-DEFAULT_PATH_NORMAL.patch => 0015-path-util.h-add-placeholder-for-DEFAULT_PATH_NORMAL.patch} (100%) rename pkgs/os-specific/linux/systemd/{0015-pkg-config-derive-prefix-from-prefix.patch => 0016-pkg-config-derive-prefix-from-prefix.patch} (100%) rename pkgs/os-specific/linux/systemd/{0016-inherit-systemd-environment-when-calling-generators.patch => 0017-inherit-systemd-environment-when-calling-generators.patch} (100%) rename pkgs/os-specific/linux/systemd/{0017-core-don-t-taint-on-unmerged-usr.patch => 0018-core-don-t-taint-on-unmerged-usr.patch} (100%) rename pkgs/os-specific/linux/systemd/{0018-tpm2_context_init-fix-driver-name-checking.patch => 0019-tpm2_context_init-fix-driver-name-checking.patch} (100%) diff --git a/pkgs/os-specific/linux/systemd/0007-hostnamed-localed-timedated-disable-methods-that-cha.patch b/pkgs/os-specific/linux/systemd/0007-hostnamed-localed-timedated-disable-methods-that-cha.patch new file mode 100644 index 000000000000..2c4c3f6564e1 --- /dev/null +++ b/pkgs/os-specific/linux/systemd/0007-hostnamed-localed-timedated-disable-methods-that-cha.patch @@ -0,0 +1,105 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Gabriel Ebner +Date: Sun, 6 Dec 2015 14:26:36 +0100 +Subject: [PATCH] hostnamed, localed, timedated: disable methods that change + system settings. + +--- + src/hostname/hostnamed.c | 6 ++++++ + src/locale/localed.c | 9 +++++++++ + src/timedate/timedated.c | 10 ++++++++++ + 3 files changed, 25 insertions(+) + +diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c +index 36ab0148b9..7d458d196d 100644 +--- a/src/hostname/hostnamed.c ++++ b/src/hostname/hostnamed.c +@@ -1028,6 +1028,9 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_ + if (r < 0) + return r; + ++ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, ++ "Changing system settings via systemd is not supported on NixOS."); ++ + name = empty_to_null(name); + + context_read_etc_hostname(c); +@@ -1091,6 +1094,9 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess + if (r < 0) + return r; + ++ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, ++ "Changing system settings via systemd is not supported on NixOS."); ++ + name = empty_to_null(name); + + context_read_machine_info(c); +diff --git a/src/locale/localed.c b/src/locale/localed.c +index 841e5e3e91..a21e34430b 100644 +--- a/src/locale/localed.c ++++ b/src/locale/localed.c +@@ -264,6 +264,9 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er + + use_localegen = locale_gen_check_available(); + ++ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, ++ "Changing system settings via systemd is not supported on NixOS."); ++ + /* If single locale without variable name is provided, then we assume it is LANG=. */ + if (strv_length(l) == 1 && !strchr(l[0], '=')) { + if (!locale_is_valid(l[0])) +@@ -382,6 +385,9 @@ static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_erro + if (r < 0) + return bus_log_parse_error(r); + ++ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, ++ "Changing system settings via systemd is not supported on NixOS."); ++ + vc_context_empty_to_null(&in); + + FOREACH_STRING(name, in.keymap ?: in.toggle, in.keymap ? in.toggle : NULL) { +@@ -607,6 +613,9 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err + if (r < 0) + return bus_log_parse_error(r); + ++ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, ++ "Changing system settings via systemd is not supported on NixOS."); ++ + x11_context_empty_to_null(&in); + + if (!x11_context_is_safe(&in)) +diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c +index ad483301ef..31ed86955b 100644 +--- a/src/timedate/timedated.c ++++ b/src/timedate/timedated.c +@@ -665,6 +665,10 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error * + if (r < 0) + return r; + ++ if (getenv("NIXOS_STATIC_TIMEZONE")) ++ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, ++ "Changing timezone via systemd is not supported when it is set in NixOS configuration."); ++ + if (!timezone_is_valid(z, LOG_DEBUG)) + return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid or not installed time zone '%s'", z); + +@@ -743,6 +747,9 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error + if (r < 0) + return r; + ++ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, ++ "Changing system settings via systemd is not supported on NixOS."); ++ + if (lrtc == c->local_rtc && !fix_system) + return sd_bus_reply_method_return(m, NULL); + +@@ -923,6 +930,9 @@ static int method_set_ntp(sd_bus_message *m, void *userdata, sd_bus_error *error + if (r < 0) + return r; + ++ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, ++ "Changing system settings via systemd is not supported on NixOS."); ++ + r = context_update_ntp_status(c, bus, m); + if (r < 0) + return r; diff --git a/pkgs/os-specific/linux/systemd/0007-Fix-hwdb-paths.patch b/pkgs/os-specific/linux/systemd/0008-Fix-hwdb-paths.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0007-Fix-hwdb-paths.patch rename to pkgs/os-specific/linux/systemd/0008-Fix-hwdb-paths.patch diff --git a/pkgs/os-specific/linux/systemd/0008-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch b/pkgs/os-specific/linux/systemd/0009-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch similarity index 99% rename from pkgs/os-specific/linux/systemd/0008-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch rename to pkgs/os-specific/linux/systemd/0009-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch index ac2b036cb778..52733a4c4920 100644 --- a/pkgs/os-specific/linux/systemd/0008-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch +++ b/pkgs/os-specific/linux/systemd/0009-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch @@ -103,7 +103,7 @@ index 65d9e7e398..dd44d529ca 100644 static bool etc_writable(void) { diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c -index ad483301ef..a7f22b1c86 100644 +index 31ed86955b..8db8d8c288 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -282,7 +282,7 @@ static int context_read_data(Context *c) { diff --git a/pkgs/os-specific/linux/systemd/0009-localectl-use-etc-X11-xkb-for-list-x11.patch b/pkgs/os-specific/linux/systemd/0010-localectl-use-etc-X11-xkb-for-list-x11.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0009-localectl-use-etc-X11-xkb-for-list-x11.patch rename to pkgs/os-specific/linux/systemd/0010-localectl-use-etc-X11-xkb-for-list-x11.patch diff --git a/pkgs/os-specific/linux/systemd/0010-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch b/pkgs/os-specific/linux/systemd/0011-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0010-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch rename to pkgs/os-specific/linux/systemd/0011-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch diff --git a/pkgs/os-specific/linux/systemd/0011-add-rootprefix-to-lookup-dir-paths.patch b/pkgs/os-specific/linux/systemd/0012-add-rootprefix-to-lookup-dir-paths.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0011-add-rootprefix-to-lookup-dir-paths.patch rename to pkgs/os-specific/linux/systemd/0012-add-rootprefix-to-lookup-dir-paths.patch diff --git a/pkgs/os-specific/linux/systemd/0012-systemd-shutdown-execute-scripts-in-etc-systemd-syst.patch b/pkgs/os-specific/linux/systemd/0013-systemd-shutdown-execute-scripts-in-etc-systemd-syst.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0012-systemd-shutdown-execute-scripts-in-etc-systemd-syst.patch rename to pkgs/os-specific/linux/systemd/0013-systemd-shutdown-execute-scripts-in-etc-systemd-syst.patch diff --git a/pkgs/os-specific/linux/systemd/0013-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch b/pkgs/os-specific/linux/systemd/0014-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0013-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch rename to pkgs/os-specific/linux/systemd/0014-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch diff --git a/pkgs/os-specific/linux/systemd/0014-path-util.h-add-placeholder-for-DEFAULT_PATH_NORMAL.patch b/pkgs/os-specific/linux/systemd/0015-path-util.h-add-placeholder-for-DEFAULT_PATH_NORMAL.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0014-path-util.h-add-placeholder-for-DEFAULT_PATH_NORMAL.patch rename to pkgs/os-specific/linux/systemd/0015-path-util.h-add-placeholder-for-DEFAULT_PATH_NORMAL.patch diff --git a/pkgs/os-specific/linux/systemd/0015-pkg-config-derive-prefix-from-prefix.patch b/pkgs/os-specific/linux/systemd/0016-pkg-config-derive-prefix-from-prefix.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0015-pkg-config-derive-prefix-from-prefix.patch rename to pkgs/os-specific/linux/systemd/0016-pkg-config-derive-prefix-from-prefix.patch diff --git a/pkgs/os-specific/linux/systemd/0016-inherit-systemd-environment-when-calling-generators.patch b/pkgs/os-specific/linux/systemd/0017-inherit-systemd-environment-when-calling-generators.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0016-inherit-systemd-environment-when-calling-generators.patch rename to pkgs/os-specific/linux/systemd/0017-inherit-systemd-environment-when-calling-generators.patch diff --git a/pkgs/os-specific/linux/systemd/0017-core-don-t-taint-on-unmerged-usr.patch b/pkgs/os-specific/linux/systemd/0018-core-don-t-taint-on-unmerged-usr.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0017-core-don-t-taint-on-unmerged-usr.patch rename to pkgs/os-specific/linux/systemd/0018-core-don-t-taint-on-unmerged-usr.patch diff --git a/pkgs/os-specific/linux/systemd/0018-tpm2_context_init-fix-driver-name-checking.patch b/pkgs/os-specific/linux/systemd/0019-tpm2_context_init-fix-driver-name-checking.patch similarity index 100% rename from pkgs/os-specific/linux/systemd/0018-tpm2_context_init-fix-driver-name-checking.patch rename to pkgs/os-specific/linux/systemd/0019-tpm2_context_init-fix-driver-name-checking.patch diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index 51a2c274c541..90c02d4491b7 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -172,18 +172,19 @@ stdenv.mkDerivation (finalAttrs: { ./0004-fsck-look-for-fsck-binary-not-just-in-sbin.patch ./0005-Add-some-NixOS-specific-unit-directories.patch ./0006-Get-rid-of-a-useless-message-in-user-sessions.patch - ./0007-Fix-hwdb-paths.patch - ./0008-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch - ./0009-localectl-use-etc-X11-xkb-for-list-x11.patch - ./0010-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch - ./0011-add-rootprefix-to-lookup-dir-paths.patch - ./0012-systemd-shutdown-execute-scripts-in-etc-systemd-syst.patch - ./0013-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch - ./0014-path-util.h-add-placeholder-for-DEFAULT_PATH_NORMAL.patch - ./0015-pkg-config-derive-prefix-from-prefix.patch - ./0016-inherit-systemd-environment-when-calling-generators.patch - ./0017-core-don-t-taint-on-unmerged-usr.patch - ./0018-tpm2_context_init-fix-driver-name-checking.patch + ./0007-hostnamed-localed-timedated-disable-methods-that-cha.patch + ./0008-Fix-hwdb-paths.patch + ./0009-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch + ./0010-localectl-use-etc-X11-xkb-for-list-x11.patch + ./0011-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch + ./0012-add-rootprefix-to-lookup-dir-paths.patch + ./0013-systemd-shutdown-execute-scripts-in-etc-systemd-syst.patch + ./0014-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch + ./0015-path-util.h-add-placeholder-for-DEFAULT_PATH_NORMAL.patch + ./0016-pkg-config-derive-prefix-from-prefix.patch + ./0017-inherit-systemd-environment-when-calling-generators.patch + ./0018-core-don-t-taint-on-unmerged-usr.patch + ./0019-tpm2_context_init-fix-driver-name-checking.patch ] ++ lib.optional stdenv.hostPlatform.isMusl ( let oe-core = fetchzip {