SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2014-10-20 14:13:15 +00:00 committed by Git OBS Bridge
parent 6e35d5d56c
commit 5f0cd90f29
7 changed files with 171 additions and 0 deletions

View File

@ -0,0 +1,50 @@
Based on d677d4df80e0ea1c66c691f50867fedd63c6770a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Thu, 16 Oct 2014 19:12:55 -0500
Subject: [PATCH] systemd: continue switch-root even if umount fails
Leaving the old root around seems better than aborting the
switch.
---
src/core/main.c | 2 +-
src/core/switch-root.c | 11 +++++------
2 files changed, 6 insertions(+), 7 deletions(-)
--- src/core/main.c
+++ src/core/main.c 2014-10-20 13:35:35.915837828 +0000
@@ -1848,7 +1848,7 @@ finish:
/* And switch root */
r = switch_root(switch_root_dir);
if (r < 0)
- log_error("Failed to switch root, ignoring: %s", strerror(-r));
+ log_error("Failed to switch root, trying to continue: %s", strerror(-r));
}
args_size = MAX(6, argc+1);
--- src/core/switch-root.c
+++ src/core/switch-root.c 2014-10-20 13:39:58.167121460 +0000
@@ -68,10 +68,9 @@ int switch_root(const char *new_root) {
goto fail;
}
- /* Work-around for a kernel bug: for some reason the kernel
- * refuses switching root if any file systems are mounted
- * MS_SHARED. Hence remount them MS_PRIVATE here as a
- * work-around.
+ /* Work-around for kernel design: the kernel refuses switching
+ * root if any file systems are mounted MS_SHARED. Hence
+ * remount them MS_PRIVATE here as a work-around.
*
* https://bugzilla.redhat.com/show_bug.cgi?id=847418 */
if (mount(NULL, "/", NULL, MS_REC|MS_PRIVATE, NULL) < 0)
@@ -124,8 +123,8 @@ int switch_root(const char *new_root) {
* running off it we need to do this lazily. */
if (umount2("/mnt", MNT_DETACH) < 0) {
r = -errno;
- log_error("Failed to umount old root dir /mnt: %m");
- goto fail;
+ log_error("Failed to lazily umount old root dir /mnt, %s: %m",
+ errno == ENOENT ? "ignoring" : "leaving it around");
}
} else if (mount(new_root, "/", NULL, MS_MOVE, NULL) < 0) {

View File

@ -0,0 +1,44 @@
Based on e7bc519620cb7bcdbe2166fc2a446453769d827e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Thu, 16 Oct 2014 19:15:38 -0500
Subject: [PATCH] systemd: try harder to bind to notify socket
Without the socket open we are going to crash and burn. If for
whatever reason we fail during deserialization we will fail when
trying to open the socket. In this case it is better to unlink the old
socket and maybe lose some messages, than to continue without the
notification socket.
Of course this situation should not happen, but we should handle
it as gracefully as possible anyway.
https://bugzilla.redhat.com/show_bug.cgi?id=1099299
---
src/core/manager.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
--- src/core/manager.c
+++ src/core/manager.c 2014-10-20 13:47:21.035837897 +0000
@@ -572,7 +572,21 @@ static int manager_setup_notify(Manager
r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(sa.un.sun_path+1));
if (r < 0) {
log_error("bind(@%s) failed: %m", sa.un.sun_path+1);
- return -errno;
+ if (errno == EADDRINUSE) {
+ log_notice("Removing %s socket and trying again.", m->notify_socket);
+ r = unlink(m->notify_socket);
+ if (r < 0) {
+ log_error("Failed to remove %s: %m", m->notify_socket);
+ return -EADDRINUSE;
+ }
+
+ r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));
+ if (r < 0) {
+ log_error("bind(@%s) failed: %m", sa.un.sun_path+1);
+ return -errno;
+ }
+ } else
+ return -errno;
}
r = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));

View File

@ -0,0 +1,39 @@
---
src/core/dbus.c | 2 +-
src/libsystemd/sd-bus/bus-util.h | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
--- src/core/dbus.c
+++ src/core/dbus.c 2014-10-17 09:52:47.227838182 +0000
@@ -639,7 +639,7 @@ static int bus_setup_disconnected_match(
}
static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- _cleanup_bus_unref_ sd_bus *bus = NULL;
+ _cleanup_bus_close_unref_ sd_bus *bus = NULL;
_cleanup_close_ int nfd = -1;
Manager *m = userdata;
sd_id128_t id;
--- src/libsystemd/sd-bus/bus-util.h
+++ src/libsystemd/sd-bus/bus-util.h 2014-10-17 09:51:34.368337493 +0000
@@ -137,11 +137,20 @@ typedef struct UnitInfo {
int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u);
+static inline void sd_bus_close_unrefp(sd_bus **bus) {
+ if (*bus) {
+ sd_bus_flush(*bus);
+ sd_bus_close(*bus);
+ sd_bus_unref(*bus);
+ }
+}
+
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_message*, sd_bus_message_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_creds*, sd_bus_creds_unref);
#define _cleanup_bus_unref_ _cleanup_(sd_bus_unrefp)
+#define _cleanup_bus_close_unref_ _cleanup_(sd_bus_close_unrefp)
#define _cleanup_bus_message_unref_ _cleanup_(sd_bus_message_unrefp)
#define _cleanup_bus_creds_unref_ _cleanup_(sd_bus_creds_unrefp)
#define _cleanup_bus_error_free_ _cleanup_(sd_bus_error_free)

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Mon Oct 20 14:10:47 UTC 2014 - werner@suse.de
- Add upstream patches
0001-systemd-continue-switch-root-even-if-umount-fails.patch
0002-systemd-try-harder-to-bind-to-notify-socket.patch
- Add patch avoid-leaking-socket-descriptors.patch to close
file descriptors if an incomming connection can not be handled
due e.g. short memory. Could be related to bsc #901481
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Oct 15 12:03:36 UTC 2014 - werner@suse.de Wed Oct 15 12:03:36 UTC 2014 - werner@suse.de

View File

@ -958,6 +958,12 @@ Patch463: 0002-shell-completion-propose-templates-for-disable-re-en.patch
Patch464: 0003-man-we-don-t-have-Wanted-dependency.patch Patch464: 0003-man-we-don-t-have-Wanted-dependency.patch
# PATCH-FIX-UPSTREAM added at 2014/10/15 # PATCH-FIX-UPSTREAM added at 2014/10/15
Patch465: 0004-selinux-fix-potential-double-free-crash-in-child-pro.patch Patch465: 0004-selinux-fix-potential-double-free-crash-in-child-pro.patch
# PATCH-FIX-UPSTREAM added at 2014/10/20
Patch466: 0001-systemd-continue-switch-root-even-if-umount-fails.patch
# PATCH-FIX-UPSTREAM added at 2014/10/20
Patch467: 0002-systemd-try-harder-to-bind-to-notify-socket.patch
# PATCH-FIX-SUSE added at 2014/10/15
Patch468: avoid-leaking-socket-descriptors.patch
# UDEV PATCHES # UDEV PATCHES
# ============ # ============
@ -1767,6 +1773,9 @@ cp %{SOURCE7} m4/
%patch463 -p0 %patch463 -p0
%patch464 -p0 %patch464 -p0
%patch465 -p0 %patch465 -p0
%patch466 -p0
%patch467 -p0
%patch468 -p0
# udev patches # udev patches
%patch1001 -p1 %patch1001 -p1

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Mon Oct 20 14:10:47 UTC 2014 - werner@suse.de
- Add upstream patches
0001-systemd-continue-switch-root-even-if-umount-fails.patch
0002-systemd-try-harder-to-bind-to-notify-socket.patch
- Add patch avoid-leaking-socket-descriptors.patch to close
file descriptors if an incomming connection can not be handled
due e.g. short memory. Could be related to bsc #901481
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Oct 15 12:03:36 UTC 2014 - werner@suse.de Wed Oct 15 12:03:36 UTC 2014 - werner@suse.de

View File

@ -953,6 +953,12 @@ Patch463: 0002-shell-completion-propose-templates-for-disable-re-en.patch
Patch464: 0003-man-we-don-t-have-Wanted-dependency.patch Patch464: 0003-man-we-don-t-have-Wanted-dependency.patch
# PATCH-FIX-UPSTREAM added at 2014/10/15 # PATCH-FIX-UPSTREAM added at 2014/10/15
Patch465: 0004-selinux-fix-potential-double-free-crash-in-child-pro.patch Patch465: 0004-selinux-fix-potential-double-free-crash-in-child-pro.patch
# PATCH-FIX-UPSTREAM added at 2014/10/20
Patch466: 0001-systemd-continue-switch-root-even-if-umount-fails.patch
# PATCH-FIX-UPSTREAM added at 2014/10/20
Patch467: 0002-systemd-try-harder-to-bind-to-notify-socket.patch
# PATCH-FIX-SUSE added at 2014/10/15
Patch468: avoid-leaking-socket-descriptors.patch
# UDEV PATCHES # UDEV PATCHES
# ============ # ============
@ -1762,6 +1768,9 @@ cp %{SOURCE7} m4/
%patch463 -p0 %patch463 -p0
%patch464 -p0 %patch464 -p0
%patch465 -p0 %patch465 -p0
%patch466 -p0
%patch467 -p0
%patch468 -p0
# udev patches # udev patches
%patch1001 -p1 %patch1001 -p1