systemd/systemd-powerd-initctl-support.patch

122 lines
4.1 KiB
Diff
Raw Normal View History

Accepting request 225960 from Base:System - Add patch getty-generator-with-serial-3270-tty.patch to avoid harmless error messages on not existing getty@3270 files - Replace systemd-big-endian-reply-matching.patch with upstream 0001-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch to solve broken systemd communication with and over dbus (bnc#866732) - Readd patch 1008-add-msft-compability-rules.patch for older code base as 13.1 - Modify pre_checkin.sh to throw an error if a patch will be applied which modifies one of Makefile.am, Makefile.in, or configiure.ac as this breaks bootstrapping - Add second version of make-209-working-on-older-dist.patch to be able to apply for bootstrapping version - Don't require non-existing binutils-gold - Avoid file conflict between udev and systemd (bnc#868230) - Modify patch module-load-handle-SUSE-etc-sysconfig-kernel-module-list.patch to ignore if /etc/sysconfig/kernel does not exist (bnc#865834) - Add patch systemd-big-endian-reply-matching.patch make sure that systemd can talk with dbus-daemon even on big endian systems (bnc#866732) ----------------------------------------------------------------- - Due to previous reason, resurrect systemd-dbus-system-bus-address.patch - Removed pkgconfig(dbus-1) BuildRequires - with 209 and newer, itis only needed for quering default DBus directories, which we nowpass to configure. OBS-URL: https://build.opensuse.org/request/show/225960 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=178
2014-03-18 16:21:15 +01:00
From 7b8b1ca177a532a6673e5795af867b3631622391 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Fri, 7 Mar 2014 14:04:58 +0100
Subject: [PATCH] systemd: powerd initctl support
Old versions of powerd will be using the initctl fifo to signal
state changes. To maintain backward compability systemd should
be interpreting these messages, too.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
src/initctl/initctl.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 70 insertions(+), 1 deletion(-)
Accepting request 286653 from Base:System - mark more subpackages as !bootstrap for systemd-mini usage. - spec : remove --with-firmware-path, firmware loader was removed in v217 - spec: remove --disable-multi-seat-x, gone.(fixed in xorg) - spec: Do not enable systemd-readahead-collect.service and systemd-readahead-replay.service as these do not exist anymore. - spec: drop timedate-add-support-for-openSUSE-version-of-etc-sysconfig.patch Yast was fixed to write all timezone changes exactly how timedated expects things to be done. - spec: remove handle-etc-HOSTNAME.patch, since late 2014 the netcfg package handles the migration from /etc/HOSTNAME to /etc/hostname and owns both files. -spec: remove boot.udev and systemd-journald.init as they currently serve no purpose. - suse-sysv-bootd-support.diff: Remove HAVE_SYSVINIT conditions, we are in sysvcompat-only codepath, also remove the code targetting other distributions, never compiled as the TARGET_$DISTRO macros are never defined. - systemd-powerd-initctl-support.patch guard with HAVE_SYSV_COMPAT - set-and-use-default-logconsole.patch: fix HAVE_SYSV_COMPAT guards - insserv-generator.patch: Only build when sysvcompat is enabled - vhangup-on-all-consoles.patch add a comment indicating this is a workaround for a kernel bug. - spec: Add option to allow disabling sysvinit compat at build time. - spec: Add option to enable resolved at build time. - spec: Remove all %ifs for !factory products, current systemd releases can neither be built nor installed in older products without upgrading several components of the base system. (removed: 1008-add-msft-compability-rules.patch was only for =< 13.1) - spec: remove all dummy "aliases" to /etc/init.d, that made sense only when those init scripts still existed. (dummy localfs.service source: gone) OBS-URL: https://build.opensuse.org/request/show/286653 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=215
2015-03-01 14:49:19 +01:00
--- systemd-219.orig/src/initctl/initctl.c
+++ systemd-219/src/initctl/initctl.c
Accepting request 225960 from Base:System - Add patch getty-generator-with-serial-3270-tty.patch to avoid harmless error messages on not existing getty@3270 files - Replace systemd-big-endian-reply-matching.patch with upstream 0001-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch to solve broken systemd communication with and over dbus (bnc#866732) - Readd patch 1008-add-msft-compability-rules.patch for older code base as 13.1 - Modify pre_checkin.sh to throw an error if a patch will be applied which modifies one of Makefile.am, Makefile.in, or configiure.ac as this breaks bootstrapping - Add second version of make-209-working-on-older-dist.patch to be able to apply for bootstrapping version - Don't require non-existing binutils-gold - Avoid file conflict between udev and systemd (bnc#868230) - Modify patch module-load-handle-SUSE-etc-sysconfig-kernel-module-list.patch to ignore if /etc/sysconfig/kernel does not exist (bnc#865834) - Add patch systemd-big-endian-reply-matching.patch make sure that systemd can talk with dbus-daemon even on big endian systems (bnc#866732) ----------------------------------------------------------------- - Due to previous reason, resurrect systemd-dbus-system-bus-address.patch - Removed pkgconfig(dbus-1) BuildRequires - with 209 and newer, itis only needed for quering default DBus directories, which we nowpass to configure. OBS-URL: https://build.opensuse.org/request/show/225960 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=178
2014-03-18 16:21:15 +01:00
@@ -32,8 +32,11 @@
#include <sys/un.h>
#include <fcntl.h>
#include <ctype.h>
+#include <sys/reboot.h>
+#include <linux/reboot.h>
#include "sd-daemon.h"
+#include "sd-shutdown.h"
#include "sd-bus.h"
#include "util.h"
@@ -44,6 +47,7 @@
#include "bus-util.h"
#include "bus-error.h"
#include "def.h"
+#include "socket-util.h"
#define SERVER_FD_MAX 16
#define TIMEOUT_MSEC ((int) (DEFAULT_EXIT_USEC/USEC_PER_MSEC))
Accepting request 286653 from Base:System - mark more subpackages as !bootstrap for systemd-mini usage. - spec : remove --with-firmware-path, firmware loader was removed in v217 - spec: remove --disable-multi-seat-x, gone.(fixed in xorg) - spec: Do not enable systemd-readahead-collect.service and systemd-readahead-replay.service as these do not exist anymore. - spec: drop timedate-add-support-for-openSUSE-version-of-etc-sysconfig.patch Yast was fixed to write all timezone changes exactly how timedated expects things to be done. - spec: remove handle-etc-HOSTNAME.patch, since late 2014 the netcfg package handles the migration from /etc/HOSTNAME to /etc/hostname and owns both files. -spec: remove boot.udev and systemd-journald.init as they currently serve no purpose. - suse-sysv-bootd-support.diff: Remove HAVE_SYSVINIT conditions, we are in sysvcompat-only codepath, also remove the code targetting other distributions, never compiled as the TARGET_$DISTRO macros are never defined. - systemd-powerd-initctl-support.patch guard with HAVE_SYSV_COMPAT - set-and-use-default-logconsole.patch: fix HAVE_SYSV_COMPAT guards - insserv-generator.patch: Only build when sysvcompat is enabled - vhangup-on-all-consoles.patch add a comment indicating this is a workaround for a kernel bug. - spec: Add option to allow disabling sysvinit compat at build time. - spec: Add option to enable resolved at build time. - spec: Remove all %ifs for !factory products, current systemd releases can neither be built nor installed in older products without upgrading several components of the base system. (removed: 1008-add-msft-compability-rules.patch was only for =< 13.1) - spec: remove all dummy "aliases" to /etc/init.d, that made sense only when those init scripts still existed. (dummy localfs.service source: gone) OBS-URL: https://build.opensuse.org/request/show/286653 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=215
2015-03-01 14:49:19 +01:00
@@ -141,7 +145,54 @@ static void change_runlevel(Server *s, i
Accepting request 225960 from Base:System - Add patch getty-generator-with-serial-3270-tty.patch to avoid harmless error messages on not existing getty@3270 files - Replace systemd-big-endian-reply-matching.patch with upstream 0001-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch to solve broken systemd communication with and over dbus (bnc#866732) - Readd patch 1008-add-msft-compability-rules.patch for older code base as 13.1 - Modify pre_checkin.sh to throw an error if a patch will be applied which modifies one of Makefile.am, Makefile.in, or configiure.ac as this breaks bootstrapping - Add second version of make-209-working-on-older-dist.patch to be able to apply for bootstrapping version - Don't require non-existing binutils-gold - Avoid file conflict between udev and systemd (bnc#868230) - Modify patch module-load-handle-SUSE-etc-sysconfig-kernel-module-list.patch to ignore if /etc/sysconfig/kernel does not exist (bnc#865834) - Add patch systemd-big-endian-reply-matching.patch make sure that systemd can talk with dbus-daemon even on big endian systems (bnc#866732) ----------------------------------------------------------------- - Due to previous reason, resurrect systemd-dbus-system-bus-address.patch - Removed pkgconfig(dbus-1) BuildRequires - with 209 and newer, itis only needed for quering default DBus directories, which we nowpass to configure. OBS-URL: https://build.opensuse.org/request/show/225960 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=178
2014-03-18 16:21:15 +01:00
}
}
+static int send_shutdownd(unsigned delay, char mode, const char *message) {
Accepting request 286653 from Base:System - mark more subpackages as !bootstrap for systemd-mini usage. - spec : remove --with-firmware-path, firmware loader was removed in v217 - spec: remove --disable-multi-seat-x, gone.(fixed in xorg) - spec: Do not enable systemd-readahead-collect.service and systemd-readahead-replay.service as these do not exist anymore. - spec: drop timedate-add-support-for-openSUSE-version-of-etc-sysconfig.patch Yast was fixed to write all timezone changes exactly how timedated expects things to be done. - spec: remove handle-etc-HOSTNAME.patch, since late 2014 the netcfg package handles the migration from /etc/HOSTNAME to /etc/hostname and owns both files. -spec: remove boot.udev and systemd-journald.init as they currently serve no purpose. - suse-sysv-bootd-support.diff: Remove HAVE_SYSVINIT conditions, we are in sysvcompat-only codepath, also remove the code targetting other distributions, never compiled as the TARGET_$DISTRO macros are never defined. - systemd-powerd-initctl-support.patch guard with HAVE_SYSV_COMPAT - set-and-use-default-logconsole.patch: fix HAVE_SYSV_COMPAT guards - insserv-generator.patch: Only build when sysvcompat is enabled - vhangup-on-all-consoles.patch add a comment indicating this is a workaround for a kernel bug. - spec: Add option to allow disabling sysvinit compat at build time. - spec: Add option to enable resolved at build time. - spec: Remove all %ifs for !factory products, current systemd releases can neither be built nor installed in older products without upgrading several components of the base system. (removed: 1008-add-msft-compability-rules.patch was only for =< 13.1) - spec: remove all dummy "aliases" to /etc/init.d, that made sense only when those init scripts still existed. (dummy localfs.service source: gone) OBS-URL: https://build.opensuse.org/request/show/286653 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=215
2015-03-01 14:49:19 +01:00
+#ifdef HAVE_SYSV_COMPAT
Accepting request 225960 from Base:System - Add patch getty-generator-with-serial-3270-tty.patch to avoid harmless error messages on not existing getty@3270 files - Replace systemd-big-endian-reply-matching.patch with upstream 0001-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch to solve broken systemd communication with and over dbus (bnc#866732) - Readd patch 1008-add-msft-compability-rules.patch for older code base as 13.1 - Modify pre_checkin.sh to throw an error if a patch will be applied which modifies one of Makefile.am, Makefile.in, or configiure.ac as this breaks bootstrapping - Add second version of make-209-working-on-older-dist.patch to be able to apply for bootstrapping version - Don't require non-existing binutils-gold - Avoid file conflict between udev and systemd (bnc#868230) - Modify patch module-load-handle-SUSE-etc-sysconfig-kernel-module-list.patch to ignore if /etc/sysconfig/kernel does not exist (bnc#865834) - Add patch systemd-big-endian-reply-matching.patch make sure that systemd can talk with dbus-daemon even on big endian systems (bnc#866732) ----------------------------------------------------------------- - Due to previous reason, resurrect systemd-dbus-system-bus-address.patch - Removed pkgconfig(dbus-1) BuildRequires - with 209 and newer, itis only needed for quering default DBus directories, which we nowpass to configure. OBS-URL: https://build.opensuse.org/request/show/225960 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=178
2014-03-18 16:21:15 +01:00
+ usec_t t = now(CLOCK_REALTIME) + delay * USEC_PER_MINUTE;
+ struct sd_shutdown_command c = {
+ .usec = t,
+ .mode = mode,
+ .dry_run = false,
+ .warn_wall = true,
+ };
+
+ union sockaddr_union sockaddr = {
+ .un.sun_family = AF_UNIX,
+ .un.sun_path = "/run/systemd/shutdownd",
+ };
+
+ struct iovec iovec[2] = {{
+ .iov_base = (char*) &c,
+ .iov_len = offsetof(struct sd_shutdown_command, wall_message),
+ }};
+
+ struct msghdr msghdr = {
+ .msg_name = &sockaddr,
+ .msg_namelen = offsetof(struct sockaddr_un, sun_path)
+ + sizeof("/run/systemd/shutdownd") - 1,
+ .msg_iov = iovec,
+ .msg_iovlen = 1,
+ };
+
+ _cleanup_close_ int fd;
+
+ fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
+ if (fd < 0)
+ return -errno;
+
+ if (!isempty(message)) {
+ iovec[1].iov_base = (char*) message;
+ iovec[1].iov_len = strlen(message);
+ msghdr.msg_iovlen++;
+ }
+
+ if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) < 0)
+ return -errno;
Accepting request 286653 from Base:System - mark more subpackages as !bootstrap for systemd-mini usage. - spec : remove --with-firmware-path, firmware loader was removed in v217 - spec: remove --disable-multi-seat-x, gone.(fixed in xorg) - spec: Do not enable systemd-readahead-collect.service and systemd-readahead-replay.service as these do not exist anymore. - spec: drop timedate-add-support-for-openSUSE-version-of-etc-sysconfig.patch Yast was fixed to write all timezone changes exactly how timedated expects things to be done. - spec: remove handle-etc-HOSTNAME.patch, since late 2014 the netcfg package handles the migration from /etc/HOSTNAME to /etc/hostname and owns both files. -spec: remove boot.udev and systemd-journald.init as they currently serve no purpose. - suse-sysv-bootd-support.diff: Remove HAVE_SYSVINIT conditions, we are in sysvcompat-only codepath, also remove the code targetting other distributions, never compiled as the TARGET_$DISTRO macros are never defined. - systemd-powerd-initctl-support.patch guard with HAVE_SYSV_COMPAT - set-and-use-default-logconsole.patch: fix HAVE_SYSV_COMPAT guards - insserv-generator.patch: Only build when sysvcompat is enabled - vhangup-on-all-consoles.patch add a comment indicating this is a workaround for a kernel bug. - spec: Add option to allow disabling sysvinit compat at build time. - spec: Add option to enable resolved at build time. - spec: Remove all %ifs for !factory products, current systemd releases can neither be built nor installed in older products without upgrading several components of the base system. (removed: 1008-add-msft-compability-rules.patch was only for =< 13.1) - spec: remove all dummy "aliases" to /etc/init.d, that made sense only when those init scripts still existed. (dummy localfs.service source: gone) OBS-URL: https://build.opensuse.org/request/show/286653 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=215
2015-03-01 14:49:19 +01:00
+#endif
Accepting request 225960 from Base:System - Add patch getty-generator-with-serial-3270-tty.patch to avoid harmless error messages on not existing getty@3270 files - Replace systemd-big-endian-reply-matching.patch with upstream 0001-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch to solve broken systemd communication with and over dbus (bnc#866732) - Readd patch 1008-add-msft-compability-rules.patch for older code base as 13.1 - Modify pre_checkin.sh to throw an error if a patch will be applied which modifies one of Makefile.am, Makefile.in, or configiure.ac as this breaks bootstrapping - Add second version of make-209-working-on-older-dist.patch to be able to apply for bootstrapping version - Don't require non-existing binutils-gold - Avoid file conflict between udev and systemd (bnc#868230) - Modify patch module-load-handle-SUSE-etc-sysconfig-kernel-module-list.patch to ignore if /etc/sysconfig/kernel does not exist (bnc#865834) - Add patch systemd-big-endian-reply-matching.patch make sure that systemd can talk with dbus-daemon even on big endian systems (bnc#866732) ----------------------------------------------------------------- - Due to previous reason, resurrect systemd-dbus-system-bus-address.patch - Removed pkgconfig(dbus-1) BuildRequires - with 209 and newer, itis only needed for quering default DBus directories, which we nowpass to configure. OBS-URL: https://build.opensuse.org/request/show/225960 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=178
2014-03-18 16:21:15 +01:00
+ return 0;
+}
+
static void request_process(Server *s, const struct init_request *req) {
+ int r;
assert(s);
assert(req);
Accepting request 286653 from Base:System - mark more subpackages as !bootstrap for systemd-mini usage. - spec : remove --with-firmware-path, firmware loader was removed in v217 - spec: remove --disable-multi-seat-x, gone.(fixed in xorg) - spec: Do not enable systemd-readahead-collect.service and systemd-readahead-replay.service as these do not exist anymore. - spec: drop timedate-add-support-for-openSUSE-version-of-etc-sysconfig.patch Yast was fixed to write all timezone changes exactly how timedated expects things to be done. - spec: remove handle-etc-HOSTNAME.patch, since late 2014 the netcfg package handles the migration from /etc/HOSTNAME to /etc/hostname and owns both files. -spec: remove boot.udev and systemd-journald.init as they currently serve no purpose. - suse-sysv-bootd-support.diff: Remove HAVE_SYSVINIT conditions, we are in sysvcompat-only codepath, also remove the code targetting other distributions, never compiled as the TARGET_$DISTRO macros are never defined. - systemd-powerd-initctl-support.patch guard with HAVE_SYSV_COMPAT - set-and-use-default-logconsole.patch: fix HAVE_SYSV_COMPAT guards - insserv-generator.patch: Only build when sysvcompat is enabled - vhangup-on-all-consoles.patch add a comment indicating this is a workaround for a kernel bug. - spec: Add option to allow disabling sysvinit compat at build time. - spec: Add option to enable resolved at build time. - spec: Remove all %ifs for !factory products, current systemd releases can neither be built nor installed in older products without upgrading several components of the base system. (removed: 1008-add-msft-compability-rules.patch was only for =< 13.1) - spec: remove all dummy "aliases" to /etc/init.d, that made sense only when those init scripts still existed. (dummy localfs.service source: gone) OBS-URL: https://build.opensuse.org/request/show/286653 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=215
2015-03-01 14:49:19 +01:00
@@ -184,9 +235,28 @@ static void request_process(Server *s, c
Accepting request 225960 from Base:System - Add patch getty-generator-with-serial-3270-tty.patch to avoid harmless error messages on not existing getty@3270 files - Replace systemd-big-endian-reply-matching.patch with upstream 0001-sd-bus-don-t-look-for-a-64bit-value-when-we-only-hav.patch to solve broken systemd communication with and over dbus (bnc#866732) - Readd patch 1008-add-msft-compability-rules.patch for older code base as 13.1 - Modify pre_checkin.sh to throw an error if a patch will be applied which modifies one of Makefile.am, Makefile.in, or configiure.ac as this breaks bootstrapping - Add second version of make-209-working-on-older-dist.patch to be able to apply for bootstrapping version - Don't require non-existing binutils-gold - Avoid file conflict between udev and systemd (bnc#868230) - Modify patch module-load-handle-SUSE-etc-sysconfig-kernel-module-list.patch to ignore if /etc/sysconfig/kernel does not exist (bnc#865834) - Add patch systemd-big-endian-reply-matching.patch make sure that systemd can talk with dbus-daemon even on big endian systems (bnc#866732) ----------------------------------------------------------------- - Due to previous reason, resurrect systemd-dbus-system-bus-address.patch - Removed pkgconfig(dbus-1) BuildRequires - with 209 and newer, itis only needed for quering default DBus directories, which we nowpass to configure. OBS-URL: https://build.opensuse.org/request/show/225960 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=178
2014-03-18 16:21:15 +01:00
return;
case INIT_CMD_POWERFAIL:
+ r = send_shutdownd(2, SD_SHUTDOWN_POWEROFF,
+ "THE POWER IS FAILED! SYSTEM GOING DOWN! PLEASE LOG OFF NOW!");
+ if (r < 0) {
+ log_warning("Failed to talk to shutdownd, shutdown cancelled: %s", strerror(-r));
+ }
+ return;
case INIT_CMD_POWERFAILNOW:
+ r = send_shutdownd(0, SD_SHUTDOWN_POWEROFF,
+ "THE POWER IS FAILED! LOW BATTERY - EMERGENCY SYSTEM SHUTDOWN!");
+ if (r < 0) {
+ log_warning("Failed to talk to shutdownd, proceeding with immediate shutdown: %s", strerror(-r));
+ reboot(RB_ENABLE_CAD);
+ reboot(RB_POWER_OFF);
+ }
+ return;
+
case INIT_CMD_POWEROK:
- log_warning("Received UPS/power initctl request. This is not implemented in systemd. Upgrade your UPS daemon!");
+ r = send_shutdownd(0, SD_SHUTDOWN_NONE,
+ "THE POWER IS BACK");
+ if (r < 0) {
+ log_warning("Failed to talk to shutdownd, proceeding with shutdown: %s", strerror(-r));
+ }
return;
case INIT_CMD_CHANGECONS: