From 5509c00d0f38520c663e079fc495e3a667938023 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Jun 23 2014 04:33:25 +0000 Subject: Add some patches --- diff --git a/0001-NEWS-add-missing-comment-about-the-floppy-group.patch b/0001-NEWS-add-missing-comment-about-the-floppy-group.patch new file mode 100644 index 0000000..3eac580 --- /dev/null +++ b/0001-NEWS-add-missing-comment-about-the-floppy-group.patch @@ -0,0 +1,26 @@ +From ac0013190eb64a6528b56a09c29ba595f6ac19e4 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 11 Jun 2014 18:42:38 +0200 +Subject: [PATCH] NEWS: add missing comment about the "floppy" group + +(cherry picked from commit 4c0d13bdd5ef971a3003899064af1717c8960bee) +--- + NEWS | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/NEWS b/NEWS +index 54d9e9e6..1274c30a 100644 +--- a/NEWS ++++ b/NEWS +@@ -179,6 +179,11 @@ CHANGES WITH 214: + added which is useful for services that shall run before any + network is configured, for example firewall scripts. + ++ * The "floppy" group that previously owned the /dev/fd* ++ devices is no longer used. The "disk" group is now used ++ instead. Distributions should probably deprecate usage of ++ this group. ++ + Contributions from: Camilo Aguilar, Christian Hesse, Colin Ian + King, Cristian Rodríguez, Daniel Buch, Dave Reisner, David + Strauss, Denis Tikhomirov, John, Jonathan Liu, Kay Sievers, diff --git a/0002-NEWS-fix-directory-name.patch b/0002-NEWS-fix-directory-name.patch new file mode 100644 index 0000000..61a0ec8 --- /dev/null +++ b/0002-NEWS-fix-directory-name.patch @@ -0,0 +1,23 @@ +From 4bf7b81ac71311d2cd44b8a14d133f613a04a030 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mantas=20Mikul=C4=97nas?= +Date: Wed, 11 Jun 2014 17:09:11 +0300 +Subject: [PATCH] NEWS: fix directory name + +(cherry picked from commit c54bed5d515771c21250b8e0c052cb6600e21d37) +--- + NEWS | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/NEWS b/NEWS +index 1274c30a..4f3c5222 100644 +--- a/NEWS ++++ b/NEWS +@@ -52,7 +52,7 @@ CHANGES WITH 214: + transports. Instead it is assumed the kernel loads them + automatically when required. This only works correctly on + very new kernels. On older kernels, please consider adding +- the kernel modules to /etc/load-modules.d/ as a work-around. ++ the kernel modules to /etc/modules-load.d/ as a work-around. + + * The resolv.conf file systemd-resolved generates has been + moved to /run/systemd/resolve/, if you have a symlink from diff --git a/0003-udev-assign-group-input-to-all-input-devices.patch b/0003-udev-assign-group-input-to-all-input-devices.patch new file mode 100644 index 0000000..97ac09c --- /dev/null +++ b/0003-udev-assign-group-input-to-all-input-devices.patch @@ -0,0 +1,53 @@ +From 8f8fb5044e90f60e065c5bbceba21aab2986edd5 Mon Sep 17 00:00:00 2001 +From: Kay Sievers +Date: Thu, 12 Jun 2014 14:59:53 +0200 +Subject: [PATCH] udev: assign group "input" to all input devices + +(cherry picked from commit 3dff3e00e044e2d53c76fa842b9a4759d4a50e69) +--- + NEWS | 6 ++++++ + README | 2 +- + rules/50-udev-default.rules | 1 + + 3 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/NEWS b/NEWS +index 4f3c5222..318f3d49 100644 +--- a/NEWS ++++ b/NEWS +@@ -1,5 +1,11 @@ + systemd System and Service Manager + ++CHANGES WITH 215: ++ * A new system group "input" is introduced, all input ++ device nodes get this group assigned. This is useful for ++ system-level software to get access to input devices. It ++ complements what is already done for "audio" and "video". ++ + CHANGES WITH 214: + + * As an experimental feature, udev now tries to lock the +diff --git a/README b/README +index 529c6e19..de159feb 100644 +--- a/README ++++ b/README +@@ -168,7 +168,7 @@ USERS AND GROUPS: + even in the very early boot stages, where no other databases + and network are available: + +- tty, dialout, kmem, video, audio, lp, cdrom, tape, disk ++ audio, cdrom, dialout, disk, input, kmem, lp, tape, tty, video + + During runtime, the journal daemon requires the + "systemd-journal" system group to exist. New journal files will +diff --git a/rules/50-udev-default.rules b/rules/50-udev-default.rules +index 122d07c9..1ecd47a2 100644 +--- a/rules/50-udev-default.rules ++++ b/rules/50-udev-default.rules +@@ -23,6 +23,7 @@ KERNEL=="tty[A-Z]*[0-9]|pppox[0-9]*|ircomm[0-9]*|noz[0-9]*|rfcomm[0-9]*", GROUP= + + SUBSYSTEM=="mem", KERNEL=="mem|kmem|port", GROUP="kmem", MODE="0640" + ++SUBSYSTEM=="input", GROUP="input" + SUBSYSTEM=="input", KERNEL=="js[0-9]*", MODE="0664" + + SUBSYSTEM=="video4linux", GROUP="video" diff --git a/0004-cryptsetup-check-that-password-is-not-null.patch b/0004-cryptsetup-check-that-password-is-not-null.patch new file mode 100644 index 0000000..32cf554 --- /dev/null +++ b/0004-cryptsetup-check-that-password-is-not-null.patch @@ -0,0 +1,27 @@ +From 89053aff0cc36dfcee6fda6e83b13f6f68c05a82 Mon Sep 17 00:00:00 2001 +From: Thomas Hindoe Paaboel Andersen +Date: Thu, 12 Jun 2014 22:50:04 +0200 +Subject: [PATCH] cryptsetup: check that password is not null + +Beef up the assert to protect against passing null to strlen. + +Found with scan-build. + +(cherry picked from commit f268f57f6344d3a2ccf447352ff3ed1313c4a199) +--- + src/cryptsetup/cryptsetup.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c +index 812b32f6..a67d85e6 100644 +--- a/src/cryptsetup/cryptsetup.c ++++ b/src/cryptsetup/cryptsetup.c +@@ -344,7 +344,7 @@ static int attach_tcrypt(struct crypt_device *cd, + + assert(cd); + assert(name); +- assert(key_file || passwords); ++ assert(key_file || (passwords && passwords[0])); + + if (arg_tcrypt_hidden) + params.flags |= CRYPT_TCRYPT_HIDDEN_HEADER; diff --git a/0005-core-fix-invalid-free-in-killall.patch b/0005-core-fix-invalid-free-in-killall.patch new file mode 100644 index 0000000..5e060c6 --- /dev/null +++ b/0005-core-fix-invalid-free-in-killall.patch @@ -0,0 +1,31 @@ +From 3f4dbb254a7ca90dd025a5de24f0fbaf53a9342e Mon Sep 17 00:00:00 2001 +From: Andreas Henriksson +Date: Fri, 13 Jun 2014 18:48:19 +0200 +Subject: [PATCH] core: fix invalid free() in killall() + +static int killall(....) in ./src/core/killall.c tries to get "s" +initialized by calling get_process_comm(...) which calls +read_one_line_file(...) which if it fails will mean it is left +uninitialized. +It is then used in argument to strna(s) call where it is +dereferenced(!), in addition to nothing else initializing it before +the scope it is in finishes. + +(cherry picked from commit 3e09eb5c83e56bc0184bd9d9c44f76047464f77c) +--- + src/core/killall.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/core/killall.c b/src/core/killall.c +index 57ed41c5..eab48f7d 100644 +--- a/src/core/killall.c ++++ b/src/core/killall.c +@@ -168,7 +168,7 @@ static int killall(int sig, Set *pids, bool send_sighup) { + continue; + + if (sig == SIGKILL) { +- _cleanup_free_ char *s; ++ _cleanup_free_ char *s = NULL; + + get_process_comm(pid, &s); + log_notice("Sending SIGKILL to PID "PID_FMT" (%s).", pid, strna(s)); diff --git a/0006-udev-fix-invalid-free-in-enable_name_policy.patch b/0006-udev-fix-invalid-free-in-enable_name_policy.patch new file mode 100644 index 0000000..6a29cec --- /dev/null +++ b/0006-udev-fix-invalid-free-in-enable_name_policy.patch @@ -0,0 +1,29 @@ +From e6e0462204a04517c6f31b7ca631d715c6ab04f8 Mon Sep 17 00:00:00 2001 +From: Andreas Henriksson +Date: Fri, 13 Jun 2014 18:48:21 +0200 +Subject: [PATCH] udev: fix invalid free() in enable_name_policy() + +static bool enable_name_policy(...) in ./src/udev/net/link-config.c +calls proc_cmdline(...) to get "line" initialized, but +proc_cmdline(...) does not guarantee that atleast when both +conditions (detect_container(NULL) > 0) and +read_full_file(...) returned < 0. + +(cherry picked from commit f8a0bb5285024b6ce372c3157e761e6543ebdcd2) +--- + src/udev/net/link-config.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c +index a9acc3dd..7a9d01bc 100644 +--- a/src/udev/net/link-config.c ++++ b/src/udev/net/link-config.c +@@ -185,7 +185,7 @@ static int load_link(link_config_ctx *ctx, const char *filename) { + } + + static bool enable_name_policy(void) { +- _cleanup_free_ char *line; ++ _cleanup_free_ char *line = NULL; + char *w, *state; + int r; + size_t l; diff --git a/0007-install-fix-invalid-free-in-unit_file_mask.patch b/0007-install-fix-invalid-free-in-unit_file_mask.patch new file mode 100644 index 0000000..e3b05ca --- /dev/null +++ b/0007-install-fix-invalid-free-in-unit_file_mask.patch @@ -0,0 +1,29 @@ +From 09220715e259bf23cbe33d497ed92259a9670320 Mon Sep 17 00:00:00 2001 +From: Andreas Henriksson +Date: Fri, 13 Jun 2014 18:48:18 +0200 +Subject: [PATCH] install: fix invalid free() in unit_file_mask() + +int unit_file_mask(...) in ./src/shared/install.c calls +get_config_path(...) which can in 4 error cases return without setting +"ret", and thus "prefix" can be uninitialized when unit_file_mask(...) +finishes (which it does directly after the error is returned from +get_config_path(...)). + +(cherry picked from commit 223217749e57996336d5730b0a28716cca56d45d) +--- + src/shared/install.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/shared/install.c b/src/shared/install.c +index 487d0f66..f5620633 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -563,7 +563,7 @@ int unit_file_mask( + unsigned *n_changes) { + + char **i; +- _cleanup_free_ char *prefix; ++ _cleanup_free_ char *prefix = NULL; + int r; + + assert(scope >= 0); diff --git a/0008-rpm-don-t-hardcode-the-binary-paths-in-the-macros-re.patch b/0008-rpm-don-t-hardcode-the-binary-paths-in-the-macros-re.patch new file mode 100644 index 0000000..5cca566 --- /dev/null +++ b/0008-rpm-don-t-hardcode-the-binary-paths-in-the-macros-re.patch @@ -0,0 +1,72 @@ +From 3c96e9e0757281a04bb066c67fc5f509871e27b0 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 13 Jun 2014 19:05:22 +0200 +Subject: [PATCH] rpm: don't hardcode the binary paths in the macros, rely on + $PATH + +this gives us a little bit more freedom to move things around later on, +as we don't hardcode the systemd paths in old RPMs that shall work with +new systemds. + +(cherry picked from commit 8cf7c96517c3688d29b30651adcda9e71e7fcb07) +--- + src/core/macros.systemd.in | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +diff --git a/src/core/macros.systemd.in b/src/core/macros.systemd.in +index 89b48259..167016a8 100644 +--- a/src/core/macros.systemd.in ++++ b/src/core/macros.systemd.in +@@ -37,42 +37,42 @@ Requires(postun): systemd \ + %systemd_post() \ + if [ $1 -eq 1 ] ; then \ + # Initial installation \ +- @rootbindir@/systemctl preset %{?*} >/dev/null 2>&1 || : \ ++ systemctl preset %{?*} >/dev/null 2>&1 || : \ + fi \ + %{nil} + + %systemd_preun() \ + if [ $1 -eq 0 ] ; then \ + # Package removal, not upgrade \ +- @rootbindir@/systemctl --no-reload disable %{?*} > /dev/null 2>&1 || : \ +- @rootbindir@/systemctl stop %{?*} > /dev/null 2>&1 || : \ ++ systemctl --no-reload disable %{?*} > /dev/null 2>&1 || : \ ++ systemctl stop %{?*} > /dev/null 2>&1 || : \ + fi \ + %{nil} + + %systemd_postun() \ +-@rootbindir@/systemctl daemon-reload >/dev/null 2>&1 || : \ ++systemctl daemon-reload >/dev/null 2>&1 || : \ + %{nil} + + %systemd_postun_with_restart() \ +-@rootbindir@/systemctl daemon-reload >/dev/null 2>&1 || : \ ++systemctl daemon-reload >/dev/null 2>&1 || : \ + if [ $1 -ge 1 ] ; then \ + # Package upgrade, not uninstall \ +- @rootbindir@/systemctl try-restart %{?*} >/dev/null 2>&1 || : \ ++ systemctl try-restart %{?*} >/dev/null 2>&1 || : \ + fi \ + %{nil} + + %udev_hwdb_update() \ +-@rootbindir@/udevadm hwdb --update >/dev/null 2>&1 || : \ ++udevadm hwdb --update >/dev/null 2>&1 || : \ + %{nil} + + %udev_rules_update() \ +-@rootbindir@/udevadm control --reload >/dev/null 2>&1 || : \ ++udevadm control --reload >/dev/null 2>&1 || : \ + %{nil} + + %journal_catalog_update() \ +-@rootbindir@/journalctl --update-catalog >/dev/null 2>&1 || : \ ++journalctl --update-catalog >/dev/null 2>&1 || : \ + %{nil} + + %tmpfiles_create() \ +-@rootbindir@/systemd-tmpfiles --create %{?*} >/dev/null 2>&1 || : \ ++systemd-tmpfiles --create %{?*} >/dev/null 2>&1 || : \ + %{nil} diff --git a/0009-Fix-spelling-mistake-scirpt-script.patch b/0009-Fix-spelling-mistake-scirpt-script.patch new file mode 100644 index 0000000..30c5429 --- /dev/null +++ b/0009-Fix-spelling-mistake-scirpt-script.patch @@ -0,0 +1,23 @@ +From 0da84688a4228368b2039a08337818dd431221ff Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 12 Jun 2014 16:41:41 +0100 +Subject: [PATCH] Fix spelling mistake, scirpt --> script + +(cherry picked from commit 855d111304114e922b34b6c4bc2a0b08766c2668) +--- + src/sysv-generator/sysv-generator.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c +index 0b8d8f73..18dae5c2 100644 +--- a/src/sysv-generator/sysv-generator.c ++++ b/src/sysv-generator/sysv-generator.c +@@ -791,7 +791,7 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) { + if (hashmap_contains(all_services, name)) + service = hashmap_get(all_services, name); + else { +- log_warning("Could not find init scirpt for %s", name); ++ log_warning("Could not find init script for %s", name); + continue; + } + diff --git a/0010-tmpfiles-set-up-selinux-label-proeprly-when-creating.patch b/0010-tmpfiles-set-up-selinux-label-proeprly-when-creating.patch new file mode 100644 index 0000000..c2f7445 --- /dev/null +++ b/0010-tmpfiles-set-up-selinux-label-proeprly-when-creating.patch @@ -0,0 +1,29 @@ +From 5aef99701f6e9504750adf906160ce23cb9851e4 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 16 Jun 2014 13:20:38 +0200 +Subject: [PATCH] tmpfiles: set up selinux label proeprly when creating fifos + +(cherry picked from commit 45c196a76b2d883552c90807386d9bed40da822b) + +Conflicts: + src/shared/util.c +--- + src/tmpfiles/tmpfiles.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c +index bb12dd0b..3e817cca 100644 +--- a/src/tmpfiles/tmpfiles.c ++++ b/src/tmpfiles/tmpfiles.c +@@ -719,9 +719,11 @@ static int create_item(Item *i) { + + case CREATE_FIFO: + ++ label_context_set(i->path, S_IFIFO); + RUN_WITH_UMASK(0000) { + r = mkfifo(i->path, i->mode); + } ++ label_context_clear(); + + if (r < 0 && errno != EEXIST) { + log_error("Failed to create fifo %s: %m", i->path); diff --git a/0011-Reset-signal-mask-on-re-exec-to-init.patch b/0011-Reset-signal-mask-on-re-exec-to-init.patch new file mode 100644 index 0000000..dd76c65 --- /dev/null +++ b/0011-Reset-signal-mask-on-re-exec-to-init.patch @@ -0,0 +1,50 @@ +From ab25a485218194a432a8238b772005f4506059f3 Mon Sep 17 00:00:00 2001 +From: Ruediger Oertel +Date: Fri, 13 Jun 2014 16:41:06 +0200 +Subject: [PATCH] Reset signal-mask on re-exec to init=.. + +Process 1 (aka init) needs to be started with an empty signal mask. +That includes the process 1 that's started after the initrd is finished. +When the initrd is using systemd (as it does with dracut based initrds) +then it is systemd that calls the real init. Normally this is systemd +again, except when the user uses for instance "init=/bin/bash" on the +kernel command line. + +(cherry picked from commit 5a85ca1cb622fda4a39c8a6f00dccea7f8a1e82a) +--- + src/core/main.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/core/main.c b/src/core/main.c +index d5d1ee2b..e87b8cc8 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -1831,6 +1831,7 @@ finish: + if (reexecute) { + const char **args; + unsigned i, args_size; ++ sigset_t ss, o_ss; + + /* Close and disarm the watchdog, so that the new + * instance can reinitialize it, but doesn't get +@@ -1914,6 +1915,11 @@ finish: + args[i++] = NULL; + assert(i <= args_size); + ++ /* reenable any blocked signals, especially important ++ * if we switch from initial ramdisk to init=... */ ++ sigemptyset(&ss); ++ sigprocmask(SIG_SETMASK, &ss, &o_ss); ++ + if (switch_root_init) { + args[0] = switch_root_init; + execv(args[0], (char* const*) args); +@@ -1932,6 +1938,8 @@ finish: + log_error("Failed to execute /bin/sh, giving up: %m"); + } else + log_warning("Failed to execute /sbin/init, giving up: %m"); ++ ++ sigprocmask(SIG_SETMASK, &o_ss, NULL); + } + + if (arg_serialization) { diff --git a/0012-core-clean-up-signal-reset-logic-when-reexec.patch b/0012-core-clean-up-signal-reset-logic-when-reexec.patch new file mode 100644 index 0000000..5b45618 --- /dev/null +++ b/0012-core-clean-up-signal-reset-logic-when-reexec.patch @@ -0,0 +1,49 @@ +From 1d4d5cd68c250af3b232fa049bd2cde171272ee9 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 20 Jun 2014 16:58:21 +0200 +Subject: [PATCH] core: clean-up signal reset logic when reexec + +There's no need to save the old sigmask, if we are going to die. Let's +simplify this. Also, reset all the signal handlers, so that we don't +leave SIG_IGN set for some of them across reexec. + +(cherry picked from commit 9bfcda9528636914aef3e0ab91191bb81654c83d) +--- + src/core/main.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/core/main.c b/src/core/main.c +index e87b8cc8..c9472929 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -1831,7 +1831,7 @@ finish: + if (reexecute) { + const char **args; + unsigned i, args_size; +- sigset_t ss, o_ss; ++ sigset_t ss; + + /* Close and disarm the watchdog, so that the new + * instance can reinitialize it, but doesn't get +@@ -1917,8 +1917,10 @@ finish: + + /* reenable any blocked signals, especially important + * if we switch from initial ramdisk to init=... */ +- sigemptyset(&ss); +- sigprocmask(SIG_SETMASK, &ss, &o_ss); ++ reset_all_signal_handlers(); ++ ++ assert_se(sigemptyset(&ss) == 0); ++ assert_se(sigprocmask(SIG_SETMASK, &ss, NULL) == 0); + + if (switch_root_init) { + args[0] = switch_root_init; +@@ -1938,8 +1940,6 @@ finish: + log_error("Failed to execute /bin/sh, giving up: %m"); + } else + log_warning("Failed to execute /sbin/init, giving up: %m"); +- +- sigprocmask(SIG_SETMASK, &o_ss, NULL); + } + + if (arg_serialization) { diff --git a/0013-journal-remote-fix-memleak.patch b/0013-journal-remote-fix-memleak.patch new file mode 100644 index 0000000..aa323f2 --- /dev/null +++ b/0013-journal-remote-fix-memleak.patch @@ -0,0 +1,37 @@ +From 84d1cd0b9bea96ba9ef600582b1ab030f49c5046 Mon Sep 17 00:00:00 2001 +From: Thomas Hindoe Paaboel Andersen +Date: Mon, 16 Jun 2014 23:49:10 +0200 +Subject: [PATCH] journal-remote: fix memleak + +(cherry picked from commit e94b5a7bc201fe73c4a291169c5c1d21cceee128) +--- + src/journal/journal-remote.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/journal/journal-remote.c b/src/journal/journal-remote.c +index 915f234a..31401fb3 100644 +--- a/src/journal/journal-remote.c ++++ b/src/journal/journal-remote.c +@@ -291,7 +291,7 @@ static int remove_source(RemoteServer *s, int fd) { + + static int add_source(RemoteServer *s, int fd, const char* name) { + RemoteSource *source = NULL; +- char *realname; ++ _cleanup_free_ char *realname = NULL; + int r; + + assert(s); +@@ -307,11 +307,11 @@ static int add_source(RemoteServer *s, int fd, const char* name) { + return log_oom(); + } + +- log_debug("Creating source for fd:%d (%s)", fd, name); ++ log_debug("Creating source for fd:%d (%s)", fd, realname); + + r = get_source_for_fd(s, fd, &source); + if (r < 0) { +- log_error("Failed to create source for fd:%d (%s)", fd, name); ++ log_error("Failed to create source for fd:%d (%s)", fd, realname); + return r; + } + assert(source); diff --git a/0014-unit-name-fix-detection-of-unit-templates-instances.patch b/0014-unit-name-fix-detection-of-unit-templates-instances.patch new file mode 100644 index 0000000..2572763 --- /dev/null +++ b/0014-unit-name-fix-detection-of-unit-templates-instances.patch @@ -0,0 +1,57 @@ +From 3e59dbfced8ba0e6258ee5ed6c6a3d895b0fd2b5 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 16 Jun 2014 17:01:26 +0200 +Subject: [PATCH] unit-name: fix detection of unit templates/instances + +We need to check for the last dot, not the first one in a unit name, for +the suffix. Correct that. + +(cherry picked from commit 6ef9eeed61a291cc42b7d911f5cf5a4deca742a3) +--- + src/shared/unit-name.c | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c +index 6c167b43..d0e71f24 100644 +--- a/src/shared/unit-name.c ++++ b/src/shared/unit-name.c +@@ -332,7 +332,7 @@ char *unit_name_path_unescape(const char *f) { + } + + bool unit_name_is_template(const char *n) { +- const char *p; ++ const char *p, *e; + + assert(n); + +@@ -340,11 +340,15 @@ bool unit_name_is_template(const char *n) { + if (!p) + return false; + +- return p[1] == '.'; ++ e = strrchr(p+1, '.'); ++ if (!e) ++ return false; ++ ++ return e == p + 1; + } + + bool unit_name_is_instance(const char *n) { +- const char *p; ++ const char *p, *e; + + assert(n); + +@@ -352,7 +356,11 @@ bool unit_name_is_instance(const char *n) { + if (!p) + return false; + +- return p[1] != '.'; ++ e = strrchr(p+1, '.'); ++ if (!e) ++ return false; ++ ++ return e > p + 1; + } + + char *unit_name_replace_instance(const char *f, const char *i) { diff --git a/0015-install-various-modernizations.patch b/0015-install-various-modernizations.patch new file mode 100644 index 0000000..bacb14d --- /dev/null +++ b/0015-install-various-modernizations.patch @@ -0,0 +1,122 @@ +From 06cd279be2d9597ac7e19d19ac2883874d801bc7 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 16 Jun 2014 17:19:30 +0200 +Subject: [PATCH] install: various modernizations + +(cherry picked from commit da39f6a63e9ca59bec23cc9d1cb841703bb5ef56) +--- + src/shared/install.c | 43 ++++++++++++++----------------------------- + 1 file changed, 14 insertions(+), 29 deletions(-) + +diff --git a/src/shared/install.c b/src/shared/install.c +index f5620633..115d831d 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -319,7 +319,8 @@ static int remove_marked_symlinks( + unsigned *n_changes, + char** files) { + +- int fd, r = 0; ++ _cleanup_close_ int fd = -1; ++ int r = 0; + bool deleted; + + assert(config_path); +@@ -347,8 +348,6 @@ static int remove_marked_symlinks( + r = q; + } while (deleted); + +- safe_close(fd); +- + return r; + } + +@@ -1830,11 +1829,11 @@ int unit_file_preset( + UnitFileChange **changes, + unsigned *n_changes) { + +- _cleanup_lookup_paths_free_ LookupPaths paths = {}; + _cleanup_install_context_done_ InstallContext plus = {}, minus = {}; +- char **i; +- _cleanup_free_ char *config_path = NULL; + _cleanup_set_free_free_ Set *remove_symlinks_to = NULL; ++ _cleanup_lookup_paths_free_ LookupPaths paths = {}; ++ _cleanup_free_ char *config_path = NULL; ++ char **i; + int r, q; + + assert(scope >= 0); +@@ -1861,16 +1860,13 @@ int unit_file_preset( + r = install_info_add_auto(&plus, *i); + else + r = install_info_add_auto(&minus, *i); +- + if (r < 0) + return r; + } + +- r = install_context_mark_for_removal(&minus, &paths, &remove_symlinks_to, +- config_path, root_dir); ++ r = install_context_mark_for_removal(&minus, &paths, &remove_symlinks_to, config_path, root_dir); + +- q = remove_marked_symlinks(remove_symlinks_to, config_path, +- changes, n_changes, files); ++ q = remove_marked_symlinks(remove_symlinks_to, config_path, changes, n_changes, files); + if (r == 0) + r = q; + +@@ -1899,8 +1895,6 @@ int unit_file_get_list( + + _cleanup_lookup_paths_free_ LookupPaths paths = {}; + char **i; +- _cleanup_free_ char *buf = NULL; +- _cleanup_closedir_ DIR *d = NULL; + int r; + + assert(scope >= 0); +@@ -1915,22 +1909,19 @@ int unit_file_get_list( + return r; + + STRV_FOREACH(i, paths.unit_path) { ++ _cleanup_closedir_ DIR *d = NULL; ++ _cleanup_free_ char *buf = NULL; + const char *units_dir; + +- free(buf); +- buf = NULL; +- +- if (root_dir) { +- if (asprintf(&buf, "%s/%s", root_dir, *i) < 0) ++ if (!isempty(root_dir)) { ++ buf = strjoin(root_dir, "/", *i, NULL); ++ if (!buf) + return -ENOMEM; + + units_dir = buf; + } else + units_dir = *i; + +- if (d) +- closedir(d); +- + d = opendir(units_dir); + if (!d) { + if (errno == ENOENT) +@@ -1960,15 +1951,9 @@ int unit_file_get_list( + if (hashmap_get(h, de->d_name)) + continue; + +- r = dirent_ensure_type(d, de); +- if (r < 0) { +- if (r == -ENOENT) +- continue; +- +- return r; +- } ++ dirent_ensure_type(d, de); + +- if (de->d_type != DT_LNK && de->d_type != DT_REG) ++ if (!IN_SET(de->d_type, DT_LNK, DT_REG)) + continue; + + f = new0(UnitFileList, 1); diff --git a/0016-install-simplify-and-clarify-disabling-logic-for-ins.patch b/0016-install-simplify-and-clarify-disabling-logic-for-ins.patch new file mode 100644 index 0000000..3d19da7 --- /dev/null +++ b/0016-install-simplify-and-clarify-disabling-logic-for-ins.patch @@ -0,0 +1,118 @@ +From bf160761cd5d35458779e96fa13655dd88350ccd Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 16 Jun 2014 19:48:31 +0200 +Subject: [PATCH] install: simplify and clarify disabling logic for instanced + units + +(cherry picked from commit bcafe923a74e702abbba3655b0270febe143499f) +--- + src/shared/install.c | 50 ++++++++++++++++++++++++++++---------------------- + 1 file changed, 28 insertions(+), 22 deletions(-) + +diff --git a/src/shared/install.c b/src/shared/install.c +index 115d831d..40dc7beb 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -194,10 +194,10 @@ static int remove_marked_symlinks_fd( + bool *deleted, + UnitFileChange **changes, + unsigned *n_changes, +- char** files) { ++ char** instance_whitelist) { + +- int r = 0; + _cleanup_closedir_ DIR *d = NULL; ++ int r = 0; + + assert(remove_symlinks_to); + assert(fd >= 0); +@@ -252,9 +252,8 @@ static int remove_marked_symlinks_fd( + } + + /* This will close nfd, regardless whether it succeeds or not */ +- q = remove_marked_symlinks_fd(remove_symlinks_to, nfd, p, config_path, deleted, changes, n_changes, files); +- +- if (r == 0) ++ q = remove_marked_symlinks_fd(remove_symlinks_to, nfd, p, config_path, deleted, changes, n_changes, instance_whitelist); ++ if (q < 0 && r == 0) + r = q; + + } else if (de->d_type == DT_LNK) { +@@ -262,6 +261,14 @@ static int remove_marked_symlinks_fd( + int q; + bool found; + ++ if (!unit_name_is_valid(de->d_name, TEMPLATE_VALID)) ++ continue; ++ ++ if (unit_name_is_instance(de->d_name) && ++ instance_whitelist && ++ !strv_contains(instance_whitelist, de->d_name)) ++ continue; ++ + p = path_make_absolute(de->d_name, path); + if (!p) + return -ENOMEM; +@@ -280,30 +287,29 @@ static int remove_marked_symlinks_fd( + set_get(remove_symlinks_to, dest) || + set_get(remove_symlinks_to, basename(dest)); + +- if (unit_name_is_instance(p)) +- found = found && strv_contains(files, basename(p)); +- + if (found) { + + if (unlink(p) < 0 && errno != ENOENT) { + + if (r == 0) + r = -errno; +- } else { +- rmdir_parents(p, config_path); +- path_kill_slashes(p); ++ continue; ++ } ++ ++ rmdir_parents(p, config_path); ++ ++ path_kill_slashes(p); + +- add_file_change(changes, n_changes, UNIT_FILE_UNLINK, p, NULL); ++ add_file_change(changes, n_changes, UNIT_FILE_UNLINK, p, NULL); + +- if (!set_get(remove_symlinks_to, p)) { ++ if (!set_get(remove_symlinks_to, p)) { + +- q = mark_symlink_for_removal(&remove_symlinks_to, p); +- if (q < 0) { +- if (r == 0) +- r = q; +- } else +- *deleted = true; +- } ++ q = mark_symlink_for_removal(&remove_symlinks_to, p); ++ if (q < 0) { ++ if (r == 0) ++ r = q; ++ } else ++ *deleted = true; + } + } + } +@@ -317,7 +323,7 @@ static int remove_marked_symlinks( + const char *config_path, + UnitFileChange **changes, + unsigned *n_changes, +- char** files) { ++ char** instance_whitelist) { + + _cleanup_close_ int fd = -1; + int r = 0; +@@ -343,7 +349,7 @@ static int remove_marked_symlinks( + } + + /* This takes possession of cfd and closes it */ +- q = remove_marked_symlinks_fd(remove_symlinks_to, cfd, config_path, config_path, &deleted, changes, n_changes, files); ++ q = remove_marked_symlinks_fd(remove_symlinks_to, cfd, config_path, config_path, &deleted, changes, n_changes, instance_whitelist); + if (r == 0) + r = q; + } while (deleted); diff --git a/0017-install-various-modernizations.patch b/0017-install-various-modernizations.patch new file mode 100644 index 0000000..66befbb --- /dev/null +++ b/0017-install-various-modernizations.patch @@ -0,0 +1,115 @@ +From f906059875069ef0b72e54581d78fe4e28b375a3 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jun 2014 00:10:54 +0200 +Subject: [PATCH] install: various modernizations + +(cherry picked from commit 1dacfd2ad643019f41fb979f5a8c144172911f85) +--- + src/shared/install.c | 47 ++++++++++++++++++++++------------------------- + 1 file changed, 22 insertions(+), 25 deletions(-) + +diff --git a/src/shared/install.c b/src/shared/install.c +index 40dc7beb..0f49f2a9 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -287,30 +287,31 @@ static int remove_marked_symlinks_fd( + set_get(remove_symlinks_to, dest) || + set_get(remove_symlinks_to, basename(dest)); + +- if (found) { ++ if (!found) ++ continue; + +- if (unlink(p) < 0 && errno != ENOENT) { + +- if (r == 0) +- r = -errno; +- continue; +- } ++ if (unlink(p) < 0 && errno != ENOENT) { ++ ++ if (r == 0) ++ r = -errno; ++ continue; ++ } + +- rmdir_parents(p, config_path); ++ rmdir_parents(p, config_path); + +- path_kill_slashes(p); ++ path_kill_slashes(p); + +- add_file_change(changes, n_changes, UNIT_FILE_UNLINK, p, NULL); ++ add_file_change(changes, n_changes, UNIT_FILE_UNLINK, p, NULL); + +- if (!set_get(remove_symlinks_to, p)) { ++ if (!set_get(remove_symlinks_to, p)) { + +- q = mark_symlink_for_removal(&remove_symlinks_to, p); +- if (q < 0) { +- if (r == 0) +- r = q; +- } else +- *deleted = true; +- } ++ q = mark_symlink_for_removal(&remove_symlinks_to, p); ++ if (q < 0) { ++ if (r == 0) ++ r = q; ++ } else ++ *deleted = true; + } + } + } +@@ -417,10 +418,8 @@ static int find_symlinks_fd( + + /* This will close nfd, regardless whether it succeeds or not */ + q = find_symlinks_fd(name, nfd, p, config_path, same_name_link); +- + if (q > 0) + return 1; +- + if (r == 0) + r = q; + +@@ -595,7 +594,6 @@ int unit_file_mask( + + if (symlink("/dev/null", path) >= 0) { + add_file_change(changes, n_changes, UNIT_FILE_SYMLINK, path, "/dev/null"); +- + continue; + } + +@@ -762,7 +760,6 @@ int unit_file_link( + _cleanup_free_ char *dest = NULL; + + q = readlink_and_make_absolute(path, &dest); +- + if (q < 0 && errno != ENOENT) { + if (r == 0) + r = q; +@@ -1302,8 +1299,8 @@ static int install_info_symlink_link( + UnitFileChange **changes, + unsigned *n_changes) { + +- int r; + _cleanup_free_ char *path = NULL; ++ int r; + + assert(i); + assert(paths); +@@ -1314,11 +1311,11 @@ static int install_info_symlink_link( + if (r != 0) + return r; + +- if (asprintf(&path, "%s/%s", config_path, i->name) < 0) ++ path = strjoin(config_path, "/", i->name, NULL); ++ if (!path) + return -ENOMEM; + +- r = create_symlink(i->path, path, force, changes, n_changes); +- return r; ++ return create_symlink(i->path, path, force, changes, n_changes); + } + + static int install_info_apply( diff --git a/0018-install-use-symlink_atomic-instead-of-unlink-symlink.patch b/0018-install-use-symlink_atomic-instead-of-unlink-symlink.patch new file mode 100644 index 0000000..d69fce7 --- /dev/null +++ b/0018-install-use-symlink_atomic-instead-of-unlink-symlink.patch @@ -0,0 +1,69 @@ +From b533ed36a5ca33ba718ad37b18d1aa175f232d03 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jun 2014 00:11:47 +0200 +Subject: [PATCH] install: use symlink_atomic() instead of unlink()+symlink() + when force creating a symlink + +(cherry picked from commit 1f8c46040e824d7367c2f013de13c87d53f249dc) +--- + src/shared/install.c | 27 ++++++++------------------- + 1 file changed, 8 insertions(+), 19 deletions(-) + +diff --git a/src/shared/install.c b/src/shared/install.c +index 0f49f2a9..f0d3d1b7 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -603,13 +603,9 @@ int unit_file_mask( + continue; + + if (force) { +- unlink(path); +- +- if (symlink("/dev/null", path) >= 0) { +- ++ if (symlink_atomic("/dev/null", path) >= 0) { + add_file_change(changes, n_changes, UNIT_FILE_UNLINK, path, NULL); + add_file_change(changes, n_changes, UNIT_FILE_SYMLINK, path, "/dev/null"); +- + continue; + } + } +@@ -770,13 +766,9 @@ int unit_file_link( + continue; + + if (force) { +- unlink(path); +- +- if (symlink(*i, path) >= 0) { +- ++ if (symlink_atomic(*i, path) >= 0) { + add_file_change(changes, n_changes, UNIT_FILE_UNLINK, path, NULL); + add_file_change(changes, n_changes, UNIT_FILE_SYMLINK, path, *i); +- + continue; + } + } +@@ -1172,17 +1164,14 @@ static int create_symlink( + if (!force) + return -EEXIST; + +- r = unlink(new_path); +- if (r < 0 && errno != ENOENT) +- return -errno; ++ r = symlink_atomic(old_path, new_path); ++ if (r < 0) ++ return r; + +- if (symlink(old_path, new_path) >= 0) { +- add_file_change(changes, n_changes, UNIT_FILE_UNLINK, new_path, NULL); +- add_file_change(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path); +- return 0; +- } ++ add_file_change(changes, n_changes, UNIT_FILE_UNLINK, new_path, NULL); ++ add_file_change(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path); + +- return -errno; ++ return 0; + } + + static int install_info_symlink_alias( diff --git a/0019-install-when-looking-for-a-unit-file-for-enabling-se.patch b/0019-install-when-looking-for-a-unit-file-for-enabling-se.patch new file mode 100644 index 0000000..fd009b1 --- /dev/null +++ b/0019-install-when-looking-for-a-unit-file-for-enabling-se.patch @@ -0,0 +1,124 @@ +From acefb01e351be2f1dbd05078fdf4522a9dadaa4d Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jun 2014 00:13:48 +0200 +Subject: [PATCH] install: when looking for a unit file for enabling, search + for templates only after traversing all search directories + +Let's always make sure to look in all search directories for the full +unit names first, before looking for templates for them. + +(cherry picked from commit e50bd775163cd96be1888943a8785a436be710e8) +--- + src/shared/install.c | 74 +++++++++++++++++++++++++++------------------------- + 1 file changed, 38 insertions(+), 36 deletions(-) + +diff --git a/src/shared/install.c b/src/shared/install.c +index f0d3d1b7..e16de4d6 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -1035,67 +1035,69 @@ static int unit_file_search( + assert(paths); + + if (info->path) { +- char *full_path = NULL; ++ const char *path; + +- if (!isempty(root_dir)) +- full_path = strappenda(root_dir, info->path); ++ if (isempty(root_dir)) ++ path = info->path; ++ else ++ path = strappenda(root_dir, info->path); + +- return unit_file_load(c, info, full_path ?: info->path, allow_symlink); ++ return unit_file_load(c, info, path, allow_symlink); + } + + assert(info->name); + + STRV_FOREACH(p, paths->unit_path) { +- _cleanup_free_ char *path = NULL, *full_path = NULL; ++ _cleanup_free_ char *path = NULL; + +- path = strjoin(*p, "/", info->name, NULL); ++ if (isempty(root_dir)) ++ path = strjoin(*p, "/", info->name, NULL); ++ else ++ path = strjoin(root_dir, "/", *p, "/", info->name, NULL); + if (!path) + return -ENOMEM; + +- if (!isempty(root_dir)) { +- full_path = strappend(root_dir, path); +- if (!full_path) +- return -ENOMEM; +- } +- +- r = unit_file_load(c, info, full_path ?: path, allow_symlink); ++ r = unit_file_load(c, info, path, allow_symlink); + if (r >= 0) { + info->path = path; + path = NULL; +- } else if (r == -ENOENT && unit_name_is_instance(info->name)) { +- /* Unit file doesn't exist, however instance enablement was requested. +- * We will check if it is possible to load template unit file. */ +- _cleanup_free_ char *template = NULL, *template_dir = NULL; ++ return r; ++ } ++ if (r != -ENOENT && r != -ELOOP) ++ return r; ++ } + +- template = unit_name_template(info->name); +- if (!template) +- return -ENOMEM; ++ if (unit_name_is_instance(info->name)) { ++ ++ /* Unit file doesn't exist, however instance ++ * enablement was requested. We will check if it is ++ * possible to load template unit file. */ + +- /* We will reuse path variable since we don't need it anymore. */ +- template_dir = path; +- *(strrchr(template_dir, '/') + 1) = '\0'; ++ _cleanup_free_ char *template = NULL, *template_dir = NULL; ++ ++ template = unit_name_template(info->name); ++ if (!template) ++ return -ENOMEM; + +- path = strappend(template_dir, template); ++ STRV_FOREACH(p, paths->unit_path) { ++ _cleanup_free_ char *path = NULL; ++ ++ if (isempty(root_dir)) ++ path = strjoin(*p, "/", template, NULL); ++ else ++ path = strjoin(root_dir, "/", *p, "/", template, NULL); + if (!path) + return -ENOMEM; + +- if (!isempty(root_dir)) { +- free(full_path); +- full_path = strappend(root_dir, path); +- if (!full_path) +- return -ENOMEM; +- } +- +- /* Let's try to load template unit. */ +- r = unit_file_load(c, info, full_path ?: path, allow_symlink); ++ r = unit_file_load(c, info, path, allow_symlink); + if (r >= 0) { + info->path = path; + path = NULL; ++ return r; + } ++ if (r != -ENOENT && r != -ELOOP) ++ return r; + } +- +- if (r != -ENOENT && r != -ELOOP) +- return r; + } + + return -ENOENT; diff --git a/0020-install-make-sure-systemctl-disable-foobar-.service-.patch b/0020-install-make-sure-systemctl-disable-foobar-.service-.patch new file mode 100644 index 0000000..7255e54 --- /dev/null +++ b/0020-install-make-sure-systemctl-disable-foobar-.service-.patch @@ -0,0 +1,60 @@ +From 90d16404421d61e4e13bcff35f914477b9d04d81 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jun 2014 00:33:39 +0200 +Subject: [PATCH] install: make sure "systemctl disable foobar@.service" + actually removes all instances + +(cherry picked from commit 559367add5e22bf32d14fa1496512c68488f48b0) +--- + src/shared/install.c | 24 +++++++++++++++++------- + 1 file changed, 17 insertions(+), 7 deletions(-) + +diff --git a/src/shared/install.c b/src/shared/install.c +index e16de4d6..278350be 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -266,8 +266,22 @@ static int remove_marked_symlinks_fd( + + if (unit_name_is_instance(de->d_name) && + instance_whitelist && +- !strv_contains(instance_whitelist, de->d_name)) +- continue; ++ !strv_contains(instance_whitelist, de->d_name)) { ++ ++ _cleanup_free_ char *w; ++ ++ /* OK, the file is not listed directly ++ * in the whitelist, so let's check if ++ * the template of it might be ++ * listed. */ ++ ++ w = unit_name_template(de->d_name); ++ if (!w) ++ return -ENOMEM; ++ ++ if (!strv_contains(instance_whitelist, w)) ++ continue; ++ } + + p = path_make_absolute(de->d_name, path); + if (!p) +@@ -290,18 +304,14 @@ static int remove_marked_symlinks_fd( + if (!found) + continue; + +- + if (unlink(p) < 0 && errno != ENOENT) { +- + if (r == 0) + r = -errno; + continue; + } + +- rmdir_parents(p, config_path); +- + path_kill_slashes(p); +- ++ rmdir_parents(p, config_path); + add_file_change(changes, n_changes, UNIT_FILE_UNLINK, p, NULL); + + if (!set_get(remove_symlinks_to, p)) { diff --git a/0021-install-make-sure-that-root-mode-doesn-t-make-us-con.patch b/0021-install-make-sure-that-root-mode-doesn-t-make-us-con.patch new file mode 100644 index 0000000..3e42f84 --- /dev/null +++ b/0021-install-make-sure-that-root-mode-doesn-t-make-us-con.patch @@ -0,0 +1,146 @@ +From c88a943a7300a2c206d17aabc733ba3704eb83e5 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jun 2014 00:53:49 +0200 +Subject: [PATCH] install: make sure that --root= mode doesn't make us consider + all units outside of search path + +(cherry picked from commit 8f294b45cbb627d31342f6a79444be59ce7e2274) +--- + src/shared/install.c | 41 +++++++++++++++++++++++++++++++++++++---- + src/shared/util.c | 16 ---------------- + src/shared/util.h | 1 - + 3 files changed, 37 insertions(+), 21 deletions(-) + +diff --git a/src/shared/install.c b/src/shared/install.c +index 278350be..509ae933 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -47,6 +47,37 @@ typedef struct { + + #define _cleanup_install_context_done_ _cleanup_(install_context_done) + ++static int in_search_path(const char *path, char **search, const char *root_dir) { ++ _cleanup_free_ char *parent = NULL; ++ char **i; ++ int r; ++ ++ assert(path); ++ ++ r = path_get_parent(path, &parent); ++ if (r < 0) ++ return r; ++ ++ STRV_FOREACH(i, search) { ++ _cleanup_free_ char *buf = NULL; ++ const char *p; ++ ++ if (root_dir) { ++ buf = strjoin(root_dir, "/", *i, NULL); ++ if (!buf) ++ return -ENOMEM; ++ ++ p = buf; ++ } else ++ p = *i; ++ ++ if (path_equal(parent, p)) ++ return 1; ++ } ++ ++ return 0; ++} ++ + static int lookup_paths_init_from_scope(LookupPaths *paths, + UnitFileScope scope, + const char *root_dir) { +@@ -746,7 +777,7 @@ int unit_file_link( + continue; + } + +- q = in_search_path(*i, paths.unit_path); ++ q = in_search_path(*i, paths.unit_path, root_dir); + if (q < 0) + return q; + +@@ -1296,6 +1327,7 @@ static int install_info_symlink_link( + InstallInfo *i, + LookupPaths *paths, + const char *config_path, ++ const char *root_dir, + bool force, + UnitFileChange **changes, + unsigned *n_changes) { +@@ -1308,7 +1340,7 @@ static int install_info_symlink_link( + assert(config_path); + assert(i->path); + +- r = in_search_path(i->path, paths->unit_path); ++ r = in_search_path(i->path, paths->unit_path, root_dir); + if (r != 0) + return r; + +@@ -1323,6 +1355,7 @@ static int install_info_apply( + InstallInfo *i, + LookupPaths *paths, + const char *config_path, ++ const char *root_dir, + bool force, + UnitFileChange **changes, + unsigned *n_changes) { +@@ -1343,7 +1376,7 @@ static int install_info_apply( + if (r == 0) + r = q; + +- q = install_info_symlink_link(i, paths, config_path, force, changes, n_changes); ++ q = install_info_symlink_link(i, paths, config_path, root_dir, force, changes, n_changes); + if (r == 0) + r = q; + +@@ -1383,7 +1416,7 @@ static int install_context_apply( + } else if (r >= 0) + r += q; + +- q = install_info_apply(i, paths, config_path, force, changes, n_changes); ++ q = install_info_apply(i, paths, config_path, root_dir, force, changes, n_changes); + if (r >= 0 && q < 0) + r = q; + } +diff --git a/src/shared/util.c b/src/shared/util.c +index 91cbf204..9be80887 100644 +--- a/src/shared/util.c ++++ b/src/shared/util.c +@@ -4452,22 +4452,6 @@ int dirent_ensure_type(DIR *d, struct dirent *de) { + return 0; + } + +-int in_search_path(const char *path, char **search) { +- char **i; +- _cleanup_free_ char *parent = NULL; +- int r; +- +- r = path_get_parent(path, &parent); +- if (r < 0) +- return r; +- +- STRV_FOREACH(i, search) +- if (path_equal(parent, *i)) +- return 1; +- +- return 0; +-} +- + int get_files_in_directory(const char *path, char ***list) { + _cleanup_closedir_ DIR *d = NULL; + size_t bufsize = 0, n = 0; +diff --git a/src/shared/util.h b/src/shared/util.h +index 0f8c3933..9c38499a 100644 +--- a/src/shared/util.h ++++ b/src/shared/util.h +@@ -543,7 +543,6 @@ int glob_extend(char ***strv, const char *path); + + int dirent_ensure_type(DIR *d, struct dirent *de); + +-int in_search_path(const char *path, char **search); + int get_files_in_directory(const char *path, char ***list); + + char *strjoin(const char *x, ...) _sentinel_; diff --git a/0022-log-don-t-downgrade-log-level-in-non-PID-1-if-quiet-.patch b/0022-log-don-t-downgrade-log-level-in-non-PID-1-if-quiet-.patch new file mode 100644 index 0000000..2dd5492 --- /dev/null +++ b/0022-log-don-t-downgrade-log-level-in-non-PID-1-if-quiet-.patch @@ -0,0 +1,49 @@ +From 09fcc5cffa54468595fbf6b81308cd22e896cdfe Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jun 2014 01:05:39 +0200 +Subject: [PATCH] log: don't downgrade log level in non-PID 1 if "quiet" is + passed on kernel cmdline + +"debug" should apply to all tools, but "quiet" only to PID1. + +(cherry picked from commit d7b15e0a0161e8fd823bffd61a4799364871582f) +--- + src/core/main.c | 5 +++++ + src/shared/log.c | 3 --- + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/src/core/main.c b/src/core/main.c +index c9472929..80a2ea3a 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -412,11 +412,16 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { + } + + } else if (streq(key, "quiet") && !value) { ++ ++ log_set_max_level(LOG_NOTICE); ++ + if (arg_show_status == _SHOW_STATUS_UNSET) + arg_show_status = SHOW_STATUS_AUTO; + + } else if (streq(key, "debug") && !value) { ++ + log_set_max_level(LOG_DEBUG); ++ + if (detect_container(NULL) > 0) + log_set_target(LOG_TARGET_CONSOLE); + +diff --git a/src/shared/log.c b/src/shared/log.c +index 6f17705a..9039db34 100644 +--- a/src/shared/log.c ++++ b/src/shared/log.c +@@ -878,9 +878,6 @@ void log_parse_environment(void) { + if (l == 5 && startswith(w, "debug")) { + log_set_max_level(LOG_DEBUG); + break; +- } else if (l == 5 && startswith(w, "quiet")) { +- log_set_max_level(LOG_WARNING); +- break; + } + } + } diff --git a/0023-install-simplify-symlink-root-logic.patch b/0023-install-simplify-symlink-root-logic.patch new file mode 100644 index 0000000..6c36fb0 --- /dev/null +++ b/0023-install-simplify-symlink-root-logic.patch @@ -0,0 +1,148 @@ +From 7e1db29dde294155be972acf6d3e2db4d27266de Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jun 2014 01:37:54 +0200 +Subject: [PATCH] install: simplify symlink --root= logic + +(cherry picked from commit 278fa5758c8e30f03c8c50f15873d55edfc4cbaf) +--- + src/shared/install.c | 59 +++++++++++++--------------------------------------- + 1 file changed, 15 insertions(+), 44 deletions(-) + +diff --git a/src/shared/install.c b/src/shared/install.c +index 509ae933..8322970a 100644 +--- a/src/shared/install.c ++++ b/src/shared/install.c +@@ -47,9 +47,8 @@ typedef struct { + + #define _cleanup_install_context_done_ _cleanup_(install_context_done) + +-static int in_search_path(const char *path, char **search, const char *root_dir) { ++static int in_search_path(const char *path, char **search) { + _cleanup_free_ char *parent = NULL; +- char **i; + int r; + + assert(path); +@@ -58,24 +57,7 @@ static int in_search_path(const char *path, char **search, const char *root_dir) + if (r < 0) + return r; + +- STRV_FOREACH(i, search) { +- _cleanup_free_ char *buf = NULL; +- const char *p; +- +- if (root_dir) { +- buf = strjoin(root_dir, "/", *i, NULL); +- if (!buf) +- return -ENOMEM; +- +- p = buf; +- } else +- p = *i; +- +- if (path_equal(parent, p)) +- return 1; +- } +- +- return 0; ++ return strv_contains(search, parent); + } + + static int lookup_paths_init_from_scope(LookupPaths *paths, +@@ -777,7 +759,7 @@ int unit_file_link( + continue; + } + +- q = in_search_path(*i, paths.unit_path, root_dir); ++ q = in_search_path(*i, paths.unit_path); + if (q < 0) + return q; + +@@ -1021,6 +1003,7 @@ static int unit_file_load( + InstallContext *c, + InstallInfo *info, + const char *path, ++ const char *root_dir, + bool allow_symlink) { + + const ConfigTableItem items[] = { +@@ -1032,14 +1015,16 @@ static int unit_file_load( + { NULL, NULL, NULL, 0, NULL } + }; + +- int fd; + _cleanup_fclose_ FILE *f = NULL; +- int r; ++ int fd, r; + + assert(c); + assert(info); + assert(path); + ++ if (!isempty(root_dir)) ++ path = strappenda3(root_dir, "/", path); ++ + fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|(allow_symlink ? 0 : O_NOFOLLOW)); + if (fd < 0) + return -errno; +@@ -1075,30 +1060,19 @@ static int unit_file_search( + assert(info); + assert(paths); + +- if (info->path) { +- const char *path; +- +- if (isempty(root_dir)) +- path = info->path; +- else +- path = strappenda(root_dir, info->path); +- +- return unit_file_load(c, info, path, allow_symlink); +- } ++ if (info->path) ++ return unit_file_load(c, info, info->path, root_dir, allow_symlink); + + assert(info->name); + + STRV_FOREACH(p, paths->unit_path) { + _cleanup_free_ char *path = NULL; + +- if (isempty(root_dir)) +- path = strjoin(*p, "/", info->name, NULL); +- else +- path = strjoin(root_dir, "/", *p, "/", info->name, NULL); ++ path = strjoin(*p, "/", info->name, NULL); + if (!path) + return -ENOMEM; + +- r = unit_file_load(c, info, path, allow_symlink); ++ r = unit_file_load(c, info, path, root_dir, allow_symlink); + if (r >= 0) { + info->path = path; + path = NULL; +@@ -1123,14 +1097,11 @@ static int unit_file_search( + STRV_FOREACH(p, paths->unit_path) { + _cleanup_free_ char *path = NULL; + +- if (isempty(root_dir)) +- path = strjoin(*p, "/", template, NULL); +- else +- path = strjoin(root_dir, "/", *p, "/", template, NULL); ++ path = strjoin(*p, "/", template, NULL); + if (!path) + return -ENOMEM; + +- r = unit_file_load(c, info, path, allow_symlink); ++ r = unit_file_load(c, info, path, root_dir, allow_symlink); + if (r >= 0) { + info->path = path; + path = NULL; +@@ -1340,7 +1311,7 @@ static int install_info_symlink_link( + assert(config_path); + assert(i->path); + +- r = in_search_path(i->path, paths->unit_path, root_dir); ++ r = in_search_path(i->path, paths->unit_path); + if (r != 0) + return r; + diff --git a/0024-conf-files-fix-when-for-root-logic.patch b/0024-conf-files-fix-when-for-root-logic.patch new file mode 100644 index 0000000..9a59074 --- /dev/null +++ b/0024-conf-files-fix-when-for-root-logic.patch @@ -0,0 +1,49 @@ +From 90df11b158e4026a73281c4df9b562a74f7045f1 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jun 2014 01:56:44 +0200 +Subject: [PATCH] conf-files: fix when for --root= logic + +This is based on parts of similar patches from Michael Marineau and +Lukas Nykrin, but simply uses strappenda3(). + +(cherry picked from commit cebed5005b5ede17fc52ab50c054fca73bc938b8) +--- + src/shared/conf-files.c | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/src/shared/conf-files.c b/src/shared/conf-files.c +index 52017821..59bc8cee 100644 +--- a/src/shared/conf-files.c ++++ b/src/shared/conf-files.c +@@ -37,10 +37,20 @@ + #include "hashmap.h" + #include "conf-files.h" + +-static int files_add(Hashmap *h, const char *dirpath, const char *suffix) { ++static int files_add(Hashmap *h, const char *dirpath, const char *suffix, const char *root) { + _cleanup_closedir_ DIR *dir = NULL; + +- dir = opendir(dirpath); ++ assert(dirpath); ++ assert(suffix); ++ ++ if (isempty(root)) ++ dir = opendir(dirpath); ++ else { ++ const char *p; ++ ++ p = strappenda3(root, "/", dirpath); ++ dir = opendir(p); ++ } + if (!dir) { + if (errno == ENOENT) + return 0; +@@ -108,7 +118,7 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const + return -ENOMEM; + + STRV_FOREACH(p, dirs) { +- r = files_add(fh, *p, suffix); ++ r = files_add(fh, *p, suffix, root); + if (r == -ENOMEM) { + hashmap_free_free(fh); + return r; diff --git a/0025-networkd-don-t-pull-in-systemd-networkd-wait-online-.patch b/0025-networkd-don-t-pull-in-systemd-networkd-wait-online-.patch new file mode 100644 index 0000000..83ab248 --- /dev/null +++ b/0025-networkd-don-t-pull-in-systemd-networkd-wait-online-.patch @@ -0,0 +1,26 @@ +From 12c375aecad2df91b32a799460585f1a97a106a8 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 17 Jun 2014 02:13:08 +0200 +Subject: [PATCH] networkd: don't pull in systemd-networkd-wait-online service + from systemd-networkd when enabling + +networkd-wait-online should never exist in the default transaction, +unless explicitly enable or pulled in via things like NFS. However, just +enabling networkd shouldn't enable networkd-wait-online, since it's +common to use the former without the latter. + +(cherry picked from commit 324d7a53b9c53b33520b97f2562219ac4143f581) +--- + units/systemd-networkd.service.in | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/units/systemd-networkd.service.in b/units/systemd-networkd.service.in +index 48f4d63a..f3bf95d3 100644 +--- a/units/systemd-networkd.service.in ++++ b/units/systemd-networkd.service.in +@@ -25,5 +25,4 @@ ProtectHome=yes + WatchdogSec=1min + + [Install] +-Also=systemd-networkd-wait-online.service + WantedBy=multi-user.target diff --git a/0026-bootchart-set-white-background.patch b/0026-bootchart-set-white-background.patch new file mode 100644 index 0000000..10549e5 --- /dev/null +++ b/0026-bootchart-set-white-background.patch @@ -0,0 +1,35 @@ +From 985c32b7716eea3f04f0b423ef3d136708b6ad51 Mon Sep 17 00:00:00 2001 +From: Frederic Crozat +Date: Mon, 16 Jun 2014 18:49:12 +0200 +Subject: [PATCH] bootchart: set white background + + In programs like eog and gimp the transparant background did not +look very good. + +Similar fix from the one done in systemd-analyze (418e3750) + +(cherry picked from commit a7997073ac07add6cb30dcd9491c0179b2d6ad52) +--- + src/bootchart/svg.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c +index a53f98a9..81211995 100644 +--- a/src/bootchart/svg.c ++++ b/src/bootchart/svg.c +@@ -123,6 +123,7 @@ static void svg_header(void) { + svg("\n