From d869ff62486aebda8c18a65d2d19fa38de97469e6a78a1b567cb0162400766c4 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Thu, 13 Nov 2014 13:01:19 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=815 --- ...sh-for-reboot-or-hddown-for-poweroff.patch | 527 +----------------- ...sole-setup-when-switching-from-vgaco.patch | 60 ++ ...-arguments-to-run-initramfs-shutdown.patch | 70 +++ ...g-at-the-next-unichar-honour-the-siz.patch | 29 + parse-crypttab-for-noauto-option.patch | 2 +- systemd-mini.changes | 21 + systemd-mini.spec | 9 + systemd.changes | 21 + systemd.spec | 9 + 9 files changed, 239 insertions(+), 509 deletions(-) create mode 100644 0001-login-rerun-vconsole-setup-when-switching-from-vgaco.patch create mode 100644 0002-shutdown-fix-arguments-to-run-initramfs-shutdown.patch create mode 100644 0003-utf8-when-looking-at-the-next-unichar-honour-the-siz.patch diff --git a/0001-add-hdflush-for-reboot-or-hddown-for-poweroff.patch b/0001-add-hdflush-for-reboot-or-hddown-for-poweroff.patch index 57ca912b..b4aeb6f4 100644 --- a/0001-add-hdflush-for-reboot-or-hddown-for-poweroff.patch +++ b/0001-add-hdflush-for-reboot-or-hddown-for-poweroff.patch @@ -1,497 +1,16 @@ -This seems to be a SUSE specific patch. Here we add the check for unmaintained -disk like devices to be able to flush and maybe shut them down. Also we add the -missing sync() system call for the direct halt/reboot systemctl command. Then we -use the system halt as gfallback if poweroff fails for both the direct poweroff -systemctl command as well as for the systemd-shutdown utility. - --- - Makefile.am | 11 + - src/core/hdflush.c | 365 ++++++++++++++++++++++++++++++++++++++++++++++ - src/core/hdflush.h | 25 +++ - src/core/shutdown.c | 12 + - src/systemctl/systemctl.c | 25 ++- - 5 files changed, 429 insertions(+), 9 deletions(-) + systemd-209/src/core/shutdown.c | 4 ++++ + systemd-209/src/systemctl/systemctl.c | 22 +++++++++++++++------- + 2 files changed, 19 insertions(+), 7 deletions(-) ---- systemd-209/Makefile.am -+++ systemd-209/Makefile.am 2014-01-28 11:06:56.000000000 +0000 -@@ -1004,7 +1004,9 @@ libsystemd_core_la_SOURCES = \ - src/core/audit-fd.c \ - src/core/audit-fd.h \ - src/core/async.c \ -- src/core/async.h -+ src/core/async.h \ -+ src/core/hdflush.c \ -+ src/core/hdflush.h - - if HAVE_KMOD - libsystemd_core_la_SOURCES += \ -@@ -1522,6 +1524,8 @@ systemd_shutdown_SOURCES = \ - src/core/shutdown.c \ - src/core/mount-setup.c \ - src/core/mount-setup.h \ -+ src/core/hdflush.c \ -+ src/core/hdflush.h \ - src/core/killall.h \ - src/core/killall.c - -@@ -1818,7 +1822,9 @@ systemd_cgroups_agent_LDADD = \ - - # ------------------------------------------------------------------------------ - systemctl_SOURCES = \ -- src/systemctl/systemctl.c -+ src/systemctl/systemctl.c \ -+ src/core/hdflush.c \ -+ src/core/hdflush.h - - systemctl_LDADD = \ - libsystemd-units.la \ -@@ -1826,6 +1832,7 @@ systemctl_LDADD = \ - libsystemd-internal.la \ - libsystemd-logs.la \ - libsystemd-journal-internal.la \ -+ libudev-internal.la \ - libsystemd-shared.la - - # ------------------------------------------------------------------------------ ---- systemd-209/src/core/hdflush.c -+++ systemd-209/src/core/hdflush.c 2014-01-28 10:58:56.000000000 +0000 -@@ -0,0 +1,367 @@ -+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ -+ -+/*** -+ This file is part of systemd. -+ -+ Copyright 2014 Werner Fink -+ -+ systemd is free software; you can redistribute it and/or modify it -+ under the terms of the GNU Lesser General Public License as published by -+ the Free Software Foundation; either version 2.1 of the License, or -+ (at your option) any later version. -+ -+ systemd 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public License -+ along with systemd; If not, see . -+***/ -+ -+/* -+ * Find all disks on the system, list out IDE, unmanaged ATA disks, and -+ * USB sticks flush the cache of those and optional shut them down. -+ */ -+ -+#include -+#include -+#ifdef LIST_DEBUG -+# include -+#endif -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#ifdef WORDS_BIGENDIAN -+# include -+#endif -+ -+#include "hdflush.h" -+ -+/* Used in flush_cache_ext(), compare with */ -+#define IDBYTES 512 -+#define MASK_EXT 0xE000 /* Bit 15 shall be zero, bit 14 shall be one, bit 13 flush cache ext */ -+#define TEST_EXT 0x6000 -+ -+/* Maybe set in list_disks() and used in do_standby_disk() */ -+#define DISK_IS_IDE 0x00000001 -+#define DISK_IS_SATA 0x00000002 -+#define DISK_EXTFLUSH 0x00000004 -+#define DISK_REMOVABLE 0x00000008 -+#define DISK_MANAGED 0x00000010 -+#define DISK_FLUSHONLY 0x00000020 -+ -+struct sysfs { -+ struct udev *udev; -+ struct udev_enumerate *num; -+ struct udev_list_entry *item; -+ char *devnode; -+ size_t size; -+}; -+ -+static int flush_cache_ext(const struct sysfs *sysfs); -+ -+static struct sysfs * open_sysfs(void) -+{ -+ static struct sysfs sysfs; -+ sysfs.udev = udev_new(); -+ if (!sysfs.udev) -+ goto err; -+ sysfs.num = udev_enumerate_new(sysfs.udev); -+ if (!sysfs.num) -+ goto err; -+ if (udev_enumerate_add_match_subsystem(sysfs.num, "block") < 0) -+ goto err; -+ if (udev_enumerate_add_match_sysname(sysfs.num, "sd?") < 0) -+ goto err; -+ if (udev_enumerate_add_match_sysname(sysfs.num, "hd?") < 0) -+ goto err; -+ if (udev_enumerate_scan_devices(sysfs.num) < 0) -+ goto err; -+ sysfs.item = udev_enumerate_get_list_entry(sysfs.num); -+ sysfs.devnode = NULL; -+ sysfs.size = 0; -+ return &sysfs; -+err: -+ if (sysfs.num) -+ udev_unref(sysfs.udev); -+ if (sysfs.udev) -+ udev_unref(sysfs.udev); -+ return NULL; -+} -+ -+static void close_sysfs(struct sysfs *sysfs) -+{ -+ if (sysfs->num) -+ udev_enumerate_unref(sysfs->num); -+ if (sysfs->udev) -+ udev_unref(sysfs->udev); -+ if (sysfs->devnode) -+ free(sysfs->devnode); -+ sysfs->devnode = NULL; -+} -+ -+ -+static char *list_disks(struct sysfs *sysfs, unsigned int* flags) -+{ -+ struct udev_device *device, *parent; -+ struct udev_list_entry *item; -+ const char *devnode; -+ char path[PATH_MAX]; -+ -+ device = NULL; -+next: -+ if (device) -+ udev_device_unref(device); -+ if (sysfs->devnode) -+ free(sysfs->devnode); -+ sysfs->devnode = NULL; -+ sysfs->size = 0; -+ *flags = 0; -+ -+ if (!sysfs->item) -+ goto empty; -+ item = sysfs->item; -+ sysfs->item = udev_list_entry_get_next(sysfs->item); -+ -+ if (!(device = udev_device_new_from_syspath(sysfs->udev, udev_list_entry_get_name(item)))) -+ goto out; -+ if (!(devnode = udev_device_get_devnode(device))) -+ goto out; -+ if (!(sysfs->devnode = strdup(devnode))) -+ goto out; -+ -+ path[0] = '\0'; -+ parent = udev_device_get_parent(device); -+ if (parent) { -+ const char *sysname, *devpath; -+ struct udev_device *disk; -+ const char *value; -+ int ret; -+ -+ sysname = udev_device_get_sysname(parent); -+ devpath = udev_device_get_devpath(parent); -+ -+ strcpy(path, "/sys"); -+ strcat(path, devpath); -+ strcat(path, "/scsi_disk/"); -+ strcat(path, sysname); -+ -+ disk = udev_device_new_from_syspath(sysfs->udev, path); -+ if (disk) { -+ value = udev_device_get_sysattr_value(disk, "manage_start_stop"); -+ udev_device_unref(disk); -+ -+ if (value && *value != '0') { -+ *flags = DISK_MANAGED; -+#ifndef LIST_DEBUG -+ goto next; /* Device managed by the kernel */ -+#endif -+ } -+ } -+ -+ value = udev_device_get_sysattr_value(device, "size"); -+ if (value && *value) -+ sysfs->size = (size_t)atoll(value); -+ -+ value = udev_device_get_sysattr_value(device, "removable"); -+ if (value && *value != '0') { -+ *flags |= DISK_REMOVABLE; -+ -+ if ((ret = flush_cache_ext(sysfs))) { -+ if (ret < 0) -+ goto next; -+ *flags |= DISK_EXTFLUSH; -+ } -+ goto out; /* Removable disk like USB stick */ -+ } -+ -+ value = udev_device_get_sysname(device); -+ if (value && *value == 'h') { -+ *flags |= DISK_IS_IDE; -+ -+ if ((ret = flush_cache_ext(sysfs))) { -+ if (ret < 0) -+ goto next; -+ *flags |= DISK_EXTFLUSH; -+ } -+ goto out; /* IDE disk found */ -+ } -+ -+ value = udev_device_get_sysattr_value(parent, "vendor"); -+ if (value && strncmp(value, "ATA", 3) == 0) { -+ *flags |= (DISK_IS_IDE|DISK_IS_SATA); -+ -+ if ((ret = flush_cache_ext(sysfs))) { -+ if (ret < 0) -+ goto next; -+ *flags |= DISK_EXTFLUSH; -+ } -+ goto out; /* SATA disk to shutdown */ -+ } -+ goto next; -+ } -+out: -+ udev_device_unref(device); -+empty: -+ return sysfs->devnode; -+} -+#ifndef LIST_DEBUG -+/* -+ * Check IDE/(S)ATA hard disk identity for -+ * the FLUSH CACHE EXT bit set. -+ */ -+static int flush_cache_ext(const struct sysfs *sysfs) -+{ -+#ifndef WIN_IDENTIFY -+#define WIN_IDENTIFY 0xEC -+#endif -+ unsigned char args[4+IDBYTES]; -+ unsigned short *id = (unsigned short*)(&args[4]); -+ int fd = -1, ret = 0; -+ -+ if (sysfs->size < (1<<28)) -+ goto out; /* small disk */ -+ -+ if ((fd = open(sysfs->devnode, O_RDONLY|O_NONBLOCK|O_CLOEXEC)) < 0) -+ goto out; -+ -+ memset(&args[0], 0, sizeof(args)); -+ args[0] = WIN_IDENTIFY; -+ args[3] = 1; -+ if (ioctl(fd, HDIO_DRIVE_CMD, &args)) -+ goto out; -+#ifdef WORDS_BIGENDIAN -+# if 0 -+ { -+ const unsigned short *end = id + IDBYTES/2; -+ const unsigned short *from = id; -+ unsigned short *to = id; -+ -+ while (from < end) -+ *to++ = bswap_16(*from++); -+ } -+# else -+ id[83] = bswap_16(id[83]); -+# endif -+#endif -+ if ((id[83] & MASK_EXT) == TEST_EXT) -+ ret = 1; -+out: -+ if (fd >= 0) -+ close(fd); -+ return ret; -+} -+ -+/* -+ * Put an IDE/SCSI/SATA disk in standby mode. -+ * Code stolen from hdparm.c -+ */ -+static int do_standby_disk(struct sysfs *sysfs, unsigned int flags) -+{ -+#ifndef WIN_STANDBYNOW1 -+#define WIN_STANDBYNOW1 0xE0 -+#endif -+#ifndef WIN_STANDBYNOW2 -+#define WIN_STANDBYNOW2 0x94 -+#endif -+#ifndef WIN_FLUSH_CACHE_EXT -+#define WIN_FLUSH_CACHE_EXT 0xEA -+#endif -+#ifndef WIN_FLUSH_CACHE -+#define WIN_FLUSH_CACHE 0xE7 -+#endif -+ unsigned char flush1[4] = {WIN_FLUSH_CACHE_EXT,0,0,0}; -+ unsigned char flush2[4] = {WIN_FLUSH_CACHE,0,0,0}; -+ unsigned char stdby1[4] = {WIN_STANDBYNOW1,0,0,0}; -+ unsigned char stdby2[4] = {WIN_STANDBYNOW2,0,0,0}; -+ int fd, ret; -+ -+ if ((fd = open(sysfs->devnode, O_RDWR|O_NONBLOCK|O_CLOEXEC)) < 0) -+ return -1; -+ -+ switch (flags & DISK_EXTFLUSH) { -+ case DISK_EXTFLUSH: -+ if ((ret = ioctl(fd, HDIO_DRIVE_CMD, &flush1)) == 0) -+ break; -+ /* Extend flush rejected, try standard flush */ -+ default: -+ ret = ioctl(fd, HDIO_DRIVE_CMD, &flush2) && -+ ioctl(fd, BLKFLSBUF); -+ break; -+ } -+ -+ if ((flags & DISK_FLUSHONLY) == 0x0) { -+ ret = ioctl(fd, HDIO_DRIVE_CMD, &stdby1) && -+ ioctl(fd, HDIO_DRIVE_CMD, &stdby2); -+ } -+ -+ close(fd); -+ -+ if (ret) -+ return -1; -+ return 0; -+} -+#endif -+#ifdef LIST_DEBUG -+int main() -+{ -+ char *disk; -+ unsigned int flags; -+ struct sysfs *sysfs = open_sysfs(); -+ if (!sysfs) -+ goto err; -+ while ((disk = list_disks(sysfs, &flags))) -+ fprintf(stdout, "%s\n", sysfs->devnode); -+ close_sysfs(sysfs); -+err: -+ return 0; -+} -+#else -+/* -+ * List all disks and put them in standby mode. -+ * This has the side-effect of flushing the writecache, -+ * which is exactly what we want on poweroff. -+ */ -+void hddown(void) -+{ -+ struct sysfs *sysfs; -+ unsigned int flags; -+ char *disk; -+ -+ if (!(sysfs = open_sysfs())) -+ return; -+ -+ while ((disk = list_disks(sysfs, &flags))) -+ do_standby_disk(sysfs, flags); -+ -+ close_sysfs(sysfs); -+} -+ -+/* -+ * List all disks and cause them to flush their buffers. -+ */ -+void hdflush(void) -+{ -+ struct sysfs *sysfs; -+ unsigned int flags; -+ char *disk; -+ -+ if (!(sysfs = open_sysfs())) -+ return; -+ -+ while ((disk = list_disks(sysfs, &flags))) -+ do_standby_disk(sysfs, (flags|DISK_FLUSHONLY)); -+ -+ close_sysfs(sysfs); -+} -+#endif ---- systemd-209/src/core/hdflush.h -+++ systemd-209/src/core/hdflush.h 2014-01-28 11:00:08.000000000 +0000 -@@ -0,0 +1,25 @@ -+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ -+ -+#pragma once -+ -+/*** -+ This file is part of systemd. -+ -+ Copyright 2014 Werner Fink -+ -+ systemd is free software; you can redistribute it and/or modify it -+ under the terms of the GNU Lesser General Public License as published by -+ the Free Software Foundation; either version 2.1 of the License, or -+ (at your option) any later version. -+ -+ systemd 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 -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public License -+ along with systemd; If not, see . -+***/ -+ -+void hdflush(void); -+void hddown(void); --- systemd-209/src/core/shutdown.c +++ systemd-209/src/core/shutdown.c 2014-02-28 11:17:22.000000000 +0000 -@@ -40,6 +40,7 @@ - #include "missing.h" - #include "log.h" - #include "fileio.h" -+#include "hdflush.h" - #include "umount.h" - #include "util.h" - #include "mkdir.h" -@@ -225,7 +226,8 @@ int main(int argc, char *argv[]) { - _cleanup_free_ char *cgroup = NULL; - char *arguments[3]; - unsigned retries; -- int cmd, r; -+ unsigned cmd; -+ int r; - - log_parse_environment(); - r = parse_argv(argc, argv); -@@ -388,8 +390,13 @@ int main(int argc, char *argv[]) { - * on reboot(), but the file systems need to be synce'd - * explicitly in advance. So let's do this here, but not - * needlessly slow down containers. */ -- if (!in_container) -+ if (!in_container) { - sync(); -+ if (cmd == RB_POWER_OFF || cmd == RB_HALT_SYSTEM) -+ hddown(); -+ else -+ hdflush(); -+ } - - switch (cmd) { - -@@ -449,6 +456,10 @@ int main(int argc, char *argv[]) { +@@ -449,6 +449,10 @@ int main(int argc, char *argv[]) { } reboot(cmd); + -+ if (cmd == RB_POWER_OFF) ++ if (cmd == (int)RB_POWER_OFF) + reboot(RB_HALT_SYSTEM); + if (errno == EPERM && in_container) { @@ -499,15 +18,7 @@ systemctl command as well as for the systemd-shutdown utility. * CAP_SYS_BOOT just exit, this will kill our --- systemd-209/src/systemctl/systemctl.c +++ systemd-209/src/systemctl/systemctl.c 2014-02-28 11:19:35.000000000 +0000 -@@ -67,6 +67,7 @@ - #include "logs-show.h" - #include "socket-util.h" - #include "fileio.h" -+#include "hdflush.h" - #include "env-util.h" - #include "bus-util.h" - #include "bus-message.h" -@@ -93,6 +94,7 @@ static bool arg_no_pager = false; +@@ -93,6 +93,7 @@ static bool arg_no_pager = false; static bool arg_no_wtmp = false; static bool arg_no_wall = false; static bool arg_no_reload = false; @@ -515,7 +26,7 @@ systemctl command as well as for the systemd-shutdown utility. static bool arg_show_types = false; static bool arg_ignore_inhibitors = false; static bool arg_dry = false; -@@ -5566,6 +5568,7 @@ static int halt_parse_argv(int argc, cha +@@ -5578,6 +5579,7 @@ static int halt_parse_argv(int argc, cha { "reboot", no_argument, NULL, ARG_REBOOT }, { "force", no_argument, NULL, 'f' }, { "wtmp-only", no_argument, NULL, 'w' }, @@ -523,7 +34,7 @@ systemctl command as well as for the systemd-shutdown utility. { "no-wtmp", no_argument, NULL, 'd' }, { "no-wall", no_argument, NULL, ARG_NO_WALL }, {} -@@ -5617,10 +5620,13 @@ static int halt_parse_argv(int argc, cha +@@ -5629,10 +5631,13 @@ static int halt_parse_argv(int argc, cha case 'i': case 'h': @@ -538,25 +49,25 @@ systemctl command as well as for the systemd-shutdown utility. case '?': return -EINVAL; -@@ -6266,16 +6272,24 @@ static int halt_now(enum action a) { +@@ -6274,20 +6279,23 @@ done: + + static int halt_now(enum action a) { + +-/* Make sure C-A-D is handled by the kernel from this ++ if (!arg_no_sync) ++ sync(); ++ ++ /* Make sure C-A-D is handled by the kernel from this * point on... */ reboot(RB_ENABLE_CAD); -- switch (a) { -+ if (!arg_no_sync) -+ sync(); + switch (a) { - case ACTION_HALT: - log_info("Halting."); - reboot(RB_HALT_SYSTEM); - return -errno; -+ if (a == ACTION_POWEROFF || a == ACTION_HALT) -+ hddown(); -+ else -+ hdflush(); -+ -+ switch (a) { - +- case ACTION_POWEROFF: log_info("Powering off."); reboot(RB_POWER_OFF); diff --git a/0001-login-rerun-vconsole-setup-when-switching-from-vgaco.patch b/0001-login-rerun-vconsole-setup-when-switching-from-vgaco.patch new file mode 100644 index 00000000..ba00c036 --- /dev/null +++ b/0001-login-rerun-vconsole-setup-when-switching-from-vgaco.patch @@ -0,0 +1,60 @@ +From f6ba8671d83f9fce9a00045d8fa399a1c07ba7fc Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Wed, 5 Nov 2014 08:30:52 -0500 +Subject: [PATCH] login: rerun vconsole-setup when switching from vgacon to + fbcon + +The initialization performed by systemd-vconsole-setup is reset +when changing console drivers (say from vgacon to fbcon), so we +need to run it in that case. + +See +http://lists.freedesktop.org/archives/systemd-devel/2014-October/023919.html +http://lists.freedesktop.org/archives/systemd-devel/2014-October/024423.html +http://lists.freedesktop.org/archives/systemd-devel/2014-November/024881.html + +This commit adds a udev rule to make systemd-vconsole-setup get run when +the fbcon device becomes available. + +(david: moved into new file 90-vconsole.rules instead of 71-seats.rules; + build-failures are on me, not on Ray) +--- + Makefile.am | 3 +++ + src/vconsole/90-vconsole.rules | 11 +++++++++++ + 2 files changed, 14 insertions(+) + create mode 100644 src/vconsole/90-vconsole.rules + +diff --git Makefile.am Makefile.am +index 3686103..f614b86 100644 +--- Makefile.am ++++ Makefile.am +@@ -4439,6 +4439,9 @@ rootlibexec_PROGRAMS += \ + nodist_systemunit_DATA += \ + units/systemd-vconsole-setup.service + ++dist_udevrules_DATA += \ ++ src/vconsole/90-vconsole.rules ++ + SYSINIT_TARGET_WANTS += \ + systemd-vconsole-setup.service + endif +diff --git src/vconsole/90-vconsole.rules src/vconsole/90-vconsole.rules +new file mode 100644 +index 0000000..bf6a9ef +--- /dev/null ++++ src/vconsole/90-vconsole.rules +@@ -0,0 +1,11 @@ ++# This file is part of systemd. ++# ++# systemd is free software; you can redistribute it and/or modify it ++# under the terms of the GNU Lesser General Public License as published by ++# the Free Software Foundation; either version 2.1 of the License, or ++# (at your option) any later version. ++ ++# Kernel resets vconsole state when changing console drivers so run ++# systemd-vconsole-setup when fbcon loads ++ ++ACTION=="add", SUBSYSTEM=="graphics", KERNEL=="fbcon", RUN+="/usr/lib/systemd/systemd-vconsole-setup" +-- +1.7.9.2 + diff --git a/0002-shutdown-fix-arguments-to-run-initramfs-shutdown.patch b/0002-shutdown-fix-arguments-to-run-initramfs-shutdown.patch new file mode 100644 index 00000000..12ad7d2d --- /dev/null +++ b/0002-shutdown-fix-arguments-to-run-initramfs-shutdown.patch @@ -0,0 +1,70 @@ +Based on 4b5d8d0f22ae61ceb45a25391354ba53b43ee992 Mon Sep 17 00:00:00 2001 +From: Michal Schmidt +Date: Thu, 6 Nov 2014 22:24:13 +0100 +Subject: [PATCH] shutdown: fix arguments to /run/initramfs/shutdown + +Our initrd interface specifies that the verb is in argv[1]. +This is where systemd passes it to systemd-shutdown, but getopt +permutes argv[]. This confuses dracut's shutdown script: + Shutdown called with argument '--log-level'. Rebooting! + +getopt can be convinced to not permute argv[] by having '-' as the first +character of optstring. Let's use it. This requires changing the way +non-option arguments (in our case, the verb) are processed. + +This fixes a bug where the system would reboot instead of powering off. +--- + src/core/shutdown.c | 24 +++++++++++------------- + 1 file changed, 11 insertions(+), 13 deletions(-) + +--- src/core/shutdown.c ++++ src/core/shutdown.c 2014-11-10 14:14:20.869519112 +0000 +@@ -75,9 +75,9 @@ static int parse_argv(int argc, char *ar + assert(argc >= 1); + assert(argv); + +- opterr = 0; +- +- while ((c = getopt_long(argc, argv, ":", options, NULL)) >= 0) ++ /* "-" prevents getopt from permuting argv[] and moving the verb away ++ * from argv[1]. Our interface to initrd promises it'll be there. */ ++ while ((c = getopt_long(argc, argv, "-", options, NULL)) >= 0) + switch (c) { + + case ARG_LOG_LEVEL: +@@ -115,27 +115,25 @@ static int parse_argv(int argc, char *ar + + break; + +- case '?': +- log_error("Unknown option %s.", argv[optind-1]); +- return -EINVAL; ++ case '\001': ++ if (!arg_verb) ++ arg_verb = optarg; ++ else ++ log_error("Excess arguments, ignoring"); ++ break; + +- case ':': +- log_error("Missing argument to %s.", argv[optind-1]); ++ case '?': + return -EINVAL; + + default: + assert_not_reached("Unhandled option code."); + } + +- if (optind >= argc) { ++ if (!arg_verb) { + log_error("Verb argument missing."); + return -EINVAL; + } + +- arg_verb = argv[optind]; +- +- if (optind + 1 < argc) +- log_error("Excess arguments, ignoring"); + return 0; + } + diff --git a/0003-utf8-when-looking-at-the-next-unichar-honour-the-siz.patch b/0003-utf8-when-looking-at-the-next-unichar-honour-the-siz.patch new file mode 100644 index 00000000..bc69be20 --- /dev/null +++ b/0003-utf8-when-looking-at-the-next-unichar-honour-the-siz.patch @@ -0,0 +1,29 @@ +Based on 144b3d9e093dd9310cd9590bec039dc43a7e2ad6 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 7 Nov 2014 16:34:00 +0100 +Subject: [PATCH] utf8: when looking at the next unichar, honour the size + parameter, in utf8_is_printable_newline() + +--- + src/shared/utf8.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +--- src/shared/utf8.c ++++ src/shared/utf8.c 2014-11-10 14:20:28.094539264 +0000 +@@ -143,9 +143,14 @@ bool utf8_is_printable_newline(const cha + + for (p = (const uint8_t*) str; length;) { + int encoded_len = utf8_encoded_valid_unichar((const char *)p); +- int val = utf8_encoded_to_unichar((const char*)p); ++ int val; + +- if (encoded_len < 0 || val < 0 || is_unicode_control(val) || ++ if (encoded_len < 0 || ++ (size_t) encoded_len > length) ++ return false; ++ ++ val = utf8_encoded_to_unichar((const char*)p); ++ if (val < 0 || is_unicode_control(val) || + (!newline && val == '\n')) + return false; + diff --git a/parse-crypttab-for-noauto-option.patch b/parse-crypttab-for-noauto-option.patch index 13f576db..8709dc70 100644 --- a/parse-crypttab-for-noauto-option.patch +++ b/parse-crypttab-for-noauto-option.patch @@ -44,7 +44,7 @@ Index: systemd-210/src/fstab-generator/fstab-generator.c + } + + if (strcmp((what + 12), name) == 0) { -+ if (strstr(options, "noauto")) ++ if (options && strstr(options, "noauto")) + return 0; + + return 1; diff --git a/systemd-mini.changes b/systemd-mini.changes index f28ae0c7..5cf2f6ca 100644 --- a/systemd-mini.changes +++ b/systemd-mini.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Nov 13 12:59:05 UTC 2014 - werner@suse.de + +- Change patch 0001-add-hdflush-for-reboot-or-hddown-for-poweroff.patch + to skip hdflush as well as hddown but only use halt as fallback + for poweroff as well as synch in systemctl before any reboot command + (compare with commit 4a3ad39957399c4a30fc472a804e72907ecaa4f9) + ------------------------------------------------------------------- Thu Nov 13 09:54:35 UTC 2014 - rmilasan@suse.com @@ -5,12 +13,25 @@ Thu Nov 13 09:54:35 UTC 2014 - rmilasan@suse.com 'rotational' equals 0, usually SSDs (bnc#904517). Add 1095-set-ssd-disk-to-use-deadline-scheduler.patch +------------------------------------------------------------------- +Thu Nov 13 07:50:49 UTC 2014 - thomas.blume@suse.com + +- fix systemd-fstab-generator crypttab parsing (bnc#903963) + ------------------------------------------------------------------- Tue Nov 11 19:10:35 UTC 2014 - gber@opensuse.org - Add pm-utils-hooks-compat.sh in order to run pm-utils sleep hooks from systemd (boo#904828) +------------------------------------------------------------------- +Mon Nov 10 14:23:00 UTC 2014 - werner@suse.de + +- Add upstream patches + 0001-login-rerun-vconsole-setup-when-switching-from-vgaco.patch + 0002-shutdown-fix-arguments-to-run-initramfs-shutdown.patch + 0003-utf8-when-looking-at-the-next-unichar-honour-the-siz.patch + ------------------------------------------------------------------- Mon Nov 10 12:39:35 UTC 2014 - werner@suse.de diff --git a/systemd-mini.spec b/systemd-mini.spec index 42566a7e..c7192bae 100644 --- a/systemd-mini.spec +++ b/systemd-mini.spec @@ -1029,6 +1029,12 @@ Patch498: 0008-journald-fix-memory-leak-on-error-path.patch Patch499: 0009-units-make-systemd-journald.service-Type-notify.patch # PATCH-FIX-UPSTREAM added at 2014/11/07 Patch500: 0010-hwdb-Update-database-of-Bluetooth-company-identifier.patch +# PATCH-FIX-UPSTREAM added at 2014/11/10 +Patch501: 0001-login-rerun-vconsole-setup-when-switching-from-vgaco.patch +# PATCH-FIX-UPSTREAM added at 2014/11/10 +Patch502: 0002-shutdown-fix-arguments-to-run-initramfs-shutdown.patch +# PATCH-FIX-UPSTREAM added at 2014/11/10 +Patch503: 0003-utf8-when-looking-at-the-next-unichar-honour-the-siz.patch # UDEV PATCHES # ============ @@ -1888,6 +1894,9 @@ cp %{SOURCE7} m4/ %patch498 -p0 %patch499 -p0 %patch500 -p0 +%patch501 -p0 +%patch502 -p0 +%patch503 -p0 # udev patches %patch1001 -p1 diff --git a/systemd.changes b/systemd.changes index f28ae0c7..5cf2f6ca 100644 --- a/systemd.changes +++ b/systemd.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Nov 13 12:59:05 UTC 2014 - werner@suse.de + +- Change patch 0001-add-hdflush-for-reboot-or-hddown-for-poweroff.patch + to skip hdflush as well as hddown but only use halt as fallback + for poweroff as well as synch in systemctl before any reboot command + (compare with commit 4a3ad39957399c4a30fc472a804e72907ecaa4f9) + ------------------------------------------------------------------- Thu Nov 13 09:54:35 UTC 2014 - rmilasan@suse.com @@ -5,12 +13,25 @@ Thu Nov 13 09:54:35 UTC 2014 - rmilasan@suse.com 'rotational' equals 0, usually SSDs (bnc#904517). Add 1095-set-ssd-disk-to-use-deadline-scheduler.patch +------------------------------------------------------------------- +Thu Nov 13 07:50:49 UTC 2014 - thomas.blume@suse.com + +- fix systemd-fstab-generator crypttab parsing (bnc#903963) + ------------------------------------------------------------------- Tue Nov 11 19:10:35 UTC 2014 - gber@opensuse.org - Add pm-utils-hooks-compat.sh in order to run pm-utils sleep hooks from systemd (boo#904828) +------------------------------------------------------------------- +Mon Nov 10 14:23:00 UTC 2014 - werner@suse.de + +- Add upstream patches + 0001-login-rerun-vconsole-setup-when-switching-from-vgaco.patch + 0002-shutdown-fix-arguments-to-run-initramfs-shutdown.patch + 0003-utf8-when-looking-at-the-next-unichar-honour-the-siz.patch + ------------------------------------------------------------------- Mon Nov 10 12:39:35 UTC 2014 - werner@suse.de diff --git a/systemd.spec b/systemd.spec index 2b3dcc5b..deadb6ff 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1024,6 +1024,12 @@ Patch498: 0008-journald-fix-memory-leak-on-error-path.patch Patch499: 0009-units-make-systemd-journald.service-Type-notify.patch # PATCH-FIX-UPSTREAM added at 2014/11/07 Patch500: 0010-hwdb-Update-database-of-Bluetooth-company-identifier.patch +# PATCH-FIX-UPSTREAM added at 2014/11/10 +Patch501: 0001-login-rerun-vconsole-setup-when-switching-from-vgaco.patch +# PATCH-FIX-UPSTREAM added at 2014/11/10 +Patch502: 0002-shutdown-fix-arguments-to-run-initramfs-shutdown.patch +# PATCH-FIX-UPSTREAM added at 2014/11/10 +Patch503: 0003-utf8-when-looking-at-the-next-unichar-honour-the-siz.patch # UDEV PATCHES # ============ @@ -1883,6 +1889,9 @@ cp %{SOURCE7} m4/ %patch498 -p0 %patch499 -p0 %patch500 -p0 +%patch501 -p0 +%patch502 -p0 +%patch503 -p0 # udev patches %patch1001 -p1