SHA256
1
0
forked from pool/systemd
systemd/systemd-powerd-initctl-support.patch
Marcus Meissner f2a4cf0154 Accepting request 286574 from home:elvigia:branches:Base:System
- 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)
- systemd-sleep-grub: moved to the grub2 package where it belongs as a
  suspend/resume hook (SR#286533) (drops prepare-suspend-to-disk.patch)

OBS-URL: https://build.opensuse.org/request/show/286574
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=856
2015-02-18 12:10:33 +00:00

122 lines
4.1 KiB
Diff

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(-)
--- systemd-219.orig/src/initctl/initctl.c
+++ systemd-219/src/initctl/initctl.c
@@ -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))
@@ -141,7 +145,54 @@ static void change_runlevel(Server *s, i
}
}
+static int send_shutdownd(unsigned delay, char mode, const char *message) {
+#ifdef HAVE_SYSV_COMPAT
+ 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;
+#endif
+ return 0;
+}
+
static void request_process(Server *s, const struct init_request *req) {
+ int r;
assert(s);
assert(req);
@@ -184,9 +235,28 @@ static void request_process(Server *s, c
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: