systemd-216-11

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2014-11-06 17:00:43 -05:00
parent 668bffb7a0
commit f9f30188c5
9 changed files with 535 additions and 1 deletions

View File

@ -0,0 +1,229 @@
From a48190c9f9b07f735d14743878955511e66206c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Thu, 6 Nov 2014 16:44:06 -0500
Subject: [PATCH] Revert "missing: remove fanotify"
This reverts commit c7e4a7bece7a5c4484d229dd5e8ff01a5d49c62e.
---
Makefile.am | 1 +
configure.ac | 1 +
src/shared/linux/fanotify.h | 98 +++++++++++++++++++++++++++++++++++++++++++++
src/shared/missing.h | 59 +++++++++++++++++++++++++++
4 files changed, 159 insertions(+)
create mode 100644 src/shared/linux/fanotify.h
diff --git a/Makefile.am b/Makefile.am
index 11a3033253..6d869c12ad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -741,6 +741,7 @@ noinst_LTLIBRARIES += \
libsystemd_shared_la_SOURCES = \
src/shared/linux/auto_dev-ioctl.h \
+ src/shared/linux/fanotify.h \
src/shared/ioprio.h \
src/shared/missing.h \
src/shared/initreq.h \
diff --git a/configure.ac b/configure.ac
index e63d3dc809..c2f8f7a548 100644
--- a/configure.ac
+++ b/configure.ac
@@ -306,6 +306,7 @@ RT_LIBS="$LIBS"
AC_SUBST(RT_LIBS)
LIBS="$save_LIBS"
+AC_CHECK_FUNCS([fanotify_init fanotify_mark])
AC_CHECK_FUNCS([memfd_create])
AC_CHECK_FUNCS([__secure_getenv secure_getenv])
AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at, setns, LO_FLAGS_PARTSCAN],
diff --git a/src/shared/linux/fanotify.h b/src/shared/linux/fanotify.h
new file mode 100644
index 0000000000..63531a6b4d
--- /dev/null
+++ b/src/shared/linux/fanotify.h
@@ -0,0 +1,98 @@
+#ifndef _LINUX_FANOTIFY_H
+#define _LINUX_FANOTIFY_H
+
+#include <linux/types.h>
+
+/* the following events that user-space can register for */
+#define FAN_ACCESS 0x00000001 /* File was accessed */
+#define FAN_MODIFY 0x00000002 /* File was modified */
+#define FAN_CLOSE_WRITE 0x00000008 /* Unwrittable file closed */
+#define FAN_CLOSE_NOWRITE 0x00000010 /* Writtable file closed */
+#define FAN_OPEN 0x00000020 /* File was opened */
+
+#define FAN_EVENT_ON_CHILD 0x08000000 /* interested in child events */
+
+/* FIXME currently Q's have no limit.... */
+#define FAN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */
+
+#define FAN_OPEN_PERM 0x00010000 /* File open in perm check */
+#define FAN_ACCESS_PERM 0x00020000 /* File accessed in perm check */
+
+/* helper events */
+#define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) /* close */
+
+/* flags used for fanotify_init() */
+#define FAN_CLOEXEC 0x00000001
+#define FAN_NONBLOCK 0x00000002
+
+#define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK)
+
+/* flags used for fanotify_modify_mark() */
+#define FAN_MARK_ADD 0x00000001
+#define FAN_MARK_REMOVE 0x00000002
+#define FAN_MARK_DONT_FOLLOW 0x00000004
+#define FAN_MARK_ONLYDIR 0x00000008
+#define FAN_MARK_MOUNT 0x00000010
+#define FAN_MARK_IGNORED_MASK 0x00000020
+#define FAN_MARK_IGNORED_SURV_MODIFY 0x00000040
+#define FAN_MARK_FLUSH 0x00000080
+
+#define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\
+ FAN_MARK_REMOVE |\
+ FAN_MARK_DONT_FOLLOW |\
+ FAN_MARK_ONLYDIR |\
+ FAN_MARK_MOUNT |\
+ FAN_MARK_IGNORED_MASK |\
+ FAN_MARK_IGNORED_SURV_MODIFY)
+
+/*
+ * All of the events - we build the list by hand so that we can add flags in
+ * the future and not break backward compatibility. Apps will get only the
+ * events that they originally wanted. Be sure to add new events here!
+ */
+#define FAN_ALL_EVENTS (FAN_ACCESS |\
+ FAN_MODIFY |\
+ FAN_CLOSE |\
+ FAN_OPEN)
+
+/*
+ * All events which require a permission response from userspace
+ */
+#define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM |\
+ FAN_ACCESS_PERM)
+
+#define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\
+ FAN_ALL_PERM_EVENTS |\
+ FAN_Q_OVERFLOW)
+
+#define FANOTIFY_METADATA_VERSION 2
+
+struct fanotify_event_metadata {
+ __u32 event_len;
+ __u32 vers;
+ __u64 mask;
+ __s32 fd;
+ __s32 pid;
+} __attribute__ ((packed));
+
+struct fanotify_response {
+ __s32 fd;
+ __u32 response;
+} __attribute__ ((packed));
+
+/* Legit userspace responses to a _PERM event */
+#define FAN_ALLOW 0x01
+#define FAN_DENY 0x02
+
+/* Helper functions to deal with fanotify_event_metadata buffers */
+#define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
+
+#define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, \
+ (struct fanotify_event_metadata*)(((char *)(meta)) + \
+ (meta)->event_len))
+
+#define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && \
+ (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && \
+ (long)(meta)->event_len <= (long)(len))
+
+#endif /* _LINUX_FANOTIFY_H */
diff --git a/src/shared/missing.h b/src/shared/missing.h
index bb4f8f23a8..c98d0273a3 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -116,6 +116,12 @@ static inline int pivot_root(const char *new_root, const char *put_old) {
#endif
#ifdef __x86_64__
+# ifndef __NR_fanotify_init
+# define __NR_fanotify_init 300
+# endif
+# ifndef __NR_fanotify_mark
+# define __NR_fanotify_mark 301
+# endif
# ifndef __NR_memfd_create
# define __NR_memfd_create 319
# endif
@@ -124,16 +130,69 @@ static inline int pivot_root(const char *new_root, const char *put_old) {
# define __NR_memfd_create 385
# endif
#elif defined _MIPS_SIM
+# if _MIPS_SIM == _MIPS_SIM_ABI32
+# ifndef __NR_fanotify_init
+# define __NR_fanotify_init 4336
+# endif
+# ifndef __NR_fanotify_mark
+# define __NR_fanotify_mark 4337
+# endif
+# elif _MIPS_SIM == _MIPS_SIM_NABI32
+# ifndef __NR_fanotify_init
+# define __NR_fanotify_init 6300
+# endif
+# ifndef __NR_fanotify_mark
+# define __NR_fanotify_mark 6301
+# endif
+# elif _MIPS_SIM == _MIPS_SIM_ABI64
+# ifndef __NR_fanotify_init
+# define __NR_fanotify_init 5295
+# endif
+# ifndef __NR_fanotify_mark
+# define __NR_fanotify_mark 5296
+# endif
+# endif
# ifndef __NR_memfd_create
# warning "__NR_memfd_create not yet defined for MIPS"
# define __NR_memfd_create 0xffffffff
# endif
#else
+# ifndef __NR_fanotify_init
+# define __NR_fanotify_init 338
+# endif
+# ifndef __NR_fanotify_mark
+# define __NR_fanotify_mark 339
+# endif
# ifndef __NR_memfd_create
# define __NR_memfd_create 356
# endif
#endif
+#ifndef HAVE_FANOTIFY_INIT
+static inline int fanotify_init(unsigned int flags, unsigned int event_f_flags) {
+ return syscall(__NR_fanotify_init, flags, event_f_flags);
+}
+#endif
+
+#ifndef HAVE_FANOTIFY_MARK
+static inline int fanotify_mark(int fanotify_fd, unsigned int flags, uint64_t mask,
+ int dfd, const char *pathname) {
+#if defined _MIPS_SIM && _MIPS_SIM == _MIPS_SIM_ABI32 || defined __powerpc__ && !defined __powerpc64__ \
+ || defined __arm__ && !defined __aarch64__
+ union {
+ uint64_t _64;
+ uint32_t _32[2];
+ } _mask;
+ _mask._64 = mask;
+
+ return syscall(__NR_fanotify_mark, fanotify_fd, flags,
+ _mask._32[0], _mask._32[1], dfd, pathname);
+#else
+ return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, pathname);
+#endif
+}
+#endif
+
#ifndef HAVE_MEMFD_CREATE
static inline int memfd_create(const char *name, unsigned int flags) {
return syscall(__NR_memfd_create, name, flags);

View File

@ -0,0 +1,26 @@
From 67ada875bc0563d97e88f77732359d01ef28a404 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 4 Nov 2014 23:45:15 +0000
Subject: [PATCH] udev: Fix parsing of udev.event-timeout kernel parameter.
(cherry picked from commit f671774f52838d35d78e62ddcb781b5b65b3373f)
---
src/udev/udevd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 2e6c71352f..193702cd28 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -994,9 +994,9 @@ static void kernel_cmdline_options(struct udev *udev) {
if (r < 0)
log_warning("Invalid udev.exec-delay ignored: %s", opt + 16);
} else if (startswith(opt, "udev.event-timeout=")) {
- r = safe_atou64(opt + 16, &arg_event_timeout_usec);
+ r = safe_atou64(opt + 19, &arg_event_timeout_usec);
if (r < 0) {
- log_warning("Invalid udev.event-timeout ignored: %s", opt + 16);
+ log_warning("Invalid udev.event-timeout ignored: %s", opt + 19);
break;
}
arg_event_timeout_usec *= USEC_PER_SEC;

View File

@ -0,0 +1,48 @@
From dc2bcafb431344448b93f92a1f6749c9afb30398 Mon Sep 17 00:00:00 2001
From: Colin Guthrie <colin@mageia.org>
Date: Sun, 2 Nov 2014 13:33:16 +0000
Subject: [PATCH] manager: Ensure user's systemd runtime directory exists.
This mirrors code in dbus.c when creating the private socket and
avoids error messages like:
systemd[1353]: bind(/run/user/603/systemd/notify) failed: No such file or directory
systemd[1353]: Failed to fully start up daemon: No such file or directory
(cherry picked from commit 0c3f25e0c1f028d4da9cc5253abf0322230e6835)
---
src/core/manager.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/core/manager.c b/src/core/manager.c
index ff29ae1d9d..47e23ba80e 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -662,9 +662,11 @@ static int manager_setup_notify(Manager *m) {
return -errno;
}
- if (m->running_as == SYSTEMD_SYSTEM)
+ if (m->running_as == SYSTEMD_SYSTEM) {
m->notify_socket = strdup("/run/systemd/notify");
- else {
+ if (!m->notify_socket)
+ return log_oom();
+ } else {
const char *e;
e = getenv("XDG_RUNTIME_DIR");
@@ -674,9 +676,11 @@ static int manager_setup_notify(Manager *m) {
}
m->notify_socket = strappend(e, "/systemd/notify");
+ if (!m->notify_socket)
+ return log_oom();
+
+ mkdir_parents_label(m->notify_socket, 0755);
}
- if (!m->notify_socket)
- return log_oom();
strncpy(sa.un.sun_path, m->notify_socket, sizeof(sa.un.sun_path)-1);
r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));

View File

@ -0,0 +1,31 @@
From c4b4b03e153f8449480977535eb70465b4320b12 Mon Sep 17 00:00:00 2001
From: Colin Guthrie <colin@mageia.org>
Date: Wed, 5 Nov 2014 15:29:41 +0000
Subject: [PATCH] udev hwdb: Change error message regarding missing hwdb.bin
back to debug.
When used in an initramfs, it's expected that the hwdb.bin file is
not present (it makes for a very large initramfs otherwise).
While it's nice to tell the user about this, as it's not strictly
speaking an error we really shouldn't be so forceful in our
reporting.
(cherry picked from commit 8232e39e7cf32071e11b3b04839e6c98fbc81d0f)
---
src/libudev/libudev-hwdb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c
index a1cfc0bd5a..0716072d9a 100644
--- a/src/libudev/libudev-hwdb.c
+++ b/src/libudev/libudev-hwdb.c
@@ -296,7 +296,7 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
}
if (!hwdb->f) {
- udev_err(udev, "hwdb.bin does not exist, please run udevadm hwdb --update");
+ udev_dbg(udev, "hwdb.bin does not exist, please run udevadm hwdb --update");
udev_hwdb_unref(hwdb);
return NULL;
}

View File

@ -0,0 +1,33 @@
From 4ce940e9a436ef9d19bd52bd9c2f7ac24d1c842c Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 6 Nov 2014 15:20:29 +0100
Subject: [PATCH] systemctl: when invokes as "reboot -f", sync()
We do this in the clean shutdown path in shutdown.c, hence we should do
is for "reboot -f", too.
(cherry picked from commit 4a3ad39957399c4a30fc472a804e72907ecaa4f9)
---
src/systemctl/systemctl.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 8481a9b20c..207a5e78dc 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -6948,8 +6948,13 @@ done:
static int halt_now(enum action a) {
-/* Make sure C-A-D is handled by the kernel from this
- * point on... */
+ /* The kernel will automaticall flush ATA disks and suchlike
+ * on reboot(), but the file systems need to be synce'd
+ * explicitly in advance. */
+ sync();
+
+ /* Make sure C-A-D is handled by the kernel from this point
+ * on... */
reboot(RB_ENABLE_CAD);
switch (a) {

View File

@ -0,0 +1,42 @@
From dd5e5ef3392a83525d23aa9a523e9d187fb7faaf Mon Sep 17 00:00:00 2001
From: Michal Schmidt <mschmidt@redhat.com>
Date: Thu, 6 Nov 2014 16:48:11 +0100
Subject: [PATCH] shared: create files even if the SELinux policy has no
context for them
The SELinux policy defines no context for some files. E.g.:
$ matchpathcon /run/lock/subsys /dev/mqueue
/run/lock/subsys <<none>>
/dev/mqueue <<none>>
We still need to be able to create them.
In this case selabel_lookup_raw() returns ENOENT. We should then skip
setfscreatecon(), but still return success.
It was broken since c34255bdb2 ("label: unify code to make directories,
symlinks").
(cherry picked from commit 2d58aa4692e9fc47911bff5d064ba3e328c35369)
---
src/shared/selinux-util.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c
index 1eddd17d27..6bd3bf1c80 100644
--- a/src/shared/selinux-util.c
+++ b/src/shared/selinux-util.c
@@ -332,9 +332,13 @@ int mac_selinux_create_file_prepare(const char *path, mode_t mode) {
r = selabel_lookup_raw(label_hnd, &filecon, newpath, mode);
}
- if (r < 0 && errno != ENOENT)
+ /* No context specified by the policy? Proceed without setting it. */
+ if (r < 0 && errno == ENOENT)
+ return 0;
+
+ if (r < 0)
r = -errno;
- else if (r == 0) {
+ else {
r = setfscreatecon(filecon);
if (r < 0) {
log_enforcing("Failed to set SELinux security context %s for %s: %m", filecon, path);

View File

@ -0,0 +1,67 @@
From a59400d10830f01a5eb657d41d992df42cd8952e Mon Sep 17 00:00:00 2001
From: Michal Schmidt <mschmidt@redhat.com>
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.
(cherry picked from commit 4b5d8d0f22ae61ceb45a25391354ba53b43ee992)
---
src/core/shutdown.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index 20cf526ba2..03cfddc543 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -75,7 +75,9 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 1);
assert(argv);
- 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:
@@ -113,6 +115,13 @@ static int parse_argv(int argc, char *argv[]) {
break;
+ case '\001':
+ if (!arg_verb)
+ arg_verb = optarg;
+ else
+ log_error("Excess arguments, ignoring");
+ break;
+
case '?':
return -EINVAL;
@@ -120,15 +129,11 @@ static int parse_argv(int argc, char *argv[]) {
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;
}

View File

@ -0,0 +1,45 @@
From 3da3e6e3eb1453a9f2ddf4a1455d1ca9dfe9ec49 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sun, 2 Nov 2014 19:08:06 -0500
Subject: [PATCH] Accept StartTimeout* options for compatibility
Assignments of 0/none are ignored, all others are warned about.
---
src/core/main.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/core/main.c b/src/core/main.c
index d48604e673..a9ca34d8cb 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -623,6 +623,9 @@ static int config_parse_join_controllers(const char *unit,
}
static int parse_config_file(void) {
+ usec_t start_timeout_usec = 0;
+ FailureAction start_timeout_action = FAILURE_ACTION_NONE;
+ char *start_timeout_reboot_arg = NULL;
const ConfigTableItem items[] = {
{ "Manager", "LogLevel", config_parse_level2, 0, NULL },
@@ -670,6 +673,9 @@ static int parse_config_file(void) {
{ "Manager", "DefaultCPUAccounting", config_parse_bool, 0, &arg_default_cpu_accounting },
{ "Manager", "DefaultBlockIOAccounting", config_parse_bool, 0, &arg_default_blockio_accounting },
{ "Manager", "DefaultMemoryAccounting", config_parse_bool, 0, &arg_default_memory_accounting },
+ { "Manager", "StartTimeoutSec", config_parse_sec, 0, &start_timeout_usec },
+ { "Manager", "StartTimeoutAction", config_parse_failure_action, 0, &start_timeout_action },
+ { "Manager", "StartTimeoutRebootArgument",config_parse_string, 0, &start_timeout_reboot_arg },
{}
};
@@ -681,6 +687,10 @@ static int parse_config_file(void) {
config_item_table_lookup, items,
false, false, true, NULL);
+ if (start_timeout_usec != 0 || start_timeout_action != FAILURE_ACTION_NONE)
+ log_warning("StartTimeoutSec, StartTimeoutAction, StartTimeoutRebootArgument settings have\n"
+ "been replaced by JobTimeoutSec, JobTimeoutAction, JobTimeoutReboot, ignoring.");
+
return 0;
}

View File

@ -16,7 +16,7 @@
Name: systemd
Url: http://www.freedesktop.org/wiki/Software/systemd
Version: 216
Release: 10%{?gitcommit:.git%{gitcommit}}%{?dist}
Release: 11%{?gitcommit:.git%{gitcommit}}%{?dist}
# For a breakdown of the licensing, see README
License: LGPLv2+ and MIT and GPLv2+
Summary: A System and Service Manager
@ -80,6 +80,14 @@ Patch0036: 0036-manager-do-not-print-timing-when-running-in-test-mod.patch
Patch0037: 0037-unit-do-not-order-timers.target-before-basic.target.patch
Patch0038: 0038-units-order-sd-journal-flush-after-sd-remount-fs.patch
Patch0039: 0039-units-make-systemd-journald.service-Type-notify.patch
Patch0040: 0040-Revert-missing-remove-fanotify.patch
Patch0041: 0041-udev-Fix-parsing-of-udev.event-timeout-kernel-parame.patch
Patch0042: 0042-manager-Ensure-user-s-systemd-runtime-directory-exis.patch
Patch0043: 0043-udev-hwdb-Change-error-message-regarding-missing-hwd.patch
Patch0044: 0044-systemctl-when-invokes-as-reboot-f-sync.patch
Patch0045: 0045-shared-create-files-even-if-the-SELinux-policy-has-n.patch
Patch0046: 0046-shutdown-fix-arguments-to-run-initramfs-shutdown.patch
Patch0996: Accept-StartTimeout-options-for-compatibility.patch
Patch0997: units-remove-dev-log-to-always-create-symlink.patch
@ -869,6 +877,11 @@ getent passwd systemd-journal-upload >/dev/null 2>&1 || useradd -r -l -g systemd
%{_datadir}/systemd/gatewayd
%changelog
* Tue Nov 04 2014 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 216-11
- Fixes for #1161100, #986667.
- Fix udev timeout parsing.
- Use sync before reboot -f.
* Tue Nov 04 2014 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 216-10
- Fix for #1159641.