From c311032ffb65c7998feb688a15e114e4cc0c36ab0c0a349914f689f3e236cd39 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Thu, 3 Apr 2014 14:38:38 +0000 Subject: [PATCH] Accepting request 228354 from Base:System OBS-URL: https://build.opensuse.org/request/show/228354 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=179 --- ...t-s-not-OK-to-invoke-alloca-in-loops.patch | 80 +++ ...or-don-t-return-OOM-on-parentless-de.patch | 20 + ...emory-leak-when-kdbus-is-not-enabled.patch | 26 + ...l-bus-call-on-machine-objects-when-w.patch | 70 +++ 0002-make-209-working-on-older-dist.patch | 65 --- ...-assert_return-to-check-for-disconne.patch | 498 ++++++++++++++++++ ...o-relabel-mounts-before-we-loaded-th.patch | 29 + ...daemon-fix-incorrect-variable-access.patch | 25 + ...-return-1-EINVAL-on-allocation-error.patch | 35 ++ ...ization-perturbation-value-right-bef.patch | 75 +++ 0007-networkd-fix-typo.patch | 26 + ...ccidentally-turn-of-watchdog-timer-e.patch | 29 + ...ess-invalid-memory-if-a-signal-match.patch | 27 + ...ode-is-long-long-gone-don-t-mention-.patch | 53 ++ ...n-the-user-types-a-overly-long-passw.patch | 33 ++ ...ke-if-somebody-sends-us-a-message-wi.patch | 47 ++ ...ve-stray-reset-of-error-return-value.patch | 24 + ...systemd-timedate-udev-spelling-fixes.patch | 118 +++++ 1006-udev-always-rename-network.patch | 94 ++-- ...pletion-smart-to-be-able-to-redirect.patch | 2 +- ...andom-hangs-on-timeouts-due-lost-cwd.patch | 23 + boot-local-start.patch | 12 + pre_checkin.sh | 12 - prepare-suspend-to-disk.patch | 28 + systemctl-set-default-target.patch | 28 + systemd-mini.changes | 78 ++- systemd-mini.spec | 139 +++-- systemd-sleep-grub | 204 +++++++ systemd.changes | 78 ++- systemd.spec | 139 +++-- udev-generate-peristent-rule.sh | 414 +++++++++++++++ 31 files changed, 2311 insertions(+), 220 deletions(-) create mode 100644 0001-cgroup-it-s-not-OK-to-invoke-alloca-in-loops.patch create mode 100644 0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch create mode 100644 0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch create mode 100644 0002-machined-fix-Kill-bus-call-on-machine-objects-when-w.patch delete mode 100644 0002-make-209-working-on-older-dist.patch create mode 100644 0003-sd-bus-don-t-use-assert_return-to-check-for-disconne.patch create mode 100644 0004-core-don-t-try-to-relabel-mounts-before-we-loaded-th.patch create mode 100644 0005-sd-daemon-fix-incorrect-variable-access.patch create mode 100644 0006-Do-not-return-1-EINVAL-on-allocation-error.patch create mode 100644 0006-sd-event-initialization-perturbation-value-right-bef.patch create mode 100644 0007-networkd-fix-typo.patch create mode 100644 0007-sd-event-don-t-accidentally-turn-of-watchdog-timer-e.patch create mode 100644 0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch create mode 100644 0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch create mode 100644 0009-ask-password-when-the-user-types-a-overly-long-passw.patch create mode 100644 0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch create mode 100644 0012-journald-remove-stray-reset-of-error-return-value.patch create mode 100644 0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch create mode 100644 avoid-random-hangs-on-timeouts-due-lost-cwd.patch create mode 100644 boot-local-start.patch create mode 100644 prepare-suspend-to-disk.patch create mode 100644 systemctl-set-default-target.patch create mode 100644 systemd-sleep-grub create mode 100644 udev-generate-peristent-rule.sh diff --git a/0001-cgroup-it-s-not-OK-to-invoke-alloca-in-loops.patch b/0001-cgroup-it-s-not-OK-to-invoke-alloca-in-loops.patch new file mode 100644 index 00000000..06845364 --- /dev/null +++ b/0001-cgroup-it-s-not-OK-to-invoke-alloca-in-loops.patch @@ -0,0 +1,80 @@ +From a641dcd9bf05418d6a6c165e1c0cff615b4a0f47 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 18 Mar 2014 04:06:36 +0100 +Subject: [PATCH] cgroup: it's not OK to invoke alloca() in loops + +--- + src/core/mount-setup.c | 20 ++++++++++++++------ + 1 file changed, 14 insertions(+), 6 deletions(-) + +diff --git src/core/mount-setup.c src/core/mount-setup.c +index 387030a..c6d3f4b 100644 +--- src/core/mount-setup.c ++++ src/core/mount-setup.c +@@ -216,10 +216,10 @@ int mount_setup_early(void) { + } + + int mount_cgroup_controllers(char ***join_controllers) { +- int r; +- char buf[LINE_MAX]; + _cleanup_set_free_free_ Set *controllers = NULL; + _cleanup_fclose_ FILE *f; ++ char buf[LINE_MAX]; ++ int r; + + /* Mount all available cgroup controllers that are built into the kernel. */ + +@@ -262,6 +262,7 @@ int mount_cgroup_controllers(char ***join_controllers) { + } + + for (;;) { ++ _cleanup_free_ char *options = NULL, *controller = NULL, *where = NULL; + MountPoint p = { + .what = "cgroup", + .type = "cgroup", +@@ -269,7 +270,6 @@ int mount_cgroup_controllers(char ***join_controllers) { + .mode = MNT_IN_CONTAINER, + }; + char ***k = NULL; +- _cleanup_free_ char *options = NULL, *controller; + + controller = set_steal_first(controllers); + if (!controller) +@@ -286,7 +286,7 @@ int mount_cgroup_controllers(char ***join_controllers) { + for (i = *k, j = *k; *i; i++) { + + if (!streq(*i, controller)) { +- char _cleanup_free_ *t; ++ _cleanup_free_ char *t; + + t = set_remove(controllers, *i); + if (!t) { +@@ -308,7 +308,11 @@ int mount_cgroup_controllers(char ***join_controllers) { + controller = NULL; + } + +- p.where = strappenda("/sys/fs/cgroup/", options); ++ where = strappend("/sys/fs/cgroup/", options); ++ if (!where) ++ return log_oom(); ++ ++ p.where = where; + p.options = options; + + r = mount_one(&p, true); +@@ -319,7 +323,11 @@ int mount_cgroup_controllers(char ***join_controllers) { + char **i; + + for (i = *k; *i; i++) { +- char *t = strappenda("/sys/fs/cgroup/", *i); ++ _cleanup_free_ char *t = NULL; ++ ++ t = strappend("/sys/fs/cgroup/", *i); ++ if (!t) ++ return log_oom(); + + r = symlink(options, t); + if (r < 0 && errno != EEXIST) { +-- +1.7.9.2 + diff --git a/0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch b/0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch new file mode 100644 index 00000000..be9add48 --- /dev/null +++ b/0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch @@ -0,0 +1,20 @@ +From 9c4495ca561624c2f0085507dd1288ed5f1247c5 Mon Sep 17 00:00:00 2001 +From: Tomasz Torcz +Date: Wed, 12 Mar 2014 19:25:11 +0100 +Subject: [PATCH] gpt-auto-generator: don't return OOM on parentless devices + +--- + src/gpt-auto-generator/gpt-auto-generator.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- src/gpt-auto-generator/gpt-auto-generator.c ++++ src/gpt-auto-generator/gpt-auto-generator.c 2014-03-18 13:35:11.438235125 +0000 +@@ -254,7 +254,7 @@ static int enumerate_partitions(struct u + + parent = udev_device_get_parent(d); + if (!parent) +- return log_oom(); ++ return 0; + + r = udev_enumerate_add_match_parent(e, parent); + if (r < 0) diff --git a/0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch b/0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch new file mode 100644 index 00000000..718f6862 --- /dev/null +++ b/0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch @@ -0,0 +1,26 @@ +From 82923adfe5c4fa09cc91fd2a2e374c936cd4a186 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Thu, 13 Mar 2014 20:00:50 +0100 +Subject: [PATCH] bus: fix memory leak when kdbus is not enabled + +--- + src/libsystemd/sd-bus/sd-bus.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git src/libsystemd/sd-bus/sd-bus.c src/libsystemd/sd-bus/sd-bus.c +index ffa3369..ca7c428 100644 +--- src/libsystemd/sd-bus/sd-bus.c ++++ src/libsystemd/sd-bus/sd-bus.c +@@ -1189,7 +1189,8 @@ _public_ int sd_bus_open_user(sd_bus **ret) { + #ifdef ENABLE_KDBUS + asprintf(&b->address, KERNEL_USER_BUS_FMT, (unsigned long) getuid()); + #else +- return -ECONNREFUSED; ++ r = -ECONNREFUSED; ++ goto fail; + #endif + } + +-- +1.7.9.2 + diff --git a/0002-machined-fix-Kill-bus-call-on-machine-objects-when-w.patch b/0002-machined-fix-Kill-bus-call-on-machine-objects-when-w.patch new file mode 100644 index 00000000..c3381ef7 --- /dev/null +++ b/0002-machined-fix-Kill-bus-call-on-machine-objects-when-w.patch @@ -0,0 +1,70 @@ +From de58a50e24a0d55e3bbcc77f8f6170a7322acf52 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 18 Mar 2014 04:43:08 +0100 +Subject: [PATCH] machined: fix Kill() bus call on machine objects when "what" + is specified as "leader" + +--- + src/machine/machine.c | 10 +++++++++- + src/machine/machined-dbus.c | 4 ++-- + src/machine/machined.h | 2 +- + 3 files changed, 12 insertions(+), 4 deletions(-) + +diff --git src/machine/machine.c src/machine/machine.c +index 4596a80..9a5cc9a 100644 +--- src/machine/machine.c ++++ src/machine/machine.c +@@ -410,7 +410,15 @@ int machine_kill(Machine *m, KillWho who, int signo) { + if (!m->unit) + return -ESRCH; + +- return manager_kill_unit(m->manager, m->unit, who, signo, NULL); ++ if (who == KILL_LEADER) { ++ /* If we shall simply kill the leader, do so directly */ ++ ++ if (kill(m->leader, signo) < 0) ++ return -errno; ++ } ++ ++ /* Otherwise make PID 1 do it for us, for the entire cgroup */ ++ return manager_kill_unit(m->manager, m->unit, signo, NULL); + } + + static const char* const machine_class_table[_MACHINE_CLASS_MAX] = { +diff --git src/machine/machined-dbus.c src/machine/machined-dbus.c +index 09d28bb..9473105 100644 +--- src/machine/machined-dbus.c ++++ src/machine/machined-dbus.c +@@ -655,7 +655,7 @@ int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, c + return 1; + } + +-int manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo, sd_bus_error *error) { ++int manager_kill_unit(Manager *manager, const char *unit, int signo, sd_bus_error *error) { + assert(manager); + assert(unit); + +@@ -667,7 +667,7 @@ int manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo + "KillUnit", + error, + NULL, +- "ssi", unit, who == KILL_LEADER ? "main" : "all", signo); ++ "ssi", unit, "all", signo); + } + + int manager_unit_is_active(Manager *manager, const char *unit) { +diff --git src/machine/machined.h src/machine/machined.h +index d4b581b..2dba303 100644 +--- src/machine/machined.h ++++ src/machine/machined.h +@@ -67,6 +67,6 @@ int match_job_removed(sd_bus *bus, sd_bus_message *message, void *userdata, sd_b + + int manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, sd_bus_message *more_properties, sd_bus_error *error, char **job); + int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job); +-int manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo, sd_bus_error *error); ++int manager_kill_unit(Manager *manager, const char *unit, int signo, sd_bus_error *error); + int manager_unit_is_active(Manager *manager, const char *unit); + int manager_job_is_active(Manager *manager, const char *path); +-- +1.7.9.2 + diff --git a/0002-make-209-working-on-older-dist.patch b/0002-make-209-working-on-older-dist.patch deleted file mode 100644 index 502c6a44..00000000 --- a/0002-make-209-working-on-older-dist.patch +++ /dev/null @@ -1,65 +0,0 @@ ---- systemd-209/units/kmod-static-nodes.service.in -+++ systemd-209/units/kmod-static-nodes.service.in 2014-02-27 15:04:30.378236539 +0000 -@@ -15,4 +15,5 @@ ConditionPathExists=/lib/modules/%v/modu - [Service] - Type=oneshot - RemainAfterExit=yes -+ExecStartPre=@MKDIR_P@ /run/tmpfiles.d - ExecStart=@KMOD@ static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf ---- systemd-209/configure -+++ systemd-209/configure 2014-02-28 17:13:50.770735397 +0000 -@@ -15999,12 +15999,12 @@ if test -n "$KMOD_CFLAGS"; then - pkg_cv_KMOD_CFLAGS="$KMOD_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ -- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libkmod >= 15 \""; } >&5 -- ($PKG_CONFIG --exists --print-errors " libkmod >= 15 ") 2>&5 -+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libkmod >= 14 \""; } >&5 -+ ($PKG_CONFIG --exists --print-errors " libkmod >= 14 ") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then -- pkg_cv_KMOD_CFLAGS=`$PKG_CONFIG --cflags " libkmod >= 15 " 2>/dev/null` -+ pkg_cv_KMOD_CFLAGS=`$PKG_CONFIG --cflags " libkmod >= 14 " 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes - else - pkg_failed=yes -@@ -16016,12 +16016,12 @@ if test -n "$KMOD_LIBS"; then - pkg_cv_KMOD_LIBS="$KMOD_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ -- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libkmod >= 15 \""; } >&5 -- ($PKG_CONFIG --exists --print-errors " libkmod >= 15 ") 2>&5 -+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libkmod >= 14 \""; } >&5 -+ ($PKG_CONFIG --exists --print-errors " libkmod >= 14 ") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then -- pkg_cv_KMOD_LIBS=`$PKG_CONFIG --libs " libkmod >= 15 " 2>/dev/null` -+ pkg_cv_KMOD_LIBS=`$PKG_CONFIG --libs " libkmod >= 14 " 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes - else - pkg_failed=yes -@@ -16042,18 +16042,18 @@ else - _pkg_short_errors_supported=no - fi - if test $_pkg_short_errors_supported = yes; then -- KMOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " libkmod >= 15 " 2>&1` -+ KMOD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " libkmod >= 14 " 2>&1` - else -- KMOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " libkmod >= 15 " 2>&1` -+ KMOD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " libkmod >= 14 " 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$KMOD_PKG_ERRORS" >&5 - -- as_fn_error $? "*** kmod version >= 15 not found" "$LINENO" 5 -+ as_fn_error $? "*** kmod version >= 14 not found" "$LINENO" 5 - elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 - $as_echo "no" >&6; } -- as_fn_error $? "*** kmod version >= 15 not found" "$LINENO" 5 -+ as_fn_error $? "*** kmod version >= 14 not found" "$LINENO" 5 - else - KMOD_CFLAGS=$pkg_cv_KMOD_CFLAGS - KMOD_LIBS=$pkg_cv_KMOD_LIBS diff --git a/0003-sd-bus-don-t-use-assert_return-to-check-for-disconne.patch b/0003-sd-bus-don-t-use-assert_return-to-check-for-disconne.patch new file mode 100644 index 00000000..72455f2c --- /dev/null +++ b/0003-sd-bus-don-t-use-assert_return-to-check-for-disconne.patch @@ -0,0 +1,498 @@ +From a3d59cd1b0a2738d06893948492113f2c35be0af Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 19 Mar 2014 21:41:21 +0100 +Subject: [PATCH] sd-bus: don't use assert_return() to check for disconnected + bus connections + +A terminated connection is a runtime error and not a developer mistake, +hence don't use assert_return() to check for it. +--- + src/libsystemd/sd-bus/bus-control.c | 20 +++++++++++++----- + src/libsystemd/sd-bus/bus-convenience.c | 58 +++++++++++++++++++++++++++++++++++++++++------------- + src/libsystemd/sd-bus/bus-objects.c | 23 +++++++++++++++------ + src/libsystemd/sd-bus/sd-bus.c | 49 +++++++++++++++++++++++++++++++++------------ + 4 files changed, 113 insertions(+), 37 deletions(-) + +--- src/libsystemd/sd-bus/bus-control.c ++++ src/libsystemd/sd-bus/bus-control.c 2014-03-28 00:00:00.000000000 +0000 +@@ -128,12 +128,14 @@ _public_ int sd_bus_request_name(sd_bus + assert_return(bus, -EINVAL); + assert_return(name, -EINVAL); + assert_return(bus->bus_client, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(!(flags & ~(SD_BUS_NAME_ALLOW_REPLACEMENT|SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_QUEUE)), -EINVAL); + assert_return(service_name_is_valid(name), -EINVAL); + assert_return(name[0] != ':', -EINVAL); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + if (bus->is_kernel) + return bus_request_name_kernel(bus, name, flags); + else +@@ -201,11 +203,13 @@ _public_ int sd_bus_release_name(sd_bus + assert_return(bus, -EINVAL); + assert_return(name, -EINVAL); + assert_return(bus->bus_client, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(service_name_is_valid(name), -EINVAL); + assert_return(name[0] != ':', -EINVAL); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + if (bus->is_kernel) + return bus_release_name_kernel(bus, name); + else +@@ -344,9 +348,11 @@ static int bus_list_names_dbus1(sd_bus * + _public_ int sd_bus_list_names(sd_bus *bus, char ***acquired, char ***activatable) { + assert_return(bus, -EINVAL); + assert_return(acquired || activatable, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + if (bus->is_kernel) + return bus_list_names_kernel(bus, acquired, activatable); + else +@@ -737,11 +743,13 @@ _public_ int sd_bus_get_owner( + assert_return(name, -EINVAL); + assert_return(mask <= _SD_BUS_CREDS_ALL, -ENOTSUP); + assert_return(mask == 0 || creds, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(service_name_is_valid(name), -EINVAL); + assert_return(bus->bus_client, -ENODATA); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + if (bus->is_kernel) + return bus_get_owner_kdbus(bus, name, mask, creds); + else +@@ -1198,10 +1206,12 @@ _public_ int sd_bus_get_owner_machine_id + assert_return(bus, -EINVAL); + assert_return(name, -EINVAL); + assert_return(machine, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(service_name_is_valid(name), -EINVAL); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + if (streq_ptr(name, bus->unique_name)) + return sd_id128_get_machine(machine); + +--- src/libsystemd/sd-bus/bus-convenience.c ++++ src/libsystemd/sd-bus/bus-convenience.c 2014-03-28 00:00:00.000000000 +0000 +@@ -36,9 +36,11 @@ _public_ int sd_bus_emit_signal( + int r; + + assert_return(bus, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + r = sd_bus_message_new_signal(bus, &m, path, interface, member); + if (r < 0) + return r; +@@ -70,9 +72,11 @@ _public_ int sd_bus_call_method( + int r; + + assert_return(bus, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + r = sd_bus_message_new_method_call(bus, &m, destination, path, interface, member); + if (r < 0) + return r; +@@ -100,9 +104,12 @@ _public_ int sd_bus_reply_method_return( + assert_return(call, -EINVAL); + assert_return(call->sealed, -EPERM); + assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); +- assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); ++ assert_return(call->bus, -EINVAL); + assert_return(!bus_pid_changed(call->bus), -ECHILD); + ++ if (!BUS_IS_OPEN(call->bus->state)) ++ return -ENOTCONN; ++ + if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) + return 0; + +@@ -134,9 +141,12 @@ _public_ int sd_bus_reply_method_error( + assert_return(call->sealed, -EPERM); + assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); + assert_return(sd_bus_error_is_set(e), -EINVAL); +- assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); ++ assert_return(call->bus, -EINVAL); + assert_return(!bus_pid_changed(call->bus), -ECHILD); + ++ if (!BUS_IS_OPEN(call->bus->state)) ++ return -ENOTCONN; ++ + if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) + return 0; + +@@ -159,9 +169,12 @@ _public_ int sd_bus_reply_method_errorf( + assert_return(call, -EINVAL); + assert_return(call->sealed, -EPERM); + assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); +- assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); ++ assert_return(call->bus, -EINVAL); + assert_return(!bus_pid_changed(call->bus), -ECHILD); + ++ if (!BUS_IS_OPEN(call->bus->state)) ++ return -ENOTCONN; ++ + if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) + return 0; + +@@ -182,9 +195,12 @@ _public_ int sd_bus_reply_method_errno( + assert_return(call, -EINVAL); + assert_return(call->sealed, -EPERM); + assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); +- assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); ++ assert_return(call->bus, -EINVAL); + assert_return(!bus_pid_changed(call->bus), -ECHILD); + ++ if (!BUS_IS_OPEN(call->bus->state)) ++ return -ENOTCONN; ++ + if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) + return 0; + +@@ -208,9 +224,12 @@ _public_ int sd_bus_reply_method_errnof( + assert_return(call, -EINVAL); + assert_return(call->sealed, -EPERM); + assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); +- assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); ++ assert_return(call->bus, -EINVAL); + assert_return(!bus_pid_changed(call->bus), -ECHILD); + ++ if (!BUS_IS_OPEN(call->bus->state)) ++ return -ENOTCONN; ++ + if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) + return 0; + +@@ -239,9 +258,11 @@ _public_ int sd_bus_get_property( + assert_return(member_name_is_valid(member), -EINVAL); + assert_return(reply, -EINVAL); + assert_return(signature_is_single(type, false), -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + r = sd_bus_call_method(bus, destination, path, "org.freedesktop.DBus.Properties", "Get", error, &rep, "ss", strempty(interface), member); + if (r < 0) + return r; +@@ -273,9 +294,11 @@ _public_ int sd_bus_get_property_trivial + assert_return(member_name_is_valid(member), -EINVAL); + assert_return(bus_type_is_trivial(type), -EINVAL); + assert_return(ptr, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + r = sd_bus_call_method(bus, destination, path, "org.freedesktop.DBus.Properties", "Get", error, &reply, "ss", strempty(interface), member); + if (r < 0) + return r; +@@ -309,9 +332,11 @@ _public_ int sd_bus_get_property_string( + assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL); + assert_return(member_name_is_valid(member), -EINVAL); + assert_return(ret, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + r = sd_bus_call_method(bus, destination, path, "org.freedesktop.DBus.Properties", "Get", error, &reply, "ss", strempty(interface), member); + if (r < 0) + return r; +@@ -348,9 +373,11 @@ _public_ int sd_bus_get_property_strv( + assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL); + assert_return(member_name_is_valid(member), -EINVAL); + assert_return(ret, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + r = sd_bus_call_method(bus, destination, path, "org.freedesktop.DBus.Properties", "Get", error, &reply, "ss", strempty(interface), member); + if (r < 0) + return r; +@@ -383,9 +410,11 @@ _public_ int sd_bus_set_property( + assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL); + assert_return(member_name_is_valid(member), -EINVAL); + assert_return(signature_is_single(type, false), -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + r = sd_bus_message_new_method_call(bus, &m, destination, path, "org.freedesktop.DBus.Properties", "Set"); + if (r < 0) + return r; +@@ -416,9 +445,12 @@ _public_ int sd_bus_query_sender_creds(s + + assert_return(call, -EINVAL); + assert_return(call->sealed, -EPERM); +- assert_return(call->bus && BUS_IS_OPEN(call->bus->state), -ENOTCONN); ++ assert_return(call->bus, -EINVAL); + assert_return(!bus_pid_changed(call->bus), -ECHILD); + ++ if (!BUS_IS_OPEN(call->bus->state)) ++ return -ENOTCONN; ++ + c = sd_bus_message_get_creds(call); + + /* All data we need? */ +--- src/libsystemd/sd-bus/bus-objects.c ++++ src/libsystemd/sd-bus/bus-objects.c 2014-03-28 00:00:00.000000000 +0000 +@@ -2196,9 +2196,10 @@ _public_ int sd_bus_emit_properties_chan + assert_return(bus, -EINVAL); + assert_return(object_path_is_valid(path), -EINVAL); + assert_return(interface_name_is_valid(interface), -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; + + /* A non-NULL but empty names list means nothing needs to be + generated. A NULL list OTOH indicates that all properties +@@ -2241,9 +2242,11 @@ _public_ int sd_bus_emit_properties_chan + assert_return(bus, -EINVAL); + assert_return(object_path_is_valid(path), -EINVAL); + assert_return(interface_name_is_valid(interface), -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + if (!name) + return 0; + +@@ -2361,9 +2364,11 @@ _public_ int sd_bus_emit_interfaces_adde + + assert_return(bus, -EINVAL); + assert_return(object_path_is_valid(path), -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + if (strv_isempty(interfaces)) + return 0; + +@@ -2421,9 +2426,11 @@ _public_ int sd_bus_emit_interfaces_adde + + assert_return(bus, -EINVAL); + assert_return(object_path_is_valid(path), -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + interfaces = strv_from_stdarg_alloca(interface); + + return sd_bus_emit_interfaces_added_strv(bus, path, interfaces); +@@ -2435,9 +2442,11 @@ _public_ int sd_bus_emit_interfaces_remo + + assert_return(bus, -EINVAL); + assert_return(object_path_is_valid(path), -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + if (strv_isempty(interfaces)) + return 0; + +@@ -2461,9 +2470,11 @@ _public_ int sd_bus_emit_interfaces_remo + + assert_return(bus, -EINVAL); + assert_return(object_path_is_valid(path), -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + interfaces = strv_from_stdarg_alloca(interface); + + return sd_bus_emit_interfaces_removed_strv(bus, path, interfaces); +--- src/libsystemd/sd-bus/sd-bus.c ++++ src/libsystemd/sd-bus/sd-bus.c 2014-03-28 12:19:27.146736146 +0000 +@@ -1592,10 +1592,12 @@ static int bus_send_internal(sd_bus *bus + int r; + + assert_return(bus, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(m, -EINVAL); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + if (m->n_fds > 0) { + r = sd_bus_can_send(bus, SD_BUS_TYPE_UNIX_FD); + if (r < 0) +@@ -1671,10 +1673,12 @@ _public_ int sd_bus_send_to(sd_bus *bus, + int r; + + assert_return(bus, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(m, -EINVAL); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + if (!streq_ptr(m->destination, destination)) { + + if (!destination) +@@ -1726,13 +1730,15 @@ _public_ int sd_bus_call_async( + int r; + + assert_return(bus, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(m, -EINVAL); + assert_return(m->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); + assert_return(!(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED), -EINVAL); + assert_return(callback, -EINVAL); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + r = hashmap_ensure_allocated(&bus->reply_callbacks, uint64_hash_func, uint64_compare_func); + if (r < 0) + return r; +@@ -1839,13 +1845,15 @@ _public_ int sd_bus_call( + int r; + + assert_return(bus, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(m, -EINVAL); + assert_return(m->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL); + assert_return(!(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED), -EINVAL); + assert_return(!bus_error_is_dirty(error), -EINVAL); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; ++ + r = bus_ensure_running(bus); + if (r < 0) + return r; +@@ -1971,9 +1979,11 @@ _public_ int sd_bus_get_events(sd_bus *b + int flags = 0; + + assert_return(bus, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state) || bus->state == BUS_CLOSING, -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state) && bus->state != BUS_CLOSING) ++ return -ENOTCONN; ++ + if (bus->state == BUS_OPENING) + flags |= POLLOUT; + else if (bus->state == BUS_AUTHENTICATING) { +@@ -1998,9 +2008,11 @@ _public_ int sd_bus_get_timeout(sd_bus * + + assert_return(bus, -EINVAL); + assert_return(timeout_usec, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state) || bus->state == BUS_CLOSING, -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + ++ if (!BUS_IS_OPEN(bus->state) && bus->state != BUS_CLOSING) ++ return -ENOTCONN; ++ + if (bus->state == BUS_CLOSING) { + *timeout_usec = 0; + return 1; +@@ -2510,7 +2522,8 @@ static int bus_poll(sd_bus *bus, bool ne + if (bus->state == BUS_CLOSING) + return 1; + +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; + + e = sd_bus_get_events(bus); + if (e < 0) +@@ -2565,7 +2578,8 @@ _public_ int sd_bus_wait(sd_bus *bus, ui + if (bus->state == BUS_CLOSING) + return 0; + +- assert_return(BUS_IS_OPEN(bus->state) , -ENOTCONN); ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; + + if (bus->rqueue_size > 0) + return 0; +@@ -2582,7 +2596,8 @@ _public_ int sd_bus_flush(sd_bus *bus) { + if (bus->state == BUS_CLOSING) + return 0; + +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; + + r = bus_ensure_running(bus); + if (r < 0) +@@ -3058,9 +3073,13 @@ _public_ int sd_bus_get_peer_creds(sd_bu + assert_return(bus, -EINVAL); + assert_return(mask <= _SD_BUS_CREDS_ALL, -ENOTSUP); + assert_return(ret, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); +- assert_return(!bus->is_kernel, -ENOTSUP); ++ ++ if (!bus->is_kernel) ++ return -ENOTSUP; ++ ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; + + if (!bus->ucred_valid && !isempty(bus->label)) + return -ENODATA; +@@ -3099,9 +3118,13 @@ _public_ int sd_bus_try_close(sd_bus *bu + int r; + + assert_return(bus, -EINVAL); +- assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); +- assert_return(bus->is_kernel, -ENOTSUP); ++ ++ if (!bus->is_kernel) ++ return -ENOTSUP; ++ ++ if (!BUS_IS_OPEN(bus->state)) ++ return -ENOTCONN; + + if (bus->rqueue_size > 0) + return -EBUSY; diff --git a/0004-core-don-t-try-to-relabel-mounts-before-we-loaded-th.patch b/0004-core-don-t-try-to-relabel-mounts-before-we-loaded-th.patch new file mode 100644 index 00000000..17d7f268 --- /dev/null +++ b/0004-core-don-t-try-to-relabel-mounts-before-we-loaded-th.patch @@ -0,0 +1,29 @@ +From c4bfd1691f4d3e26d6d7f34dbca941e119956e8a Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 24 Mar 2014 21:04:02 +0100 +Subject: [PATCH] core: don't try to relabel mounts before we loaded the + policy + +--- + src/core/mount-setup.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git src/core/mount-setup.c src/core/mount-setup.c +index 147333a..0a45b24 100644 +--- src/core/mount-setup.c ++++ src/core/mount-setup.c +@@ -172,7 +172,10 @@ static int mount_one(const MountPoint *p, bool relabel) { + + /* The access mode here doesn't really matter too much, since + * the mounted file system will take precedence anyway. */ +- mkdir_p_label(p->where, 0755); ++ if (relabel) ++ mkdir_p_label(p->where, 0755); ++ else ++ mkdir_p(p->where, 0755); + + log_debug("Mounting %s to %s of type %s with options %s.", + p->what, +-- +1.7.9.2 + diff --git a/0005-sd-daemon-fix-incorrect-variable-access.patch b/0005-sd-daemon-fix-incorrect-variable-access.patch new file mode 100644 index 00000000..99a923b2 --- /dev/null +++ b/0005-sd-daemon-fix-incorrect-variable-access.patch @@ -0,0 +1,25 @@ +From 56dc9aec21ab23f76fadf45585adf88e71aa8078 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 24 Mar 2014 23:54:14 +0100 +Subject: [PATCH] sd-daemon: fix incorrect variable access + +--- + src/libsystemd/sd-daemon/sd-daemon.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git src/libsystemd/sd-daemon/sd-daemon.c src/libsystemd/sd-daemon/sd-daemon.c +index 21fb346..b013438 100644 +--- src/libsystemd/sd-daemon/sd-daemon.c ++++ src/libsystemd/sd-daemon/sd-daemon.c +@@ -517,7 +517,7 @@ _public_ int sd_watchdog_enabled(int unset_environment, uint64_t *usec) { + r = -errno; + goto finish; + } +- if (!p || p == e || *p || l <= 0) { ++ if (!p || p == e || *p || ll <= 0) { + r = -EINVAL; + goto finish; + } +-- +1.7.9.2 + diff --git a/0006-Do-not-return-1-EINVAL-on-allocation-error.patch b/0006-Do-not-return-1-EINVAL-on-allocation-error.patch new file mode 100644 index 00000000..bf1db2c6 --- /dev/null +++ b/0006-Do-not-return-1-EINVAL-on-allocation-error.patch @@ -0,0 +1,35 @@ +From 315db1a8aed226a51a4cf700172249cfd10ae115 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Fri, 14 Mar 2014 09:05:56 -0400 +Subject: [PATCH] Do not return -1 (EINVAL) on allocation error + +--- + src/core/socket.c | 8 +++----- + +diff --git src/core/socket.c src/core/socket.c +index 8ecc9f9..b39bec2 100644 +--- src/core/socket.c ++++ src/core/socket.c +@@ -198,16 +198,14 @@ static int socket_instantiate_service(Socket *s) { + + assert(s->accept); + +- if (!(prefix = unit_name_to_prefix(UNIT(s)->id))) ++ prefix = unit_name_to_prefix(UNIT(s)->id); ++ if (!prefix) + return -ENOMEM; + +- r = asprintf(&name, "%s@%u.service", prefix, s->n_accepted); +- +- if (r < 0) ++ if (asprintf(&name, "%s@%u.service", prefix, s->n_accepted) < 0) + return -ENOMEM; + + r = manager_load_unit(UNIT(s)->manager, name, NULL, NULL, &u); +- + if (r < 0) + return r; + +-- +1.7.9.2 + diff --git a/0006-sd-event-initialization-perturbation-value-right-bef.patch b/0006-sd-event-initialization-perturbation-value-right-bef.patch new file mode 100644 index 00000000..a561cabb --- /dev/null +++ b/0006-sd-event-initialization-perturbation-value-right-bef.patch @@ -0,0 +1,75 @@ +From 52444dc478fe38b5b69a771923ab429a41927aa5 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 24 Mar 2014 23:54:21 +0100 +Subject: [PATCH] sd-event: initialization perturbation value right before we + use it + +That way, we don't forget to initialize it when the watchdog is +initialized before all event sources. +--- + src/libsystemd/sd-event/sd-event.c | 34 +++++++++++++++++++++------------- + 1 file changed, 21 insertions(+), 13 deletions(-) + +--- src/libsystemd/sd-event/sd-event.c ++++ src/libsystemd/sd-event/sd-event.c 2014-03-28 12:44:05.652327044 +0000 +@@ -648,13 +648,31 @@ _public_ int sd_event_add_io( + return 0; + } + ++static void initialize_perturb(sd_event *e) { ++ sd_id128_t bootid = {}; ++ ++ /* When we sleep for longer, we try to realign the wakeup to ++ the same time wihtin each minute/second/250ms, so that ++ events all across the system can be coalesced into a single ++ CPU wakeup. However, let's take some system-specific ++ randomness for this value, so that in a network of systems ++ with synced clocks timer events are distributed a ++ bit. Here, we calculate a perturbation usec offset from the ++ boot ID. */ ++ ++ if (_likely_(e->perturb != (usec_t) -1)) ++ return; ++ ++ if (sd_id128_get_boot(&bootid) >= 0) ++ e->perturb = (bootid.qwords[0] ^ bootid.qwords[1]) % USEC_PER_MINUTE; ++} ++ + static int event_setup_timer_fd( + sd_event *e, + EventSourceType type, + int *timer_fd, + clockid_t id) { + +- sd_id128_t bootid = {}; + struct epoll_event ev = {}; + int r, fd; + +@@ -677,18 +695,6 @@ static int event_setup_timer_fd( + return -errno; + } + +- /* When we sleep for longer, we try to realign the wakeup to +- the same time wihtin each minute/second/250ms, so that +- events all across the system can be coalesced into a single +- CPU wakeup. However, let's take some system-specific +- randomness for this value, so that in a network of systems +- with synced clocks timer events are distributed a +- bit. Here, we calculate a perturbation usec offset from the +- boot ID. */ +- +- if (sd_id128_get_boot(&bootid) >= 0) +- e->perturb = (bootid.qwords[0] ^ bootid.qwords[1]) % USEC_PER_MINUTE; +- + *timer_fd = fd; + return 0; + } +@@ -1506,6 +1512,8 @@ static usec_t sleep_between(sd_event *e, + if (b <= a + 1) + return a; + ++ initialize_perturb(e); ++ + /* + Find a good time to wake up again between times a and b. We + have two goals here: diff --git a/0007-networkd-fix-typo.patch b/0007-networkd-fix-typo.patch new file mode 100644 index 00000000..8bd67322 --- /dev/null +++ b/0007-networkd-fix-typo.patch @@ -0,0 +1,26 @@ +From eed0eee85ac34abd81cd9e81fdb6a19f47b6c8a3 Mon Sep 17 00:00:00 2001 +From: Michael Olbrich +Date: Fri, 14 Mar 2014 18:19:29 +0100 +Subject: [PATCH] networkd: fix typo + +It's HAVE_SPLIT_USR not HAVE_SPLIT_USER +--- + src/network/networkd-manager.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git src/network/networkd-manager.c src/network/networkd-manager.c +index c730e71..ea414b1 100644 +--- src/network/networkd-manager.c ++++ src/network/networkd-manager.c +@@ -33,7 +33,7 @@ const char* const network_dirs[] = { + "/etc/systemd/network", + "/run/systemd/network", + "/usr/lib/systemd/network", +-#ifdef HAVE_SPLIT_USER ++#ifdef HAVE_SPLIT_USR + "/lib/systemd/network", + #endif + NULL}; +-- +1.7.9.2 + diff --git a/0007-sd-event-don-t-accidentally-turn-of-watchdog-timer-e.patch b/0007-sd-event-don-t-accidentally-turn-of-watchdog-timer-e.patch new file mode 100644 index 00000000..ee4c169a --- /dev/null +++ b/0007-sd-event-don-t-accidentally-turn-of-watchdog-timer-e.patch @@ -0,0 +1,29 @@ +From 75145780813957ecbe6835f2c8bc20113a3605d2 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 25 Mar 2014 00:01:51 +0100 +Subject: [PATCH] sd-event: don't accidentally turn of watchdog timer event if + we determine 0 + +--- + src/libsystemd/sd-event/sd-event.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git src/libsystemd/sd-event/sd-event.c src/libsystemd/sd-event/sd-event.c +index d6a3d1c..4aabec1 100644 +--- src/libsystemd/sd-event/sd-event.c ++++ src/libsystemd/sd-event/sd-event.c +@@ -2087,6 +2087,11 @@ static int arm_watchdog(sd_event *e) { + + timespec_store(&its.it_value, t); + ++ /* Make sure we never set the watchdog to 0, which tells the ++ * kernel to disable it. */ ++ if (its.it_value.tv_sec == 0 && its.it_value.tv_nsec == 0) ++ its.it_value.tv_nsec = 1; ++ + r = timerfd_settime(e->watchdog_fd, TFD_TIMER_ABSTIME, &its, NULL); + if (r < 0) + return -errno; +-- +1.7.9.2 + diff --git a/0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch b/0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch new file mode 100644 index 00000000..d2eac44b --- /dev/null +++ b/0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch @@ -0,0 +1,27 @@ +From bbb6ff0216a7c081a2e63e01b1f121592b0165bb Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 14 Mar 2014 21:12:36 +0100 +Subject: [PATCH] sd-bus: don't access invalid memory if a signal matcher was + freed from its own callback + +--- + src/libsystemd/sd-bus/bus-match.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git src/libsystemd/sd-bus/bus-match.c src/libsystemd/sd-bus/bus-match.c +index 8280488..c54ca8d 100644 +--- src/libsystemd/sd-bus/bus-match.c ++++ src/libsystemd/sd-bus/bus-match.c +@@ -293,6 +293,9 @@ int bus_match_run( + r = bus_maybe_reply_error(m, r, &error_buffer); + if (r != 0) + return r; ++ ++ if (bus && bus->match_callbacks_modified) ++ return 0; + } + + return bus_match_run(bus, node->next, m); +-- +1.7.9.2 + diff --git a/0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch b/0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch new file mode 100644 index 00000000..b4564a5a --- /dev/null +++ b/0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch @@ -0,0 +1,53 @@ +From 0088d63151e088d62104d88f866e9eb049091c22 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 25 Mar 2014 00:31:48 +0100 +Subject: [PATCH] systemctl: --kill-mode is long long gone, don't mention it + in the man page + +--- + man/systemctl.xml | 5 ++--- + shell-completion/bash/systemctl | 5 +---- + 2 files changed, 3 insertions(+), 7 deletions(-) + +diff --git man/systemctl.xml man/systemctl.xml +index 77447dd..b4727d9 100644 +--- man/systemctl.xml ++++ man/systemctl.xml +@@ -664,9 +664,8 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service + + Send a signal to one or more processes of the + unit. Use to select which +- process to kill. Use to select +- the kill mode and to select the +- signal to send. ++ process to kill. Use to select ++ the signal to send. + + + +diff --git shell-completion/bash/systemctl shell-completion/bash/systemctl +index dc7ef66..0dfc868 100644 +--- shell-completion/bash/systemctl ++++ shell-completion/bash/systemctl +@@ -74,7 +74,7 @@ _systemctl () { + [STANDALONE]='--all -a --reverse --after --before --defaults --fail --ignore-dependencies --failed --force -f --full -l --global + --help -h --no-ask-password --no-block --no-legend --no-pager --no-reload --no-wall + --quiet -q --privileged -P --system --user --version --runtime' +- [ARG]='--host -H --kill-mode --kill-who --property -p --signal -s --type -t --state --root' ++ [ARG]='--host -H --kill-who --property -p --signal -s --type -t --state --root' + ) + + if __contains_word "--user" ${COMP_WORDS[*]}; then +@@ -99,9 +99,6 @@ _systemctl () { + --kill-who) + comps='all control main' + ;; +- --kill-mode) +- comps='control-group process' +- ;; + --root) + comps=$(compgen -A directory -- "$cur" ) + compopt -o filenames +-- +1.7.9.2 + diff --git a/0009-ask-password-when-the-user-types-a-overly-long-passw.patch b/0009-ask-password-when-the-user-types-a-overly-long-passw.patch new file mode 100644 index 00000000..840c4a18 --- /dev/null +++ b/0009-ask-password-when-the-user-types-a-overly-long-passw.patch @@ -0,0 +1,33 @@ +From 036eeac5a1799fa2c0ae11a14d8c667b5d303189 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 25 Mar 2014 01:27:05 +0100 +Subject: [PATCH] ask-password: when the user types a overly long password, + beep and refuse +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Based on a similar patch from David Härdeman. +--- + src/shared/ask-password-api.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git src/shared/ask-password-api.c src/shared/ask-password-api.c +index 117f0c6..96f16cc 100644 +--- src/shared/ask-password-api.c ++++ src/shared/ask-password-api.c +@@ -207,6 +207,11 @@ int ask_password_tty( + if (ttyfd >= 0) + loop_write(ttyfd, "(no echo) ", 10, false); + } else { ++ if (p >= sizeof(passphrase)-1) { ++ loop_write(ttyfd, "\a", 1, false); ++ continue; ++ } ++ + passphrase[p++] = c; + + if (!silent_mode && ttyfd >= 0) +-- +1.7.9.2 + diff --git a/0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch b/0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch new file mode 100644 index 00000000..f9e93696 --- /dev/null +++ b/0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch @@ -0,0 +1,47 @@ +From 5a4d665ad679a8436f1210ba67d713a8f0b91b96 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 14 Mar 2014 21:15:32 +0100 +Subject: [PATCH] sd-bus: don't choke if somebody sends us a message with a + unix fd count of 0 + +It's kinda pointless to include a unix fd header field in messages if it +carries the value 0, but let's do this anyway... +--- + src/libsystemd/sd-bus/bus-message.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git src/libsystemd/sd-bus/bus-message.c src/libsystemd/sd-bus/bus-message.c +index 97ab0e3..b9d7f6d 100644 +--- src/libsystemd/sd-bus/bus-message.c ++++ src/libsystemd/sd-bus/bus-message.c +@@ -4885,6 +4885,7 @@ int bus_message_parse_fields(sd_bus_message *m) { + size_t ri; + int r; + uint32_t unix_fds = 0; ++ bool unix_fds_set = false; + void *offsets = NULL; + unsigned n_offsets = 0; + size_t sz = 0; +@@ -5097,7 +5098,7 @@ int bus_message_parse_fields(sd_bus_message *m) { + } + + case BUS_MESSAGE_HEADER_UNIX_FDS: +- if (unix_fds != 0) ++ if (unix_fds_set) + return -EBADMSG; + + if (!streq(signature, "u")) +@@ -5107,9 +5108,7 @@ int bus_message_parse_fields(sd_bus_message *m) { + if (r < 0) + return -EBADMSG; + +- if (unix_fds == 0) +- return -EBADMSG; +- ++ unix_fds_set = true; + break; + + default: +-- +1.7.9.2 + diff --git a/0012-journald-remove-stray-reset-of-error-return-value.patch b/0012-journald-remove-stray-reset-of-error-return-value.patch new file mode 100644 index 00000000..f15237f7 --- /dev/null +++ b/0012-journald-remove-stray-reset-of-error-return-value.patch @@ -0,0 +1,24 @@ +From 2fc74bf4336eb7a7e40c0b355d19966cd97d4b3c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Mon, 10 Mar 2014 21:19:23 -0400 +Subject: [PATCH] journald: remove stray reset of error return value + +--- + src/journal/journald.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git src/journal/journald.c src/journal/journald.c +index 37896d0..c8c0801 100644 +--- src/journal/journald.c ++++ src/journal/journald.c +@@ -110,7 +110,6 @@ int main(int argc, char *argv[]) { + r = sd_event_run(server.event, t); + if (r < 0) { + log_error("Failed to run event loop: %s", strerror(-r)); +- r = -errno; + goto finish; + } + +-- +1.7.9.2 + diff --git a/0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch b/0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch new file mode 100644 index 00000000..0343c2ad --- /dev/null +++ b/0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch @@ -0,0 +1,118 @@ +From 6f285378aa6e4b5b23c939d1fea16f9ab0a57efb Mon Sep 17 00:00:00 2001 +From: Miklos Vajna +Date: Fri, 14 Mar 2014 21:13:38 +0100 +Subject: [PATCH] core, libsystemd, systemd, timedate, udev: spelling fixes + +--- + src/core/service.c | 2 +- + src/core/unit.c | 2 +- + src/libsystemd/sd-bus/bus-message.c | 2 +- + src/libsystemd/sd-bus/sd-bus.c | 4 ++-- + src/systemd/sd-resolve.h | 2 +- + src/timedate/timedated.c | 2 +- + src/udev/udevadm-settle.c | 2 +- + 7 files changed, 8 insertions(+), 8 deletions(-) + +diff --git src/core/service.c src/core/service.c +index 41b95ab..386692a 100644 +--- src/core/service.c ++++ src/core/service.c +@@ -3416,7 +3416,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { + free(t); + } + +- /* Interpet WATCHDOG= */ ++ /* Interpret WATCHDOG= */ + if (strv_find(tags, "WATCHDOG=1")) { + log_debug_unit(u->id, "%s: got WATCHDOG=1", u->id); + service_reset_watchdog(s); +diff --git src/core/unit.c src/core/unit.c +index 5c98843..4fb0d9c 100644 +--- src/core/unit.c ++++ src/core/unit.c +@@ -1537,7 +1537,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su + unit_destroy_cgroup(u); + + /* Note that this doesn't apply to RemainAfterExit services exiting +- * sucessfully, since there's no change of state in that case. Which is ++ * successfully, since there's no change of state in that case. Which is + * why it is handled in service_set_state() */ + if (UNIT_IS_INACTIVE_OR_FAILED(os) != UNIT_IS_INACTIVE_OR_FAILED(ns)) { + ExecContext *ec; +diff --git src/libsystemd/sd-bus/bus-message.c src/libsystemd/sd-bus/bus-message.c +index b9d7f6d..e32f2b8 100644 +--- src/libsystemd/sd-bus/bus-message.c ++++ src/libsystemd/sd-bus/bus-message.c +@@ -4215,7 +4215,7 @@ static int message_read_ap( + * in a single stackframe. We hence implement our own + * home-grown stack in an array. */ + +- n_array = (unsigned) -1; /* lenght of current array entries */ ++ n_array = (unsigned) -1; /* length of current array entries */ + n_struct = strlen(types); /* length of current struct contents signature */ + + for (;;) { +diff --git src/libsystemd/sd-bus/sd-bus.c src/libsystemd/sd-bus/sd-bus.c +index 8e44e50..ba8a8a2 100644 +--- src/libsystemd/sd-bus/sd-bus.c ++++ src/libsystemd/sd-bus/sd-bus.c +@@ -1447,7 +1447,7 @@ static int bus_seal_message(sd_bus *b, sd_bus_message *m, usec_t timeout) { + static int bus_remarshal_message(sd_bus *b, sd_bus_message **m) { + assert(b); + +- /* Do packet version and endianess already match? */ ++ /* Do packet version and endianness already match? */ + if ((b->message_version == 0 || b->message_version == (*m)->header->version) && + (b->message_endian == 0 || b->message_endian == (*m)->header->endian)) + return 0; +@@ -1464,7 +1464,7 @@ int bus_seal_synthetic_message(sd_bus *b, sd_bus_message *m) { + * hence let's fill something in for synthetic messages. Since + * synthetic messages might have a fake sender and we don't + * want to interfere with the real sender's serial numbers we +- * pick a fixed, artifical one. We use (uint32_t) -1 rather ++ * pick a fixed, artificial one. We use (uint32_t) -1 rather + * than (uint64_t) -1 since dbus1 only had 32bit identifiers, + * even though kdbus can do 64bit. */ + +diff --git src/systemd/sd-resolve.h src/systemd/sd-resolve.h +index df69e4b..3c1d482 100644 +--- src/systemd/sd-resolve.h ++++ src/systemd/sd-resolve.h +@@ -129,7 +129,7 @@ int sd_resolve_get_next(sd_resolve *resolve, sd_resolve_query **q); + int sd_resolve_get_n_queries(sd_resolve *resolve); + + /** Cancel a currently running query. q is is destroyed by this call +- * and may not be used any futher. */ ++ * and may not be used any further. */ + int sd_resolve_cancel(sd_resolve_query* q); + + /** Returns non-zero when the query operation specified by q has been completed */ +diff --git src/timedate/timedated.c src/timedate/timedated.c +index d85ce57..c4a797a 100644 +--- src/timedate/timedated.c ++++ src/timedate/timedated.c +@@ -468,7 +468,7 @@ static int property_get_rtc_time( + zero(tm); + r = hwclock_get_time(&tm); + if (r == -EBUSY) { +- log_warning("/dev/rtc is busy, is somebody keeping it open continously? That's not a good idea... Returning a bogus RTC timestamp."); ++ log_warning("/dev/rtc is busy, is somebody keeping it open continuously? That's not a good idea... Returning a bogus RTC timestamp."); + t = 0; + } else if (r == -ENOENT) { + log_debug("Not /dev/rtc found."); +diff --git src/udev/udevadm-settle.c src/udev/udevadm-settle.c +index b026155..927ea2a 100644 +--- src/udev/udevadm-settle.c ++++ src/udev/udevadm-settle.c +@@ -100,7 +100,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) + case '?': + exit(EXIT_FAILURE); + default: +- assert_not_reached("Unkown argument"); ++ assert_not_reached("Unknown argument"); + } + + if (optind < argc) { +-- +1.7.9.2 + diff --git a/1006-udev-always-rename-network.patch b/1006-udev-always-rename-network.patch index 1cbbda78..eb98cc2f 100644 --- a/1006-udev-always-rename-network.patch +++ b/1006-udev-always-rename-network.patch @@ -9,55 +9,69 @@ Date: Tue, 4 Mar 2014 10:29:21 +0000 Port the patch of Robert to systemd v210 and test it out. --- - udev-event.c | 40 ++++++++++++++++++++++++++++++++++++---- - 1 file changed, 36 insertions(+), 4 deletions(-) + udev-event.c | 42 ++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 38 insertions(+), 4 deletions(-) + --- systemd-210/src/udev/udev-event.c -+++ systemd-210/src/udev/udev-event.c 2014-03-04 11:19:50.583710411 +0100 -@@ -765,10 +765,42 @@ static int rename_netif(struct udev_even ++++ systemd-210/src/udev/udev-event.c 2014-03-27 13:19:06.727748307 +0000 +@@ -750,8 +750,9 @@ static int rename_netif(struct udev_even + struct udev_device *dev = event->dev; + _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL; + char name[IFNAMSIZ]; ++ char interim[IFNAMSIZ], *ptr = &interim[0]; + const char *oldname; +- int r; ++ int r, loop; + + oldname = udev_device_get_sysname(dev); + +@@ -765,12 +766,45 @@ static int rename_netif(struct udev_even return r; r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), name); - if (r < 0) -- log_error("error changing net interface name %s to %s: %s", -- oldname, name, strerror(-r)); ++ if (r == 0) { ++ print_kmsg("renamed network interface %s to %s\n", oldname, name); ++ return r; ++ } else if (r != -EEXIST) { + log_error("error changing net interface name %s to %s: %s", + oldname, name, strerror(-r)); - else -+ if (r < 0) { -+ char interim[IFNAMSIZ], *ptr = &interim[0]; -+ int loop = 90; +- print_kmsg("renamed network interface %s to %s", oldname, name); ++ return r; ++ } ++ ++ /* free our own name, another process may wait for us */ ++ strpcpyf(&ptr, IFNAMSIZ, "rename%u", udev_device_get_ifindex(dev)); ++ ++ r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), interim); ++ if (r < 0) { ++ log_error("error changing net interface name %s to %s: %s", ++ oldname, interim, strerror(-r)); ++ return r; ++ } + ++ /* log temporary name */ ++ print_kmsg("renamed network interface %s to %s\n", oldname, interim); ++ ++ loop = 90 * 20; ++ while (loop--) { ++ const struct timespec duration = { 0, 1000 * 1000 * 1000 / 20 }; ++ nanosleep(&duration, NULL); ++ ++ r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), name); ++ if (r == 0) { ++ print_kmsg("renamed network interface %s to %s\n", interim, name); ++ break; ++ } + -+ /* keep trying if the destination interface name already exists */ + if (r != -EEXIST) { + log_error("error changing net interface name %s to %s: %s", -+ oldname, name, strerror(-r)); -+ return r; ++ interim, name, strerror(-r)); ++ break; + } -+ -+ /* free our own name, another process may wait for us */ -+ strpcpyf(&ptr, IFNAMSIZ, "rename%u", udev_device_get_ifindex(dev)); -+ -+ r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), interim); -+ if (r < 0) { -+ log_error("error changing net interface name %s to %s: %s", -+ oldname, name, strerror(-r)); -+ return r; -+ } -+ -+ /* log temporary name */ -+ print_kmsg("renamed network interface %s to %s", oldname, interim); -+ do { -+ r = rtnl_set_link_name(rtnl, udev_device_get_ifindex(dev), name); -+ if (r == 0) { -+ print_kmsg("renamed network interface %s to %s", oldname, name); -+ return r; -+ } -+ if (r != -EEXIST) { -+ log_error("error changing net interface name %s to %s: %s", -+ oldname, name, strerror(-r)); -+ return r; -+ } -+ } while (loop-- > 0); -+ } else - print_kmsg("renamed network interface %s to %s", oldname, name); - ++ } return r; + } + diff --git a/1019-make-completion-smart-to-be-able-to-redirect.patch b/1019-make-completion-smart-to-be-able-to-redirect.patch index 90ca8edc..89d79183 100644 --- a/1019-make-completion-smart-to-be-able-to-redirect.patch +++ b/1019-make-completion-smart-to-be-able-to-redirect.patch @@ -108,7 +108,7 @@ --- systemd-208/shell-completion/bash/systemctl +++ systemd-208/shell-completion/bash/systemctl 2014-01-17 14:35:26.506235666 +0000 @@ -77,6 +77,10 @@ _systemctl () { - [ARG]='--host -H --kill-mode --kill-who --property -p --signal -s --type -t --state --root' + [ARG]='--host -H --kill-who --property -p --signal -s --type -t --state --root' ) + if __contains_word ">" ${COMP_WORDS[*]:0:COMP_CWORD}; then diff --git a/avoid-random-hangs-on-timeouts-due-lost-cwd.patch b/avoid-random-hangs-on-timeouts-due-lost-cwd.patch new file mode 100644 index 00000000..3e11c296 --- /dev/null +++ b/avoid-random-hangs-on-timeouts-due-lost-cwd.patch @@ -0,0 +1,23 @@ +Found this during debugging an other problem. The issue was that +after ``sudo -i'' and a ``cd /usr/lib/systemd/system/'' followed +later by a shutdown may fail with (journalctl -b -1): + + systemd-exit.service: Failed at step CHDIR spawning: /usr/bin/kill + +which then caused the subsequent fault that umounting the users +home directories done by automount are busy. + +--- systemd-210/units/user/systemd-exit.service.in ++++ systemd-210/units/user/systemd-exit.service.in 2014-03-25 16:59:20.406235916 +0000 +@@ -10,8 +10,9 @@ Description=Exit the Session + Documentation=man:systemd.special(7) + DefaultDependencies=no + Requires=shutdown.target +-After=shutdown.target ++After=shutdown.target multi-user.target + + [Service] + Type=oneshot +-ExecStart=@KILL@ -s 58 $MANAGERPID ++WorkingDirectory=/ ++ExecStart=@KILL@ -s SIGRTMIN+24 $MANAGERPID diff --git a/boot-local-start.patch b/boot-local-start.patch new file mode 100644 index 00000000..2f9e9d55 --- /dev/null +++ b/boot-local-start.patch @@ -0,0 +1,12 @@ +diff -Naur systemd-210/units/rc-local.service.in systemd-210-mod/units/rc-local.service.in +--- systemd-210/units/rc-local.service.in 2013-08-13 22:02:52.788756123 +0200 ++++ systemd-210-mod/units/rc-local.service.in 2014-03-25 08:34:40.317587764 +0100 +@@ -10,7 +10,7 @@ + [Unit] + Description=@RC_LOCAL_SCRIPT_PATH_START@ Compatibility + ConditionFileIsExecutable=@RC_LOCAL_SCRIPT_PATH_START@ +-After=network.target ++After=basic.target + + [Service] + Type=forking diff --git a/pre_checkin.sh b/pre_checkin.sh index 69373260..18706301 100644 --- a/pre_checkin.sh +++ b/pre_checkin.sh @@ -4,18 +4,6 @@ # create a -mini spec for systemd for bootstrapping ORIG_SPEC=systemd -for patch in $(grep -lE 'Makefile.(am|in)|configure\.ac' *.patch) -do - sed -rn 's/^Patch([0-9]+):\s+'${patch}'/patch\1/p' $ORIG_SPEC.spec -done | while read patch -do - grep -1E '^%'${patch}'[^0-9]' $ORIG_SPEC.spec | grep -q bootstrap - if ((${PIPESTATUS[1]} != 0)) - then - echo Patch ${patch} does trigger 'auto(re)configure' 1>&2 - exit 1 - fi -done EDIT_WARNING="##### WARNING: please do not edit this auto generated spec file. Use the ${ORIG_SPEC}.spec! #####\n" sed "s/^%define bootstrap.*$/${EDIT_WARNING}%define bootstrap 1/; s/^%define udevpkgname.*$/${EDIT_WARNING}%define udevpkgname udev-mini/; diff --git a/prepare-suspend-to-disk.patch b/prepare-suspend-to-disk.patch new file mode 100644 index 00000000..01f95f9d --- /dev/null +++ b/prepare-suspend-to-disk.patch @@ -0,0 +1,28 @@ +diff -Naur systemd-210/units/systemd-hibernate.service.in systemd-210-mod/units/systemd-hibernate.service.in +--- systemd-210/units/systemd-hibernate.service.in 2013-08-13 22:02:52.808756274 +0200 ++++ systemd-210-mod/units/systemd-hibernate.service.in 2014-03-25 12:27:44.995995220 +0100 +@@ -11,7 +11,10 @@ + DefaultDependencies=no + Requires=sleep.target + After=sleep.target ++ConditionKernelCommandLine=resume + + [Service] + Type=oneshot ++ExecStart=@rootbindir@/systemd-sleep-grub pre + ExecStart=@rootlibexecdir@/systemd-sleep hibernate ++ExecStopPost=@rootbindir@/systemd-sleep-grub post +diff -Naur systemd-210/units/systemd-hybrid-sleep.service.in systemd-210-mod/units/systemd-hybrid-sleep.service.in +--- systemd-210/units/systemd-hybrid-sleep.service.in 2013-08-13 22:02:52.809756282 +0200 ++++ systemd-210-mod/units/systemd-hybrid-sleep.service.in 2014-03-25 12:27:56.115994902 +0100 +@@ -11,7 +11,10 @@ + DefaultDependencies=no + Requires=sleep.target + After=sleep.target ++ConditionKernelCommandLine=resume + + [Service] + Type=oneshot ++ExecStart=@rootbindir@/systemd-sleep-grub pre + ExecStart=@rootlibexecdir@/systemd-sleep hybrid-sleep ++ExecStopPost=@rootbindir@/systemd-sleep-grub post diff --git a/systemctl-set-default-target.patch b/systemctl-set-default-target.patch new file mode 100644 index 00000000..4dd058d9 --- /dev/null +++ b/systemctl-set-default-target.patch @@ -0,0 +1,28 @@ +Mention that --force is required to override an already existing default.target + +This solves the bug bnc#868439 + +--- + systemctl.xml | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- systemd-210/man/systemctl.xml ++++ systemd-210/man/systemctl.xml 2014-03-19 12:19:53.182235657 +0000 +@@ -371,7 +371,7 @@ along with systemd; If not, see + + +- When used with enable, overwrite ++ When used with enable or set-default, overwrite + any existing conflicting symlinks. + + When used with halt, +@@ -1036,6 +1036,8 @@ kobject-uevent 1 systemd-udevd-kernel.so + + Set the default target to boot into. Command links + default.target to the given unit. ++ If combined with , override ++ an already existing symlink for the default target. + + + diff --git a/systemd-mini.changes b/systemd-mini.changes index 80282770..6e6334de 100644 --- a/systemd-mini.changes +++ b/systemd-mini.changes @@ -1,3 +1,79 @@ +------------------------------------------------------------------- +Fri Mar 28 12:53:21 UTC 2014 - werner@suse.de + +- Add or port upstram bugfix patches: + 0001-cgroup-it-s-not-OK-to-invoke-alloca-in-loops.patch + 0002-machined-fix-Kill-bus-call-on-machine-objects-when-w.patch + 0003-sd-bus-don-t-use-assert_return-to-check-for-disconne.patch + 0004-core-don-t-try-to-relabel-mounts-before-we-loaded-th.patch + 0005-sd-daemon-fix-incorrect-variable-access.patch + 0006-sd-event-initialization-perturbation-value-right-bef.patch + 0007-sd-event-don-t-accidentally-turn-of-watchdog-timer-e.patch + 0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch + 0009-ask-password-when-the-user-types-a-overly-long-passw.patch +- Modify patch + 1019-make-completion-smart-to-be-able-to-redirect.patch + to work together with + 0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch + +------------------------------------------------------------------- +Fri Mar 28 08:10:13 UTC 2014 - werner@suse.de + +- Use Robert's revised 1006-udev-always-rename-network.patch + +------------------------------------------------------------------- +Tue Mar 25 17:28:18 UTC 2014 - werner@suse.de + +- Readd patch Forward-suspend-hibernate-calls-to-pm-utils.patch + older code base as 13.1 only +- Add patch avoid-random-hangs-on-timeouts-due-lost-cwd.patch + to be able to terminate the user manager even if cwd of the + user is gone + +------------------------------------------------------------------- +Tue Mar 25 13:08:56 UTC 2014 - thomas.blume@suse.com + +- add prepare-suspend-to-disk.patch + enable suspend conditions check and preparation for systemd-sleep + (fate#316824, bnc#856389, bnc#856392) +- remove Forward-suspend-hibernate-calls-to-pm-utils.patch since it is obsolete + (bnc#856392#c20) +- add boot-local-start.patch + fix startup for /etc/init.d/boot.local (bnc#869142) + +------------------------------------------------------------------- +Mon Mar 24 11:19:38 UTC 2014 - coolo@suse.com + +- also autoreconf in systemd-mini to simplify spec file logic + and fix build in staging:gcc49 + (obsoleting 0002-make-209-working-on-older-dist.patch) + +------------------------------------------------------------------- +Wed Mar 19 13:21:37 UTC 2014 - werner@suse.de + +- Be sure that the refreshed manual pages are installed + +------------------------------------------------------------------- +Wed Mar 19 12:09:31 UTC 2014 - werner@suse.de + +- Add patch systemctl-set-default-target.patch which explain how + to override the default.target by using --force (bnc#868439) + +------------------------------------------------------------------- +Tue Mar 18 13:23:43 UTC 2014 - werner@suse.de + +- Add Robert's udev-generate-peristent-rule shell script to + udev's tool library +- Add or port upstram bugfix patches: + 0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch + 0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch + 0006-Do-not-return-1-EINVAL-on-allocation-error.patch + 0007-networkd-fix-typo.patch + 0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch + 0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch + 0012-journald-remove-stray-reset-of-error-return-value.patch + 0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch + ------------------------------------------------------------------- Fri Mar 14 14:24:56 UTC 2014 - werner@suse.de @@ -789,7 +865,7 @@ Fri Dec 20 12:06:18 UTC 2013 - werner@suse.de - Change patch 1012-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch to check if XDG_RUNTIME_DIR is set before the call of pam_putenv() - may fix bnc#855160 + may fix bnc#855160 ------------------------------------------------------------------- Fri Dec 20 09:40:01 UTC 2013 - lbsousajr@gmail.com diff --git a/systemd-mini.spec b/systemd-mini.spec index c554b30a..1a24806d 100644 --- a/systemd-mini.spec +++ b/systemd-mini.spec @@ -149,21 +149,9 @@ Source11: after-local.service Source1060: boot.udev Source1061: write_dev_root_rule Source1062: systemd-udev-root-symlink +Source1063: udev-generate-peristent-rule.sh +Source1064: systemd-sleep-grub -############################################################################## -# -# WARNING: For the case of for bootstrapping patch should not affect -# the files -# -# Makefile.am, Makefile.in, and configure.ac -# -# as this triggers an (re)autoconfigure. Please check patches with the command -# -# grep -lE 'Makefile.(am|in)|configure\.ac' *.patch -# -# to surround them with %if ! 0%{?bootstrap} ... %endif -# -############################################################################## # # PATCH-FIX-UPSTREAM avoid-assertion-if-invalid-address-familily-is-passed-to-g.patch lnussel@suse.com bnc#791101 -- avoid assertion if invalid address familily is passed to gethostbyaddr_r Patch0: avoid-assertion-if-invalid-address-familily-is-passed-to-g.patch @@ -215,7 +203,7 @@ Patch42: systemd-pam_config.patch Patch23: disable-nss-myhostname-warning-bnc-783841.patch # PATCH-FIX-OPENSUSE handle-HOSTNAME.patch fcrozat@suse.com -- handle /etc/HOSTNAME (bnc#803653) Patch24: handle-etc-HOSTNAME.patch -# PATCH-FIX-OPENSUSE Forward-suspend-hibernate-calls-to-pm-utils.patch fcrozat@suse.com bnc#790157 -- forward to pm-utils +# PATCH-FIX-OPENSUSE forward to pm-utils -- for code base <= 1310 Patch25: Forward-suspend-hibernate-calls-to-pm-utils.patch # PATCH-FIX-UPSTREAM rules-add-lid-switch-of-ARM-based-Chromebook-as-a-power-sw.patch rjschwei@suse.com -- add lid switch of ARM based Chromebook as a power switch to logind Patch38: rules-add-lid-switch-of-ARM-based-Chromebook-as-a-power-sw.patch @@ -237,7 +225,6 @@ Patch93: 0001-Don-t-snprintf-a-potentially-NULL-pointer.patch Patch114: 0001-systemd-empty-sigmask-on-reexec.patch # PATCH-FIX-SUSE 0001-make-209-working-on-older-dist.patch werner@suse.com Patch117: 0001-make-209-working-on-older-dist.patch -Patch118: 0002-make-209-working-on-older-dist.patch # PATCH-FIX-SUSE 0001-make-fortify-happy-with-ppoll.patch werner@suse.com Patch119: 0001-make-fortify-happy-with-ppoll.patch # PATCH-FIX-SUSE 0001-avoid-abort-due-timeout-at-user-service.patch werner@suse.com @@ -308,6 +295,40 @@ Patch151: 0005-logind-fix-policykit-checks.patch Patch152: 0006-rules-mark-loop-device-as-SYSTEMD_READY-0-if-no-file.patch # PATCH-FIX-USTREAM added at 2014/03/11 Patch153: 0008-man-multiple-sleep-modes-are-to-be-separated-by-whit.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch154: 0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch155: 0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch157: 0006-Do-not-return-1-EINVAL-on-allocation-error.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch158: 0007-networkd-fix-typo.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch159: 0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch160: 0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch161: 0012-journald-remove-stray-reset-of-error-return-value.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch162: 0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch163: 0001-cgroup-it-s-not-OK-to-invoke-alloca-in-loops.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch164: 0002-machined-fix-Kill-bus-call-on-machine-objects-when-w.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch165: 0003-sd-bus-don-t-use-assert_return-to-check-for-disconne.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch166: 0004-core-don-t-try-to-relabel-mounts-before-we-loaded-th.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch167: 0005-sd-daemon-fix-incorrect-variable-access.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch168: 0006-sd-event-initialization-perturbation-value-right-bef.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch169: 0007-sd-event-don-t-accidentally-turn-of-watchdog-timer-e.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch170: 0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch171: 0009-ask-password-when-the-user-types-a-overly-long-passw.patch # PATCH-FIX-OPENSUSE 1009-make-xsltproc-use-correct-ROFF-links.patch -- Make ROFF links working again in manual pages (bnc#842844) Patch1009: 1009-make-xsltproc-use-correct-ROFF-links.patch # PATCH-FIX-OPENSUSE 1010-do-not-install-sulogin-unit-with-poweroff.patch -- Avoid installing console-shell.service (bnc#849071) @@ -326,6 +347,15 @@ Patch1020: 0001-add-network-device-after-NFS-mount-units.patch Patch1022: 1022-systemd-tmpfiles-ownerkeep.patch # PATCH-FIX-SUSE systemd-powerd-initctl-support.patch Patch1023: systemd-powerd-initctl-support.patch +# PATCH-FIX-SUSE systemctl-set-default-target.patch +Patch1024: systemctl-set-default-target.patch +# PATCH-FIX-SUSE prepare-suspend-to-disk.patch (fate #316824) +Patch1025: prepare-suspend-to-disk.patch +# PATCH-FIX-SUSE boot-local-start.patch (bnc #869142) +Patch1026: boot-local-start.patch +# PATCH-FIX-SUSE avoid random hangs on timeouts due lost cwd at terminating user manager +Patch1027: avoid-random-hangs-on-timeouts-due-lost-cwd.patch + # PATCH-FIX-SUSE systemd-install-compat_pkgconfig-always.patch Patch1999: systemd-install-compat_pkgconfig-always.patch # PATCH-FIX-OPENSUSE systemd-dbus-system-bus-address.patch always use /run/dbus not /var/run @@ -560,18 +590,11 @@ cp %{SOURCE7} m4/ # systemd patches %patch0 -p1 -%if ! 0%{?bootstrap} %patch1 -p1 -%endif %patch3 -p1 -# don't apply when bootstrapping to not modify configure.in -%if ! 0%{?bootstrap} %patch4 -p1 -%endif %patch5 -p1 -%if ! 0%{?bootstrap} %patch6 -p1 -%endif %patch7 -p1 %patch8 -p1 %patch9 -p1 @@ -581,9 +604,7 @@ cp %{SOURCE7} m4/ %patch14 -p1 %patch15 -p1 %patch16 -p1 -%if ! 0%{?bootstrap} %patch17 -p1 -%endif %patch18 -p1 %patch19 -p1 %patch20 -p1 @@ -591,7 +612,9 @@ cp %{SOURCE7} m4/ %patch22 -p1 %patch23 -p1 %patch24 -p1 +%if 0%{?suse_version} <= 1310 %patch25 -p1 +%endif # check if this is still needed, or can be derived from fbdev uaccess rule # http://lists.freedesktop.org/archives/systemd-devel/2012-November/007561.html %patch27 -p1 @@ -606,19 +629,13 @@ cp %{SOURCE7} m4/ %patch46 -p1 %patch47 -p1 %patch84 -p1 -%if ! 0%{?bootstrap} %patch86 -p1 -%endif %patch90 -p1 %patch91 -p1 %patch93 -p1 %patch114 -p0 %if 0%{?suse_version} <= 1310 -%if ! 0%{?bootstrap} %patch117 -p1 -%else -%patch118 -p1 -%endif %endif %patch119 -p1 %patch120 -p1 @@ -635,9 +652,7 @@ cp %{SOURCE7} m4/ %patch131 -p0 %patch132 -p0 %patch133 -p0 -%if ! 0%{?bootstrap} %patch134 -p0 -%endif %patch135 -p0 %patch136 -p0 %patch137 -p0 @@ -657,24 +672,39 @@ cp %{SOURCE7} m4/ %patch151 -p0 %patch152 -p0 %patch153 -p0 +%patch154 -p0 +%patch155 -p0 +%patch157 -p0 +%patch158 -p0 +%patch159 -p0 +%patch160 -p0 +%patch161 -p0 +%patch162 -p0 +%patch163 -p0 +%patch164 -p0 +%patch165 -p0 +%patch166 -p0 +%patch167 -p0 +%patch168 -p0 +%patch169 -p0 +%patch170 -p0 +%patch171 -p0 %patch1009 -p1 %patch1010 -p1 %patch1012 -p1 %patch1014 -p1 %patch1018 -p1 %patch1019 -p1 -%if ! 0%{?bootstrap} %patch1020 -p1 -%endif %patch1022 -p1 %patch1023 -p1 -%if ! 0%{?bootstrap} +%patch1024 -p1 +%patch1025 -p1 +%patch1026 -p1 +%patch1027 -p1 %patch1999 -p1 -%endif %patch2000 -p1 -%if ! 0%{?bootstrap} %patch2001 -p1 -%endif # udev patches %patch1034 -p0 %patch1035 -p0 @@ -683,23 +713,16 @@ cp %{SOURCE7} m4/ %patch1003 -p1 %patch1005 -p1 %patch1006 -p1 -# don't apply when bootstrapping to not modify Makefile.am -%if ! 0%{?bootstrap} %patch1007 -p1 -%endif %if 0%{?suse_version} <= 1310 -%if ! 0%{?bootstrap} %patch1008 -p1 %endif -%endif # ensure generate files are removed rm -f units/emergency.service %build -%if ! 0%{?bootstrap} autoreconf -fiv -%endif # prevent pre-generated and distributed files from re-building find . -name "*.[1-8]" -exec touch '{}' '+'; export V=1 @@ -744,8 +767,24 @@ export V=1 --disable-kdbus \ CFLAGS="%{optflags}" make %{?_smp_mflags} +%if ! 0%{?bootstrap} +make %{?_smp_mflags} update-man-list man +%endif %install +# Use refreshed manual pages +for man in man/*.[0-9] +do + section=${man##*.} + test -d man/man${section} || continue + new=man/man${section}/${man##*/} + if test -s $new -a $new -nt $man + then + cp -p $new $man + else + sed -ri 's@"(systemd) 209"@"\1 %{version}"@' $man + fi +done make install DESTDIR="%buildroot" # move to %{_lib} @@ -776,6 +815,8 @@ sed -ie "s|@@PREFIX@@|%{_bindir}|g" %{S:1061} install -m755 -D %{S:1061} %{buildroot}/%{_prefix}/lib/udev/write_dev_root_rule sed -ie "s|@@PREFIX@@|%{_prefix}/lib/udev|g" %{S:1062} install -m644 -D %{S:1062} %{buildroot}/%{_prefix}/lib/systemd/system/systemd-udev-root-symlink.service +install -m755 -D %{S:1063} %{buildroot}/%{_prefix}/lib/udev/udev-generate-peristent-rule +install -m755 -D %{S:1064} %{buildroot}/%{_bindir}/systemd-sleep-grub mkdir -p %{buildroot}/%{_prefix}/lib/systemd/system/basic.target.wants ln -sf ../systemd-udev-root-symlink.service %{buildroot}/%{_prefix}/lib/systemd/system/basic.target.wants rm -rf %{buildroot}%{_sysconfdir}/rpm @@ -1112,6 +1153,7 @@ exit 0 /bin/systemd /bin/systemd-ask-password /bin/systemctl +%{_bindir}/systemd-sleep-grub %{_bindir}/bootctl %{_bindir}/busctl %{_bindir}/kernel-install @@ -1205,9 +1247,7 @@ exit 0 %{_prefix}/lib/systemd/system-generators/systemd-rc-local-generator %{_prefix}/lib/systemd/system-generators/systemd-fstab-generator %{_prefix}/lib/systemd/system-generators/systemd-system-update-generator -%if ! 0%{?bootstrap} %{_prefix}/lib/systemd/system-generators/systemd-insserv-generator -%endif %{_prefix}/lib/systemd/system-generators/systemd-gpt-auto-generator /%{_lib}/security/pam_systemd.so /etc/pam.d/systemd-user @@ -1293,9 +1333,7 @@ exit 0 %{_prefix}/lib/udev/rules.d/73-seat-numlock.rules %endif %{_prefix}/lib/udev/rules.d/99-systemd.rules -%if ! 0%{?bootstrap} %{_prefix}/lib/udev/numlock-on -%endif %if 0%{suse_version} < 1310 %{_sysconfdir}/rpm/macros.systemd %endif @@ -1376,6 +1414,7 @@ exit 0 %{_prefix}/lib/udev/scsi_id %{_prefix}/lib/udev/v4l_id %{_prefix}/lib/udev/write_dev_root_rule +%{_prefix}/lib/udev/udev-generate-peristent-rule %dir %{_prefix}/lib/udev/rules.d/ %exclude %{_prefix}/lib/udev/rules.d/70-uaccess.rules %exclude %{_prefix}/lib/udev/rules.d/71-seat.rules diff --git a/systemd-sleep-grub b/systemd-sleep-grub new file mode 100644 index 00000000..beeed387 --- /dev/null +++ b/systemd-sleep-grub @@ -0,0 +1,204 @@ +#!/bin/bash +# +# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. + +set -x + +prepare-parameters() +{ + eval `grep LOADER_TYPE= /etc/sysconfig/bootloader` + + if [ x"$LOADER_TYPE" = "xgrub2" -o x"$LOADER_TYPE" = "xgrub2-efi" ]; then + GRUBONCE="/usr/sbin/grub2-once" + GRUBDEFAULT="/boot/grub2/grubenv" + GRUB2EDITENV="/usr/bin/grub2-editenv" + GRUB2CONF="/boot/grub2/grub.cfg" + BLKID="/usr/sbin/blkid" + getkernels="getkernels-grub2" + fi +} + +##################################################################### +# gets a list of available kernels from /boot/grub2/grub.cfg +# kernels are in the array $KERNELS, output to stdout to be eval-ed. +getkernels-grub2() +{ + local I DUMMY MNT ROOTDEV + declare -i I=0 J=-1 + + # we need the root partition later to decide if this is the kernel to select + while read ROOTDEV MNT DUMMY; do + [ "$ROOTDEV" = "rootfs" ] && continue # not what we are searching for + if [ "$MNT" = "/" ]; then + break + fi + done < /proc/mounts + + while read LINE; do + case $LINE in + menuentry\ *) + let J++ + ;; + set\ default*) + local DEFAULT=${LINE#*default=} + + if echo $DEFAULT | grep -q saved_entry ; then + local SAVED=`$GRUB2EDITENV $GRUBDEFAULT list | sed -n s/^saved_entry=//p` + if [ -n "$SAVED" ]; then + DEFAULT_BOOT=$($GRUBONCE --show-mapped "$SAVED") + fi + fi + + ;; + linux*noresume*) + echo " Skipping grub entry #${J}, because it has the noresume option" >&2 + ;; + linux*root=*) + local ROOT + ROOT=${LINE#*root=} + DUMMY=($ROOT) + ROOT=${DUMMY[0]} + + if [ x"${ROOT:0:5}" = "xUUID=" ]; then + UUID=${ROOT#UUID=} + if [ -n "$UUID" ]; then + ROOT=$($BLKID -U $UUID) + fi + fi + + if [ "$(stat -Lc '%t:%T' $ROOT)" != "$(stat -Lc '%t:%T' $ROOTDEV)" ]; then + echo " Skipping grub entry #${J}, because its root= parameter ($ROOT)" >&2 + echo " does not match the current root device ($ROOTDEV)." >&2 + continue + fi + DUMMY=($LINE) # kernel (hd0,1)/boot/vmlinuz-ABC root=/dev/hda2 + echo "KERNELS[$I]='${DUMMY[1]##*/}'" # vmlinuz-ABC + echo "MENU_ENTRIES[$I]=$J" + # DEBUG "Found kernel entry #${I}: '${DUMMY[1]##*/}'" INFO + let I++ + ;; + linux*) + # a kernel without "root="? We better skip that one... + echo " Skipping grub entry #${J}, because it has no root= option" >&2 + ;; + *) ;; + esac + done < "$GRUB2CONF" +} + +############################################################# +# runs grubonce from the grub package to select which kernel +# to boot on next startup +grub-once() +{ + if [ -x "$GRUBONCE" ]; then + echo " running '$GRUBONCE $1'" + $GRUBONCE $1 + else + echo "WARNING: $GRUBONCE not found, not preparing bootloader" + fi +} + +############################################################# +# restore grub default after (eventually failed) resume +grub-once-restore() +{ + echo "INFO: running grub-once-restore" + prepare-parameters + $GRUB2EDITENV $GRUBDEFAULT unset next_entry +} + +############################################################################# +# try to find a kernel image that matches the actually running kernel. +# We need this, if more than one kernel is installed. This works reasonably +# well with grub, if all kernels are named "vmlinuz-`uname -r`" and are +# located in /boot. If they are not, good luck ;-) +find-kernel-entry() +{ + NEXT_BOOT=-1 + ARCH=`uname -m` + declare -i I=0 + # DEBUG "running kernel: $RUNNING" DIAG + while [ -n "${KERNELS[$I]}" ]; do + BOOTING="${KERNELS[$I]}" + if IMAGE=`readlink /boot/$BOOTING` && [ -e "/boot/${IMAGE##*/}" ]; then + # DEBUG "Found kernel symlink $BOOTING => $IMAGE" INFO + BOOTING=$IMAGE + fi + case $ARCH in + ppc*) BOOTING="${BOOTING#*vmlinux-}" ;; + *) BOOTING="${BOOTING#*vmlinuz-}" ;; + esac + if [ "$RUNNING" == "$BOOTING" ]; then + NEXT_BOOT=${MENU_ENTRIES[$I]} + echo " running kernel is grub menu entry $NEXT_BOOT (${KERNELS[$I]})" + break + fi + let I++ + done + # if we have not found a kernel, issue a warning. + # if we have found a kernel, we'll do "grub-once" later, after + # prepare_suspend finished. + if [ $NEXT_BOOT -eq -1 ]; then + echo "WARNING: no kernelfile matching the running kernel found" + fi +} + +############################################################################# +# if we did not find a kernel (or BOOT_LOADER is not GRUB) check, +# if the running kernel is still the one that will (probably) be booted for +# resume (default entry in menu.lst or, if there is none, the kernel file +# /boot/vmlinuz points to.) +# This will only work, if you use "original" SUSE kernels. +# you can always override with the config variable set to "yes" +prepare-grub() +{ + echo "INFO: running prepare-grub" + prepare-parameters + eval `$getkernels` + RUNNING=`uname -r` + find-kernel-entry + + RET=0 + + if [ $NEXT_BOOT -eq -1 ]; then + # which kernel is booted with the default entry? + BOOTING="${KERNELS[$DEFAULT_BOOT]}" + # if there is no default entry (no menu.lst?) we fall back to + # the default of /boot/vmlinuz. + [ -z "$BOOTING" ] && BOOTING="vmlinuz" + if IMAGE=`readlink /boot/$BOOTING` && [ -e "/boot/${IMAGE##*/}" ]; then + BOOTING=$IMAGE + fi + BOOTING="${BOOTING#*vmlinuz-}" + echo "running kernel: '$RUNNING', probably booting kernel: '$BOOTING'" + if [ "$BOOTING" != "$RUNNING" ]; then + echo "ERROR: kernel version mismatch, cannot suspend to disk" + echo "running: $RUNNING booting: $BOOTING" >> $INHIBIT + RET=1 + fi + else + # set the bootloader to the running kernel + echo " preparing boot-loader: selecting entry $NEXT_BOOT, kernel /boot/$BOOTING" + T1=`date +"%s%N"` + sync; sync; sync # this is needed to speed up grub-once on reiserfs + T2=`date +"%s%N"` + echo " grub-once: `grub-once $NEXT_BOOT`" + T3=`date +"%s%N"` + S=$(((T2-T1)/100000000)); S="$((S/10)).${S:0-1}" + G=$(((T3-T2)/100000000)); G="$((G/10)).${G:0-1}" + echo " time needed for sync: $S seconds, time needed for grub: $G seconds." + fi + + return $RET +} + + +###### main() + +if [ "$1" = pre ] ; then + prepare-grub +fi +if [ "$1" = post ] ; then + grub-once-restore +fi diff --git a/systemd.changes b/systemd.changes index 80282770..6e6334de 100644 --- a/systemd.changes +++ b/systemd.changes @@ -1,3 +1,79 @@ +------------------------------------------------------------------- +Fri Mar 28 12:53:21 UTC 2014 - werner@suse.de + +- Add or port upstram bugfix patches: + 0001-cgroup-it-s-not-OK-to-invoke-alloca-in-loops.patch + 0002-machined-fix-Kill-bus-call-on-machine-objects-when-w.patch + 0003-sd-bus-don-t-use-assert_return-to-check-for-disconne.patch + 0004-core-don-t-try-to-relabel-mounts-before-we-loaded-th.patch + 0005-sd-daemon-fix-incorrect-variable-access.patch + 0006-sd-event-initialization-perturbation-value-right-bef.patch + 0007-sd-event-don-t-accidentally-turn-of-watchdog-timer-e.patch + 0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch + 0009-ask-password-when-the-user-types-a-overly-long-passw.patch +- Modify patch + 1019-make-completion-smart-to-be-able-to-redirect.patch + to work together with + 0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch + +------------------------------------------------------------------- +Fri Mar 28 08:10:13 UTC 2014 - werner@suse.de + +- Use Robert's revised 1006-udev-always-rename-network.patch + +------------------------------------------------------------------- +Tue Mar 25 17:28:18 UTC 2014 - werner@suse.de + +- Readd patch Forward-suspend-hibernate-calls-to-pm-utils.patch + older code base as 13.1 only +- Add patch avoid-random-hangs-on-timeouts-due-lost-cwd.patch + to be able to terminate the user manager even if cwd of the + user is gone + +------------------------------------------------------------------- +Tue Mar 25 13:08:56 UTC 2014 - thomas.blume@suse.com + +- add prepare-suspend-to-disk.patch + enable suspend conditions check and preparation for systemd-sleep + (fate#316824, bnc#856389, bnc#856392) +- remove Forward-suspend-hibernate-calls-to-pm-utils.patch since it is obsolete + (bnc#856392#c20) +- add boot-local-start.patch + fix startup for /etc/init.d/boot.local (bnc#869142) + +------------------------------------------------------------------- +Mon Mar 24 11:19:38 UTC 2014 - coolo@suse.com + +- also autoreconf in systemd-mini to simplify spec file logic + and fix build in staging:gcc49 + (obsoleting 0002-make-209-working-on-older-dist.patch) + +------------------------------------------------------------------- +Wed Mar 19 13:21:37 UTC 2014 - werner@suse.de + +- Be sure that the refreshed manual pages are installed + +------------------------------------------------------------------- +Wed Mar 19 12:09:31 UTC 2014 - werner@suse.de + +- Add patch systemctl-set-default-target.patch which explain how + to override the default.target by using --force (bnc#868439) + +------------------------------------------------------------------- +Tue Mar 18 13:23:43 UTC 2014 - werner@suse.de + +- Add Robert's udev-generate-peristent-rule shell script to + udev's tool library +- Add or port upstram bugfix patches: + 0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch + 0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch + 0006-Do-not-return-1-EINVAL-on-allocation-error.patch + 0007-networkd-fix-typo.patch + 0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch + 0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch + 0012-journald-remove-stray-reset-of-error-return-value.patch + 0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch + ------------------------------------------------------------------- Fri Mar 14 14:24:56 UTC 2014 - werner@suse.de @@ -789,7 +865,7 @@ Fri Dec 20 12:06:18 UTC 2013 - werner@suse.de - Change patch 1012-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch to check if XDG_RUNTIME_DIR is set before the call of pam_putenv() - may fix bnc#855160 + may fix bnc#855160 ------------------------------------------------------------------- Fri Dec 20 09:40:01 UTC 2013 - lbsousajr@gmail.com diff --git a/systemd.spec b/systemd.spec index 7be75e0f..b5f4ba83 100644 --- a/systemd.spec +++ b/systemd.spec @@ -144,21 +144,9 @@ Source11: after-local.service Source1060: boot.udev Source1061: write_dev_root_rule Source1062: systemd-udev-root-symlink +Source1063: udev-generate-peristent-rule.sh +Source1064: systemd-sleep-grub -############################################################################## -# -# WARNING: For the case of for bootstrapping patch should not affect -# the files -# -# Makefile.am, Makefile.in, and configure.ac -# -# as this triggers an (re)autoconfigure. Please check patches with the command -# -# grep -lE 'Makefile.(am|in)|configure\.ac' *.patch -# -# to surround them with %if ! 0%{?bootstrap} ... %endif -# -############################################################################## # # PATCH-FIX-UPSTREAM avoid-assertion-if-invalid-address-familily-is-passed-to-g.patch lnussel@suse.com bnc#791101 -- avoid assertion if invalid address familily is passed to gethostbyaddr_r Patch0: avoid-assertion-if-invalid-address-familily-is-passed-to-g.patch @@ -210,7 +198,7 @@ Patch42: systemd-pam_config.patch Patch23: disable-nss-myhostname-warning-bnc-783841.patch # PATCH-FIX-OPENSUSE handle-HOSTNAME.patch fcrozat@suse.com -- handle /etc/HOSTNAME (bnc#803653) Patch24: handle-etc-HOSTNAME.patch -# PATCH-FIX-OPENSUSE Forward-suspend-hibernate-calls-to-pm-utils.patch fcrozat@suse.com bnc#790157 -- forward to pm-utils +# PATCH-FIX-OPENSUSE forward to pm-utils -- for code base <= 1310 Patch25: Forward-suspend-hibernate-calls-to-pm-utils.patch # PATCH-FIX-UPSTREAM rules-add-lid-switch-of-ARM-based-Chromebook-as-a-power-sw.patch rjschwei@suse.com -- add lid switch of ARM based Chromebook as a power switch to logind Patch38: rules-add-lid-switch-of-ARM-based-Chromebook-as-a-power-sw.patch @@ -232,7 +220,6 @@ Patch93: 0001-Don-t-snprintf-a-potentially-NULL-pointer.patch Patch114: 0001-systemd-empty-sigmask-on-reexec.patch # PATCH-FIX-SUSE 0001-make-209-working-on-older-dist.patch werner@suse.com Patch117: 0001-make-209-working-on-older-dist.patch -Patch118: 0002-make-209-working-on-older-dist.patch # PATCH-FIX-SUSE 0001-make-fortify-happy-with-ppoll.patch werner@suse.com Patch119: 0001-make-fortify-happy-with-ppoll.patch # PATCH-FIX-SUSE 0001-avoid-abort-due-timeout-at-user-service.patch werner@suse.com @@ -303,6 +290,40 @@ Patch151: 0005-logind-fix-policykit-checks.patch Patch152: 0006-rules-mark-loop-device-as-SYSTEMD_READY-0-if-no-file.patch # PATCH-FIX-USTREAM added at 2014/03/11 Patch153: 0008-man-multiple-sleep-modes-are-to-be-separated-by-whit.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch154: 0001-gpt-auto-generator-don-t-return-OOM-on-parentless-de.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch155: 0002-bus-fix-memory-leak-when-kdbus-is-not-enabled.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch157: 0006-Do-not-return-1-EINVAL-on-allocation-error.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch158: 0007-networkd-fix-typo.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch159: 0008-sd-bus-don-t-access-invalid-memory-if-a-signal-match.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch160: 0009-sd-bus-don-t-choke-if-somebody-sends-us-a-message-wi.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch161: 0012-journald-remove-stray-reset-of-error-return-value.patch +# PATCH-FIX-USTREAM added at 2014/03/18 +Patch162: 0013-core-libsystemd-systemd-timedate-udev-spelling-fixes.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch163: 0001-cgroup-it-s-not-OK-to-invoke-alloca-in-loops.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch164: 0002-machined-fix-Kill-bus-call-on-machine-objects-when-w.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch165: 0003-sd-bus-don-t-use-assert_return-to-check-for-disconne.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch166: 0004-core-don-t-try-to-relabel-mounts-before-we-loaded-th.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch167: 0005-sd-daemon-fix-incorrect-variable-access.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch168: 0006-sd-event-initialization-perturbation-value-right-bef.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch169: 0007-sd-event-don-t-accidentally-turn-of-watchdog-timer-e.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch170: 0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch +# PATCH-FIX-USTREAM added at 2014/03/28 +Patch171: 0009-ask-password-when-the-user-types-a-overly-long-passw.patch # PATCH-FIX-OPENSUSE 1009-make-xsltproc-use-correct-ROFF-links.patch -- Make ROFF links working again in manual pages (bnc#842844) Patch1009: 1009-make-xsltproc-use-correct-ROFF-links.patch # PATCH-FIX-OPENSUSE 1010-do-not-install-sulogin-unit-with-poweroff.patch -- Avoid installing console-shell.service (bnc#849071) @@ -321,6 +342,15 @@ Patch1020: 0001-add-network-device-after-NFS-mount-units.patch Patch1022: 1022-systemd-tmpfiles-ownerkeep.patch # PATCH-FIX-SUSE systemd-powerd-initctl-support.patch Patch1023: systemd-powerd-initctl-support.patch +# PATCH-FIX-SUSE systemctl-set-default-target.patch +Patch1024: systemctl-set-default-target.patch +# PATCH-FIX-SUSE prepare-suspend-to-disk.patch (fate #316824) +Patch1025: prepare-suspend-to-disk.patch +# PATCH-FIX-SUSE boot-local-start.patch (bnc #869142) +Patch1026: boot-local-start.patch +# PATCH-FIX-SUSE avoid random hangs on timeouts due lost cwd at terminating user manager +Patch1027: avoid-random-hangs-on-timeouts-due-lost-cwd.patch + # PATCH-FIX-SUSE systemd-install-compat_pkgconfig-always.patch Patch1999: systemd-install-compat_pkgconfig-always.patch # PATCH-FIX-OPENSUSE systemd-dbus-system-bus-address.patch always use /run/dbus not /var/run @@ -555,18 +585,11 @@ cp %{SOURCE7} m4/ # systemd patches %patch0 -p1 -%if ! 0%{?bootstrap} %patch1 -p1 -%endif %patch3 -p1 -# don't apply when bootstrapping to not modify configure.in -%if ! 0%{?bootstrap} %patch4 -p1 -%endif %patch5 -p1 -%if ! 0%{?bootstrap} %patch6 -p1 -%endif %patch7 -p1 %patch8 -p1 %patch9 -p1 @@ -576,9 +599,7 @@ cp %{SOURCE7} m4/ %patch14 -p1 %patch15 -p1 %patch16 -p1 -%if ! 0%{?bootstrap} %patch17 -p1 -%endif %patch18 -p1 %patch19 -p1 %patch20 -p1 @@ -586,7 +607,9 @@ cp %{SOURCE7} m4/ %patch22 -p1 %patch23 -p1 %patch24 -p1 +%if 0%{?suse_version} <= 1310 %patch25 -p1 +%endif # check if this is still needed, or can be derived from fbdev uaccess rule # http://lists.freedesktop.org/archives/systemd-devel/2012-November/007561.html %patch27 -p1 @@ -601,19 +624,13 @@ cp %{SOURCE7} m4/ %patch46 -p1 %patch47 -p1 %patch84 -p1 -%if ! 0%{?bootstrap} %patch86 -p1 -%endif %patch90 -p1 %patch91 -p1 %patch93 -p1 %patch114 -p0 %if 0%{?suse_version} <= 1310 -%if ! 0%{?bootstrap} %patch117 -p1 -%else -%patch118 -p1 -%endif %endif %patch119 -p1 %patch120 -p1 @@ -630,9 +647,7 @@ cp %{SOURCE7} m4/ %patch131 -p0 %patch132 -p0 %patch133 -p0 -%if ! 0%{?bootstrap} %patch134 -p0 -%endif %patch135 -p0 %patch136 -p0 %patch137 -p0 @@ -652,24 +667,39 @@ cp %{SOURCE7} m4/ %patch151 -p0 %patch152 -p0 %patch153 -p0 +%patch154 -p0 +%patch155 -p0 +%patch157 -p0 +%patch158 -p0 +%patch159 -p0 +%patch160 -p0 +%patch161 -p0 +%patch162 -p0 +%patch163 -p0 +%patch164 -p0 +%patch165 -p0 +%patch166 -p0 +%patch167 -p0 +%patch168 -p0 +%patch169 -p0 +%patch170 -p0 +%patch171 -p0 %patch1009 -p1 %patch1010 -p1 %patch1012 -p1 %patch1014 -p1 %patch1018 -p1 %patch1019 -p1 -%if ! 0%{?bootstrap} %patch1020 -p1 -%endif %patch1022 -p1 %patch1023 -p1 -%if ! 0%{?bootstrap} +%patch1024 -p1 +%patch1025 -p1 +%patch1026 -p1 +%patch1027 -p1 %patch1999 -p1 -%endif %patch2000 -p1 -%if ! 0%{?bootstrap} %patch2001 -p1 -%endif # udev patches %patch1034 -p0 %patch1035 -p0 @@ -678,23 +708,16 @@ cp %{SOURCE7} m4/ %patch1003 -p1 %patch1005 -p1 %patch1006 -p1 -# don't apply when bootstrapping to not modify Makefile.am -%if ! 0%{?bootstrap} %patch1007 -p1 -%endif %if 0%{?suse_version} <= 1310 -%if ! 0%{?bootstrap} %patch1008 -p1 %endif -%endif # ensure generate files are removed rm -f units/emergency.service %build -%if ! 0%{?bootstrap} autoreconf -fiv -%endif # prevent pre-generated and distributed files from re-building find . -name "*.[1-8]" -exec touch '{}' '+'; export V=1 @@ -739,8 +762,24 @@ export V=1 --disable-kdbus \ CFLAGS="%{optflags}" make %{?_smp_mflags} +%if ! 0%{?bootstrap} +make %{?_smp_mflags} update-man-list man +%endif %install +# Use refreshed manual pages +for man in man/*.[0-9] +do + section=${man##*.} + test -d man/man${section} || continue + new=man/man${section}/${man##*/} + if test -s $new -a $new -nt $man + then + cp -p $new $man + else + sed -ri 's@"(systemd) 209"@"\1 %{version}"@' $man + fi +done make install DESTDIR="%buildroot" # move to %{_lib} @@ -771,6 +810,8 @@ sed -ie "s|@@PREFIX@@|%{_bindir}|g" %{S:1061} install -m755 -D %{S:1061} %{buildroot}/%{_prefix}/lib/udev/write_dev_root_rule sed -ie "s|@@PREFIX@@|%{_prefix}/lib/udev|g" %{S:1062} install -m644 -D %{S:1062} %{buildroot}/%{_prefix}/lib/systemd/system/systemd-udev-root-symlink.service +install -m755 -D %{S:1063} %{buildroot}/%{_prefix}/lib/udev/udev-generate-peristent-rule +install -m755 -D %{S:1064} %{buildroot}/%{_bindir}/systemd-sleep-grub mkdir -p %{buildroot}/%{_prefix}/lib/systemd/system/basic.target.wants ln -sf ../systemd-udev-root-symlink.service %{buildroot}/%{_prefix}/lib/systemd/system/basic.target.wants rm -rf %{buildroot}%{_sysconfdir}/rpm @@ -1107,6 +1148,7 @@ exit 0 /bin/systemd /bin/systemd-ask-password /bin/systemctl +%{_bindir}/systemd-sleep-grub %{_bindir}/bootctl %{_bindir}/busctl %{_bindir}/kernel-install @@ -1200,9 +1242,7 @@ exit 0 %{_prefix}/lib/systemd/system-generators/systemd-rc-local-generator %{_prefix}/lib/systemd/system-generators/systemd-fstab-generator %{_prefix}/lib/systemd/system-generators/systemd-system-update-generator -%if ! 0%{?bootstrap} %{_prefix}/lib/systemd/system-generators/systemd-insserv-generator -%endif %{_prefix}/lib/systemd/system-generators/systemd-gpt-auto-generator /%{_lib}/security/pam_systemd.so /etc/pam.d/systemd-user @@ -1288,9 +1328,7 @@ exit 0 %{_prefix}/lib/udev/rules.d/73-seat-numlock.rules %endif %{_prefix}/lib/udev/rules.d/99-systemd.rules -%if ! 0%{?bootstrap} %{_prefix}/lib/udev/numlock-on -%endif %if 0%{suse_version} < 1310 %{_sysconfdir}/rpm/macros.systemd %endif @@ -1371,6 +1409,7 @@ exit 0 %{_prefix}/lib/udev/scsi_id %{_prefix}/lib/udev/v4l_id %{_prefix}/lib/udev/write_dev_root_rule +%{_prefix}/lib/udev/udev-generate-peristent-rule %dir %{_prefix}/lib/udev/rules.d/ %exclude %{_prefix}/lib/udev/rules.d/70-uaccess.rules %exclude %{_prefix}/lib/udev/rules.d/71-seat.rules diff --git a/udev-generate-peristent-rule.sh b/udev-generate-peristent-rule.sh new file mode 100644 index 00000000..4c83919a --- /dev/null +++ b/udev-generate-peristent-rule.sh @@ -0,0 +1,414 @@ +#!/bin/bash +# +# Copyright (C) 2014 Robert Milasan +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# This script run manually by user, will generate a persistent rule for +# a given network interface to rename it to new interface name. +# + +prj=${0##*/} + +log_info() +{ + local msg="$1" + echo "$prj: $msg" +} + +log_error() +{ + local msg=$1 + echo "$prj: $msg" >&2 +} + +usage() +{ + set -f + cat << EOF +$prj: udev persistent rule generator + +Usage: $prj [OPTION] ... + + -h show this help + -m generate the persistent rule based on interface MAC address + -p generate the persistent rule based on interface PCI slot + -v be verbose + -c current interface name (ex: "ip a s") + -n new interface name (ex: net0) + -o where to write the new generate rule (default: /dev/stdout) + prefered location is /etc/udev/rules.d/70-persistent-net.rules + +Example: + $prj -m -c enp0s4 -n net0 -o /etc/udev/rules.d/70-persistent-net.rules + or + $prj -p -c wlp3s0 -n wlan0 -o /etc/udev/rules.d/50-mynet.rules + +EOF +} + +display_note() +{ + cat <<'EOF' + +NOTE: Using the generate persistent rule might mean you will need to do extra +work to ensure that it will work accordingly. This mean, regenerating the +initramfs/initrd image and/or using 'net.ifnames=0' option at boot time. + +In openSUSE/SUSE, the user will need to regenerate the initramfs/initrd image, +but usually there is no need for 'net.ifnames=0' option if the persistent rule +is available in initramfs/initrd image. + +EOF +} + +get_pci() +{ + local path=$1 + local pci="" + + if [ -L "$path/device" ]; then + local pci_link="$(readlink -f $path/device 2>/dev/null)" + pci="$(basename $pci_link 2>/dev/null)" + fi + echo $pci +} + +get_pci_id() +{ + local path=$1 + local pci_id="" + + if [ -r "$path/device/uevent" ]; then + local _pci_id="$(cat $path/device/uevent|grep ^PCI_ID 2>/dev/null)" + pci_id="${_pci_id#*=}" + fi + echo $pci_id +} + +get_macaddr() +{ + local path=$1 + local macaddr="" + + if [ -r "$path/address" ]; then + macaddr="$(cat $path/address 2>/dev/null)" + fi + echo $macaddr +} + +get_type() +{ + local path=$1 + local dev_type="" + + if [ -r "$path/type" ]; then + dev_type="$(cat $path/type 2>/dev/null)" + fi + echo $dev_type +} + +get_dev_id() +{ + local path=$1 + local dev_id="" + + if [ -r "$path/dev_id" ]; then + dev_id="$(cat $path/dev_id 2>/dev/null)" + fi + echo $dev_id +} + +get_devtype() +{ + local path=$1 + local devtype="" + if [ -r "$path/uevent" ]; then + local _devtype="$(cat $path/uevent|grep ^DEVTYPE 2>/dev/null)" + devtype="${_devtype#*=}" + fi + echo $devtype +} + +get_subsystem() +{ + local path=$1 + local subsystem="" + + if [ -L "$path/subsystem" ]; then + local subsystem_link="$(readlink -f $path/subsystem 2>/dev/null)" + subsystem="$(basename $subsystem_link 2>/dev/null)" + fi + echo $subsystem +} + +get_driver() +{ + local path=$1 + local driver="" + + if [ -L "$path/device/driver" ]; then + local driver_link="$(readlink -f $path/device/driver 2>/dev/null)" + driver="$(basename $driver_link 2>/dev/null)" + fi + echo $driver +} + +valid_mac() +{ + local macaddr=$1 + local valid_macaddr="" + + if [ -n "$macaddr" ]; then + valid_macaddr="$(echo $macaddr | sed -n '/^\([0-9a-z][0-9a-z]:\)\{5\}[0-9a-z][0-9a-z]$/p')" + fi + echo $valid_macaddr +} + +generate_comment() +{ + local pci_id=$1 + local driver=$2 + local output=$3 + + if [ -z "$pci_id" ]; then + log_error "\$pci_id empty." + exit 1 + elif [ -z "$driver" ]; then + log_error "\$driver empty." + exit 1 + elif [ -z "$output" ]; then + log_error "\$output empty." + exit 1 + else + echo "# PCI device $pci_id ($driver) with official udev name $interface renamed to unsupported $new_interface" >> $output + fi +} + +generate_rule() +{ + local _subsystem=$1 + local _mac=$2 + local _pci=$3 + local _dev_id=$4 + local _dev_type=$5 + local _kernel=$6 + local _interface=$7 + local output=$8 + + if [ -z "$_subsystem" ]; then + log_error "\$_subsystem empty." + exit 1 + elif [ -z "$_dev_id" ]; then + log_error "\$_dev_id empty." + exit 1 + elif [ -z "$_dev_type" ]; then + log_error "\$_dev_type empty." + exit 1 + elif [ -z "$_kernel" ]; then + log_error "\$_kernel empty." + exit 1 + elif [ -z "$_interface" ]; then + log_error "\$_interface empty." + exit 1 + elif [ -z "$output" ]; then + output="/dev/stdout" + fi + + if [ "$_mac" != "none" ]; then + echo "SUBSYSTEM==\"$_subsystem\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$_mac\", \ +ATTR{dev_id}==\"$_dev_id\", ATTR{type}==\"$_dev_type\", KERNEL==\"$_kernel\", NAME=\"$_interface\"" >> ${output} + elif [ "$_pci" != "none" ]; then + echo "SUBSYSTEM==\"$_subsystem\", ACTION==\"add\", DRIVERS==\"?*\", KERNELS==\"$_pci\", \ +ATTR{dev_id}==\"$_dev_id\", ATTR{type}==\"$_dev_type\", KERNEL==\"$_kernel\", NAME=\"$_interface\"" >> ${output} + else + log_error "MAC address or PCI slot information missing." + exit 1 + fi +} + +if [ $# -eq 0 ]; then + usage + log_error "missing option(s)." + exit 1 +fi + +use_mac=0 +use_pci=0 +use_verbose=0 + +while getopts "hmpvc:n:o:" opt; do + case "$opt" in + h) + usage; exit 0;; + m) + use_mac=1 ;; + p) + use_pci=1 ;; + v) + use_verbose=1 ;; + c) + ifcur="$OPTARG" ;; + n) + ifnew="$OPTARG" ;; + o) + output="$OPTARG" ;; + \?) + exit 1 ;; + esac +done + +if [[ "$use_mac" -eq 1 ]] && [[ "$use_pci" -eq 1 ]]; then + log_error "generating a persistent rule can be done only using one of the option, -m or -p, not both." + exit 1 +fi + +outfile=$output +if [ -z "$output" ]; then + outfile=/dev/stdout +else + dir="$(dirname $outfile 2>/dev/null)" + tmpfile="$dir/.tmp_file" + if [ -d "$dir" ]; then + touch "$tmpfile" >/dev/null 2>&1 + if [ $? -ne 0 ]; then + log_error "no write access for $outfile. make sure you have write permissions to $dir." + exit 1 + fi + rm -f "$tmpfile" >/dev/null 2>&1 + else + log_error "$dir not a directory." + exit 1 + fi +fi + +interface=$ifcur +if [ -z "$interface" ]; then + log_error "current interface must be specified." + exit 1 +elif [ "$interface" == "lo" ]; then + log_error "loopback interface is not a valid interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: INTERFACE=$interface" + +new_interface=$ifnew +if [ -z "$new_interface" ]; then + log_error "new interface must be specified." + exit 1 +elif [ "$new_interface" == "lo" ]; then + log_error "new interface cant be named loopback interface." + exit +fi +[ "$use_verbose" -eq 1 ] && echo "I: INTERFACE_NEW=$new_interface" + +path="/sys/class/net/$interface" +if [ ! -d "$path" ]; then + log_error "devpath $path not a directory." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: DEVPATH=$path" + +devtype="$(get_devtype $path)" +if [ -n "$devtype" ]; then + [ "$use_verbose" -eq 1 ] && echo "I: DEVTYPE=$devtype" +fi + +subsystem="$(get_subsystem $path)" +if [ -z "$subsystem" ]; then + log_error "unable to retrieve subsystem for interface $interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: SUBSYSTEM=$subsystem" + +pci_id="$(get_pci_id $path)" +if [ -z "$pci_id" ]; then + log_error "unable to retrieve PCI_ID for interface $interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: PCI_ID=$pci_id" + +driver="$(get_driver $path)" +if [ -z "$driver" ]; then + log_error "unable to retrieve driver for interface $interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: DRIVER=$driver" + +if [ "$use_mac" -eq 1 ]; then + macaddr="$(get_macaddr $path)" + if [ -z "$macaddr" ]; then + log_error "unable to retrieve MAC address for interface $interface." + exit 1 + fi + if [ "$(valid_mac $macaddr)" != "$macaddr" ]; then + log_error "$macaddr invalid MAC address." + exit 1 + fi + [ "$use_verbose" -eq 1 ] && echo "I: MACADDR=$macaddr" +fi + +if [ "$use_pci" -eq 1 ]; then + pci="$(get_pci $path)" + if [ -z "$pci" ]; then + log_error "unable to retrieve PCI slot for interface $interface." + exit 1 + fi + [ "$use_verbose" -eq 1 ] && echo "I: KERNELS=$pci" +fi + +dev_id="$(get_dev_id $path)" +if [ -z "$dev_id" ]; then + log_error "unable to retrieve dev_id for interface $interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: DEV_ID=$dev_id" + +dev_type="$(get_type $path)" +if [ -z "$dev_type" ]; then + log_error "unable to retrieve dev_type for interface $interface." + exit 1 +fi +[ "$use_verbose" -eq 1 ] && echo "I: TYPE=$dev_type" + +if [ "$devtype" == "wlan" ]; then + kernel="wlan*" +else + kernel="eth*" +fi + +if [ -n "$output" ]; then + echo "Persistent rule saved in "$outfile"" + echo + generate_comment "$pci_id" "$driver" "$output" +fi + +set -f +if [ "$use_mac" -eq 1 ]; then + generate_rule "$subsystem" "$macaddr" "none" "$dev_id" "$dev_type" "$kernel" "$new_interface" + if [ -n "$output" ]; then + generate_rule "$subsystem" "$macaddr" "none" "$dev_id" "$dev_type" "$kernel" "$new_interface" "$output" + fi +elif [ "$use_pci" -eq 1 ]; then + generate_rule "$subsystem" "none" "$pci" "$dev_id" "$dev_type" "$kernel" "$new_interface" + if [ -n "$output" ]; then + generate_rule "$subsystem" "none" "$pci" "$dev_id" "$dev_type" "$kernel" "$new_interface" "$outfile" + fi +fi + +if [ -n "$output" ]; then + display_note +fi + +exit 0