More patches for outstanding bugs

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2015-03-23 00:32:52 -04:00
parent ffc19a0568
commit 77e6ed9659
22 changed files with 1380 additions and 0 deletions

View File

@ -0,0 +1,38 @@
From 317e24365d3d88b7a5282577a35bc8f259737f93 Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Wed, 11 Mar 2015 22:23:38 +0100
Subject: [PATCH] libudev: monitor - fix error path in send_device
Return -errno rather than -1 in case sendmsg() fails.
(cherry picked from commit a4445e88cece0444c66d70876b03065158dd4685)
---
src/libudev/libudev-monitor.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index 3f1fee7f7e..d0486e3d1e 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -749,12 +749,20 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor,
* If we send to a multicast group, we will get
* ECONNREFUSED, which is expected.
*/
- if (destination != NULL)
+ if (destination)
smsg.msg_name = &destination->snl;
else
smsg.msg_name = &udev_monitor->snl_destination;
smsg.msg_namelen = sizeof(struct sockaddr_nl);
count = sendmsg(udev_monitor->sock, &smsg, 0);
+ if (count < 0) {
+ if (!destination && errno == ECONNREFUSED) {
+ log_debug("passed unknown number of bytes to netlink monitor %p", udev_monitor);
+ return 0;
+ } else
+ return -errno;
+ }
+
log_debug("passed %zi bytes to netlink monitor %p", count, udev_monitor);
return count;
}

View File

@ -0,0 +1,23 @@
From 84d7bc201f8875bed45c9516fcec62d5f82d3718 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 14 Mar 2015 17:41:53 -0400
Subject: [PATCH] core: remove left-over debug message
(cherry picked from commit bdb26d423a7f992bec5c28e17894c684d770d6f3)
---
src/core/load-fragment.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 90bf5634c8..f17a82fcdf 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -634,8 +634,6 @@ int config_parse_exec(const char *unit,
n[k] = NULL;
- log_debug("path: %s", path ?: n[0]);
-
if (!n[0])
reason = "Empty executable name or zeroeth argument";
else if (!string_is_safe(path ?: n[0]))

View File

@ -0,0 +1,23 @@
From b238b0eaf71449e128480bb5a5875a4b51cafd6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 14 Mar 2015 17:56:13 -0400
Subject: [PATCH] units: there is no systemd-udev-hwdb-update.service
(cherry picked from commit d99ce93383028f08470b6d334bc1a31ca8d16b22)
---
units/systemd-udevd.service.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/units/systemd-udevd.service.in b/units/systemd-udevd.service.in
index f6acd6fe4c..2791f73ac3 100644
--- a/units/systemd-udevd.service.in
+++ b/units/systemd-udevd.service.in
@@ -10,7 +10,7 @@ Description=udev Kernel Device Manager
Documentation=man:systemd-udevd.service(8) man:udev(7)
DefaultDependencies=no
Wants=systemd-udevd-control.socket systemd-udevd-kernel.socket
-After=systemd-udevd-control.socket systemd-udevd-kernel.socket systemd-udev-hwdb-update.service systemd-sysusers.service
+After=systemd-udevd-control.socket systemd-udevd-kernel.socket systemd-hwdb-update.service systemd-sysusers.service
Before=sysinit.target
ConditionPathIsReadWrite=/sys

View File

@ -0,0 +1,29 @@
From 5112d77f6a279cfa1cf4c1f3eac896f475650952 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 14 Mar 2015 20:14:39 -0400
Subject: [PATCH] util: remove redundant debug message
mar 14 20:05:34 fedora22 systemd[4058]: /usr/lib/systemd/system-generators/kdump-dep-generator.sh will be executed.
mar 14 20:05:34 fedora22 systemd[4058]: Spawned /usr/lib/systemd/system-generators/kdump-dep-generator.sh as 4059.
The second line already says everything.
(cherry picked from commit 7034e9db51d0b6f8e1dbbe9127393c6fbc06fe28)
---
src/shared/util.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/shared/util.c b/src/shared/util.c
index 85487230a2..1e1bf944f2 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -4115,8 +4115,7 @@ static int do_execute(char **directories, usec_t timeout, char *argv[]) {
if (null_or_empty_path(path)) {
log_debug("%s is empty (a mask).", path);
continue;
- } else
- log_debug("%s will be executed.", path);
+ }
pid = fork();
if (pid < 0) {

View File

@ -0,0 +1,26 @@
From a6a1e98b4e16777989ada937402f0b5373dad4a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 14 Mar 2015 20:24:47 -0400
Subject: [PATCH] tmpfiles: remove redundant debug message
Mar 13 19:48:30 adam.happyassassin.net systemd-tmpfiles[970]: "/var/lib/machines" has right mode 40700
Mar 13 19:48:30 adam.happyassassin.net systemd-tmpfiles[970]: /var/lib/machines created successfully.
(cherry picked from commit 51bfdaf66c381793d2f39ad891f3411a55927da6)
---
src/tmpfiles/tmpfiles.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 1e10968164..73a9c9d5b6 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -1209,8 +1209,6 @@ static int create_item(Item *i) {
break;
}
- log_debug("%s created successfully.", i->path);
-
return 0;
}

View File

@ -0,0 +1,275 @@
From 68f8c0b9eeeead72fbdf90b32e5cf01862d9c351 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 14 Mar 2015 21:46:59 -0400
Subject: [PATCH] sysv-generator: initialize LookupPaths just once
With debugging on, sysv-generator would print the full set of
lookup paths for *every* sysv script.
While at it, pass LookupPaths as a pointer in sysv-generator,
and constify it everywhere.
(cherry picked from commit a8ffe6fbcbfdba39aef8dce8b298b3e0cb377c0e)
---
src/shared/install.c | 55 ++++++++++++++++++++++---------------
src/shared/install.h | 11 +++++++-
src/shared/path-lookup.c | 1 +
src/shared/path-lookup.h | 3 +-
src/sysv-generator/sysv-generator.c | 14 +++++-----
5 files changed, 53 insertions(+), 31 deletions(-)
diff --git a/src/shared/install.c b/src/shared/install.c
index 65f1c245c6..92b8d6e8ef 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1084,7 +1084,7 @@ static int unit_file_load(
static int unit_file_search(
InstallContext *c,
InstallInfo *info,
- LookupPaths *paths,
+ const LookupPaths *paths,
const char *root_dir,
bool allow_symlink,
bool load,
@@ -1153,7 +1153,7 @@ static int unit_file_search(
}
static int unit_file_can_install(
- LookupPaths *paths,
+ const LookupPaths *paths,
const char *root_dir,
const char *name,
bool allow_symlink,
@@ -1317,7 +1317,7 @@ static int install_info_symlink_wants(
static int install_info_symlink_link(
InstallInfo *i,
- LookupPaths *paths,
+ const LookupPaths *paths,
const char *config_path,
const char *root_dir,
bool force,
@@ -1345,7 +1345,7 @@ static int install_info_symlink_link(
static int install_info_apply(
InstallInfo *i,
- LookupPaths *paths,
+ const LookupPaths *paths,
const char *config_path,
const char *root_dir,
bool force,
@@ -1377,7 +1377,7 @@ static int install_info_apply(
static int install_context_apply(
InstallContext *c,
- LookupPaths *paths,
+ const LookupPaths *paths,
const char *config_path,
const char *root_dir,
bool force,
@@ -1424,7 +1424,7 @@ static int install_context_apply(
static int install_context_mark_for_removal(
InstallContext *c,
- LookupPaths *paths,
+ const LookupPaths *paths,
Set **remove_symlinks_to,
const char *config_path,
const char *root_dir) {
@@ -1785,39 +1785,28 @@ int unit_file_get_default(
return -ENOENT;
}
-UnitFileState unit_file_get_state(
+UnitFileState unit_file_lookup_state(
UnitFileScope scope,
const char *root_dir,
+ const LookupPaths *paths,
const char *name) {
- _cleanup_lookup_paths_free_ LookupPaths paths = {};
UnitFileState state = _UNIT_FILE_STATE_INVALID;
char **i;
_cleanup_free_ char *path = NULL;
int r;
- assert(scope >= 0);
- assert(scope < _UNIT_FILE_SCOPE_MAX);
- assert(name);
-
- if (root_dir && scope != UNIT_FILE_SYSTEM)
- return -EINVAL;
+ assert(paths);
if (!unit_name_is_valid(name, TEMPLATE_VALID))
return -EINVAL;
- r = lookup_paths_init_from_scope(&paths, scope, root_dir);
- if (r < 0)
- return r;
-
- STRV_FOREACH(i, paths.unit_path) {
+ STRV_FOREACH(i, paths->unit_path) {
struct stat st;
char *partial;
bool also = false;
free(path);
- path = NULL;
-
path = path_join(root_dir, *i, name);
if (!path)
return -ENOMEM;
@@ -1858,7 +1847,7 @@ UnitFileState unit_file_get_state(
else if (r > 0)
return state;
- r = unit_file_can_install(&paths, root_dir, partial, true, &also);
+ r = unit_file_can_install(paths, root_dir, partial, true, &also);
if (r < 0 && errno != ENOENT)
return r;
else if (r > 0)
@@ -1873,6 +1862,28 @@ UnitFileState unit_file_get_state(
return r < 0 ? r : state;
}
+UnitFileState unit_file_get_state(
+ UnitFileScope scope,
+ const char *root_dir,
+ const char *name) {
+
+ _cleanup_lookup_paths_free_ LookupPaths paths = {};
+ int r;
+
+ assert(scope >= 0);
+ assert(scope < _UNIT_FILE_SCOPE_MAX);
+ assert(name);
+
+ if (root_dir && scope != UNIT_FILE_SYSTEM)
+ return -EINVAL;
+
+ r = lookup_paths_init_from_scope(&paths, scope, root_dir);
+ if (r < 0)
+ return r;
+
+ return unit_file_lookup_state(scope, root_dir, &paths, name);
+}
+
int unit_file_query_preset(UnitFileScope scope, const char *root_dir, const char *name) {
_cleanup_strv_free_ char **files = NULL;
char **p;
diff --git a/src/shared/install.h b/src/shared/install.h
index 357be0f92d..3ca39397e6 100644
--- a/src/shared/install.h
+++ b/src/shared/install.h
@@ -23,6 +23,7 @@
#include "hashmap.h"
#include "unit-name.h"
+#include "path-lookup.h"
typedef enum UnitFileScope {
UNIT_FILE_SYSTEM,
@@ -98,7 +99,15 @@ int unit_file_set_default(UnitFileScope scope, const char *root_dir, const char
int unit_file_get_default(UnitFileScope scope, const char *root_dir, char **name);
int unit_file_add_dependency(UnitFileScope scope, bool runtime, const char *root_dir, char **files, char *target, UnitDependency dep, bool force, UnitFileChange **changes, unsigned *n_changes);
-UnitFileState unit_file_get_state(UnitFileScope scope, const char *root_dir, const char *filename);
+UnitFileState unit_file_lookup_state(
+ UnitFileScope scope,
+ const char *root_dir,
+ const LookupPaths *paths,
+ const char *name);
+UnitFileState unit_file_get_state(
+ UnitFileScope scope,
+ const char *root_dir,
+ const char *filename);
int unit_file_get_list(UnitFileScope scope, const char *root_dir, Hashmap *h);
diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c
index 291a2f4054..812730be1c 100644
--- a/src/shared/path-lookup.c
+++ b/src/shared/path-lookup.c
@@ -31,6 +31,7 @@
#include "strv.h"
#include "path-util.h"
#include "path-lookup.h"
+#include "install.h"
int user_config_home(char **config_home) {
const char *e;
diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h
index 2ec888da81..f1925eef69 100644
--- a/src/shared/path-lookup.h
+++ b/src/shared/path-lookup.h
@@ -22,7 +22,8 @@
***/
#include "macro.h"
-#include "install.h"
+
+typedef enum UnitFileScope UnitFileScope;
typedef struct LookupPaths {
char **unit_path;
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 6e39b449eb..0125ca27d9 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -723,10 +723,10 @@ static int fix_order(SysvStub *s, Hashmap *all_services) {
return 0;
}
-static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
+static int enumerate_sysv(const LookupPaths *lp, Hashmap *all_services) {
char **path;
- STRV_FOREACH(path, lp.sysvinit_path) {
+ STRV_FOREACH(path, lp->sysvinit_path) {
_cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
@@ -768,7 +768,7 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
if (!fpath)
return log_oom();
- if (unit_file_get_state(UNIT_FILE_SYSTEM, NULL, name) >= 0) {
+ if (unit_file_lookup_state(UNIT_FILE_SYSTEM, NULL, lp, name) >= 0) {
log_debug("Native unit for %s already exists, skipping", name);
continue;
}
@@ -793,7 +793,7 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
return 0;
}
-static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
+static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_services) {
char **p;
unsigned i;
_cleanup_closedir_ DIR *d = NULL;
@@ -804,7 +804,7 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
_cleanup_set_free_ Set *shutdown_services = NULL;
int r = 0;
- STRV_FOREACH(p, lp.sysvrcnd_path)
+ STRV_FOREACH(p, lp->sysvrcnd_path)
for (i = 0; i < ELEMENTSOF(rcnd_table); i ++) {
struct dirent *de;
@@ -954,13 +954,13 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
- r = enumerate_sysv(lp, all_services);
+ r = enumerate_sysv(&lp, all_services);
if (r < 0) {
log_error("Failed to generate units for all init scripts.");
return EXIT_FAILURE;
}
- r = set_dependencies_from_rcnd(lp, all_services);
+ r = set_dependencies_from_rcnd(&lp, all_services);
if (r < 0) {
log_error("Failed to read runlevels from rcnd links.");
return EXIT_FAILURE;

View File

@ -0,0 +1,31 @@
From 1708f0d4156c6579691728bebe429ece10f5a2be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 14 Mar 2015 21:49:10 -0400
Subject: [PATCH] core: do not use quotes around virt and arch
Quotes are useful when the string can contain spaces or be otherwise
confusing. Not possible with those two.
(cherry picked from commit d3f86679783aee216d60b125acfb5f39a0df555f)
---
src/core/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/main.c b/src/core/main.c
index ba2de85bd3..fd527d4d63 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1537,11 +1537,11 @@ int main(int argc, char *argv[]) {
detect_virtualization(&virtualization);
if (virtualization)
- log_info("Detected virtualization '%s'.", virtualization);
+ log_info("Detected virtualization %s.", virtualization);
write_container_id();
- log_info("Detected architecture '%s'.", architecture_to_string(uname_architecture()));
+ log_info("Detected architecture %s.", architecture_to_string(uname_architecture()));
if (in_initrd())
log_info("Running in initial RAM disk.");

View File

@ -0,0 +1,37 @@
From 61504cbece6425b0e3acbb594aeed458fdc674e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 14 Mar 2015 22:22:49 -0400
Subject: [PATCH] udev: downgrade "has devpath" and "filled with db file"
messages
Udev debug messages have to be significantly overhauled... For now
just downgrade those two. They are responsible for approximately 25%
of debug output during boot and are rather useless.
(cherry picked from commit cdd45c1ffbf790facd1817757832aa25d9211967)
---
src/libudev/libudev-device.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 9863901a33..e408942221 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -613,7 +613,7 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile)
}
fclose(f);
- log_debug("device %p filled with db file data", udev_device);
+ log_trace("device %p filled with db file data", udev_device);
return 0;
}
@@ -775,7 +775,7 @@ _public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, con
return NULL;
udev_device_set_syspath(udev_device, path);
- log_debug("device %p has devpath '%s'", udev_device, udev_device_get_devpath(udev_device));
+ log_trace("device %p has devpath '%s'", udev_device, udev_device_get_devpath(udev_device));
return udev_device;
}

View File

@ -0,0 +1,36 @@
From 46746489010823c9a7cea7c39593aeb68ceee176 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 14 Mar 2015 22:35:30 -0400
Subject: [PATCH] cryptsetup-generator: remove warning about crypttab access
mode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This file contains no privileged data — just names of devices to decrypt
and files containing keys. On a running system most of this can be inferred from
the device tree anyway.
(cherry picked from commit 71e4e1258436e7e81d772aed52a02bb5d9c87cb8)
---
src/cryptsetup/cryptsetup-generator.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index 05061c0704..db8337f92a 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -377,13 +377,6 @@ static int add_crypttab_devices(void) {
return 0;
}
- /* If we readd support for specifying passphrases
- * directly in crypttab we should upgrade the warning
- * below, though possibly only if a passphrase is
- * specified directly. */
- if (st.st_mode & 0005)
- log_debug("/etc/crypttab is world-readable. This is usually not a good idea.");
-
for (;;) {
int r, k;
char line[LINE_MAX], *l, *uuid;

View File

@ -0,0 +1,23 @@
From 69dd93bbe3444dc583581d59389567ab7d59bd6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 14 Mar 2015 22:56:01 -0400
Subject: [PATCH] sysctl: tweak debug message
(cherry picked from commit 924bc14fef39373f4523664207007a6c82c2b2d5)
---
src/sysctl/sysctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 2415d84526..98b146a9ab 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -121,7 +121,7 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno
return log_error_errno(r, "Failed to open file '%s', ignoring: %m", path);
}
- log_debug("parse: %s", path);
+ log_debug("Parsing %s", path);
while (!feof(f)) {
char l[LINE_MAX], *p, *value, *new_value, *property, *existing;
void *v;

View File

@ -0,0 +1,39 @@
From 9555e12d82200b02ad8c54858bcf469e6f2d7e82 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Wed, 4 Mar 2015 10:31:42 -0500
Subject: [PATCH] journald: add syslog fields for audit messages
Audit messages would be displayed as "unknown[1]".
Also specify AUTH as facility... This seems to be the closest match
(/* security/authorization messages */).
(cherry picked from commit cd556b6ca8aec8dd371806afedec45f852f8f724)
---
src/journal/journald-audit.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c
index c2f1545cc9..46eb82fa34 100644
--- a/src/journal/journald-audit.c
+++ b/src/journal/journald-audit.c
@@ -373,7 +373,7 @@ static void process_audit_string(Server *s, int type, const char *data, size_t s
if (isempty(p))
return;
- n_iov_allocated = N_IOVEC_META_FIELDS + 5;
+ n_iov_allocated = N_IOVEC_META_FIELDS + 7;
iov = new(struct iovec, n_iov_allocated);
if (!iov) {
log_oom();
@@ -392,6 +392,10 @@ static void process_audit_string(Server *s, int type, const char *data, size_t s
sprintf(id_field, "_AUDIT_ID=%" PRIu64, id);
IOVEC_SET_STRING(iov[n_iov++], id_field);
+ assert_cc(32 == LOG_AUTH);
+ IOVEC_SET_STRING(iov[n_iov++], "SYSLOG_FACILITY=32");
+ IOVEC_SET_STRING(iov[n_iov++], "SYSLOG_IDENTIFIER=audit");
+
m = alloca(strlen("MESSAGE=<audit-") + DECIMAL_STR_MAX(int) + strlen("> ") + strlen(p) + 1);
sprintf(m, "MESSAGE=<audit-%i> %s", type, p);
IOVEC_SET_STRING(iov[n_iov++], m);

View File

@ -0,0 +1,32 @@
From 11c04e6ae1056e46687471a1fda6f8684ff6aa10 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sun, 15 Mar 2015 12:12:19 -0400
Subject: [PATCH] core: remove useless debug message
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
Mar 13 19:48:28 adam.happyassassin.net systemd[1]: Collecting (null)
(cherry picked from commit cc3bc3e6203e0c615e31b8b68796362e1385f28a)
---
src/core/manager.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/core/manager.c b/src/core/manager.c
index 203a6a0a1a..7483a96ec6 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -844,7 +844,8 @@ static unsigned manager_dispatch_gc_queue(Manager *m) {
if (u->gc_marker == gc_marker + GC_OFFSET_BAD ||
u->gc_marker == gc_marker + GC_OFFSET_UNSURE) {
- log_unit_debug(u->id, "Collecting %s", u->id);
+ if (u->id)
+ log_unit_debug(u->id, "Collecting %s", u->id);
u->gc_marker = gc_marker + GC_OFFSET_BAD;
unit_add_to_cleanup_queue(u);
}

View File

@ -0,0 +1,23 @@
From 9270c8ffa5a7f12f510772eba0eb40fbb16ad163 Mon Sep 17 00:00:00 2001
From: Alison Chaiken <alison_chaiken@mentor.com>
Date: Sun, 15 Mar 2015 16:26:14 -0700
Subject: [PATCH] man: standard-conf: change directory reference to wildcard
(cherry picked from commit 1d940aa32913c108e0282ebd359b2eb999ffeadf)
---
man/standard-conf.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/man/standard-conf.xml b/man/standard-conf.xml
index 36af45927d..004f53f70c 100644
--- a/man/standard-conf.xml
+++ b/man/standard-conf.xml
@@ -54,7 +54,7 @@
directories, and has the lowest precedence; entries in a file in
any configuration directory override entries in the single
configuration file. Files in the
- <filename>logind.conf.d/</filename> configuration subdirectories
+ <filename>*.conf.d/</filename> configuration subdirectories
are sorted by their filename in lexicographic order, regardless of
which of the subdirectories they reside in. If multiple files
specify the same option, the entry in the file with the

View File

@ -0,0 +1,33 @@
From 9ad7334d68fe2187968c4716097a24575835ab04 Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin.pitt@ubuntu.com>
Date: Fri, 13 Mar 2015 08:35:59 +0100
Subject: [PATCH] core: don't change removed devices to state "tentative"
Commit 628c89c introduced the "tentative" device state, which caused
devices to go from "plugged" to "tentative" on a remove uevent. This
breaks the cleanup of stale mounts (see commit 3b48ce4), as that only
applies to "dead" devices.
The "tentative" state only really makes sense on adding a device when
we don't know where it was coming from (i. e. not from udev). But when
we get a device removal from udev we definitively know that it's gone,
so change the device state back to "dead" as before 628c89c.
(cherry picked from commit 496068a8288084ab3ecf8b179a8403ecff1a6be8)
---
src/core/device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/device.c b/src/core/device.c
index 4ff8827219..cc4ebd2c87 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -421,7 +421,7 @@ static void device_update_found_one(Device *d, bool add, DeviceFound found, bool
if (now) {
if (d->found & DEVICE_FOUND_UDEV)
device_set_state(d, DEVICE_PLUGGED);
- else if (d->found != DEVICE_NOT_FOUND)
+ else if (add && d->found != DEVICE_NOT_FOUND)
device_set_state(d, DEVICE_TENTATIVE);
else
device_set_state(d, DEVICE_DEAD);

View File

@ -0,0 +1,75 @@
From 0659783c379ec16f0556f8e78b30be9fd70f45aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 21 Mar 2015 11:31:16 -0400
Subject: [PATCH] fstab-generator: ignore invalid swap priority
A failed priority is not something worth stopping boot over. Most people
have only one swap device, in which case priority is irrelevant, and even
if there is more than one swap device, they are all usable, and ignoring the
priority field should only result in some loss of performance.
The kernel will report the priority as -1 if not set, so it's easy for
people to make this mistake.
https://bugzilla.redhat.com/show_bug.cgi?id=1204336
(cherry picked from commit e0952d9d021234e79f3a70f33a9e5d201872a417)
---
src/fstab-generator/fstab-generator.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 5662b5fde1..8e2f522bd0 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -54,9 +54,10 @@ static int add_swap(
bool noauto,
bool nofail) {
- _cleanup_free_ char *name = NULL, *unit = NULL, *lnk = NULL;
+ _cleanup_free_ char *name = NULL, *unit = NULL, *lnk = NULL, *filtered = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r, pri = -1;
+ const char *opts;
assert(what);
assert(me);
@@ -71,9 +72,17 @@ static int add_swap(
return 0;
}
- r = fstab_find_pri(me->mnt_opts, &pri);
- if (r < 0)
- return log_error_errno(r, "Failed to parse priority: %m");
+ opts = me->mnt_opts;
+ r = fstab_find_pri(opts, &pri);
+ if (r < 0) {
+ log_error_errno(r, "Failed to parse priority, ignoring: %m");
+
+ /* Remove invalid pri field */
+ r = fstab_filter_options(opts, "pri\0", NULL, NULL, &filtered);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse options: %m");
+ opts = filtered;
+ }
name = unit_name_from_path(what, ".swap");
if (!name)
@@ -106,15 +115,15 @@ static int add_swap(
if (pri >= 0)
fprintf(f, "Priority=%i\n", pri);
- if (!isempty(me->mnt_opts) && !streq(me->mnt_opts, "defaults"))
- fprintf(f, "Options=%s\n", me->mnt_opts);
+ if (!isempty(opts) && !streq(opts, "defaults"))
+ fprintf(f, "Options=%s\n", opts);
r = fflush_and_check(f);
if (r < 0)
return log_error_errno(r, "Failed to write unit file %s: %m", unit);
/* use what as where, to have a nicer error message */
- r = generator_write_timeouts(arg_dest, what, what, me->mnt_opts, NULL);
+ r = generator_write_timeouts(arg_dest, what, what, opts, NULL);
if (r < 0)
return r;

View File

@ -0,0 +1,192 @@
From 8ab04e3a6f3160114c679dc9045e89c8dd4d4a75 Mon Sep 17 00:00:00 2001
From: Michael Olbrich <m.olbrich@pengutronix.de>
Date: Wed, 18 Mar 2015 14:04:55 +0100
Subject: [PATCH] missing.h: add more btrfs types and defines
(cherry picked from commit 8e8ba79229bb82248a568f5929143a66f4be45b7)
---
src/shared/missing.h | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 151 insertions(+)
diff --git a/src/shared/missing.h b/src/shared/missing.h
index 802b4957e0..ca670cea43 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -230,12 +230,59 @@ static inline int getrandom(void *buffer, size_t count, unsigned flags) {
#define BTRFS_UUID_SIZE 16
#endif
+#ifndef BTRFS_SUBVOL_RDONLY
+#define BTRFS_SUBVOL_RDONLY (1ULL << 1)
+#endif
+
+#ifndef BTRFS_SUBVOL_NAME_MAX
+#define BTRFS_SUBVOL_NAME_MAX 4039
+#endif
+
+#ifndef BTRFS_INO_LOOKUP_PATH_MAX
+#define BTRFS_INO_LOOKUP_PATH_MAX 4080
+#endif
+
+#ifndef BTRFS_SEARCH_ARGS_BUFSIZE
+#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
+#endif
+
#ifndef HAVE_LINUX_BTRFS_H
struct btrfs_ioctl_vol_args {
int64_t fd;
char name[BTRFS_PATH_NAME_MAX + 1];
};
+struct btrfs_qgroup_limit {
+ __u64 flags;
+ __u64 max_rfer;
+ __u64 max_excl;
+ __u64 rsv_rfer;
+ __u64 rsv_excl;
+};
+
+struct btrfs_qgroup_inherit {
+ __u64 flags;
+ __u64 num_qgroups;
+ __u64 num_ref_copies;
+ __u64 num_excl_copies;
+ struct btrfs_qgroup_limit lim;
+ __u64 qgroups[0];
+};
+
+struct btrfs_ioctl_vol_args_v2 {
+ __s64 fd;
+ __u64 transid;
+ __u64 flags;
+ union {
+ struct {
+ __u64 size;
+ struct btrfs_qgroup_inherit *qgroup_inherit;
+ };
+ __u64 unused[4];
+ };
+ char name[BTRFS_SUBVOL_NAME_MAX + 1];
+};
+
struct btrfs_ioctl_dev_info_args {
uint64_t devid; /* in/out */
uint8_t uuid[BTRFS_UUID_SIZE]; /* in/out */
@@ -251,6 +298,68 @@ struct btrfs_ioctl_fs_info_args {
uint8_t fsid[BTRFS_FSID_SIZE]; /* out */
uint64_t reserved[124]; /* pad to 1k */
};
+
+struct btrfs_ioctl_ino_lookup_args {
+ __u64 treeid;
+ __u64 objectid;
+ char name[BTRFS_INO_LOOKUP_PATH_MAX];
+};
+
+struct btrfs_ioctl_search_key {
+ /* which root are we searching. 0 is the tree of tree roots */
+ __u64 tree_id;
+
+ /* keys returned will be >= min and <= max */
+ __u64 min_objectid;
+ __u64 max_objectid;
+
+ /* keys returned will be >= min and <= max */
+ __u64 min_offset;
+ __u64 max_offset;
+
+ /* max and min transids to search for */
+ __u64 min_transid;
+ __u64 max_transid;
+
+ /* keys returned will be >= min and <= max */
+ __u32 min_type;
+ __u32 max_type;
+
+ /*
+ * how many items did userland ask for, and how many are we
+ * returning
+ */
+ __u32 nr_items;
+
+ /* align to 64 bits */
+ __u32 unused;
+
+ /* some extra for later */
+ __u64 unused1;
+ __u64 unused2;
+ __u64 unused3;
+ __u64 unused4;
+};
+
+struct btrfs_ioctl_search_header {
+ __u64 transid;
+ __u64 objectid;
+ __u64 offset;
+ __u32 type;
+ __u32 len;
+};
+
+
+struct btrfs_ioctl_search_args {
+ struct btrfs_ioctl_search_key key;
+ char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
+};
+
+struct btrfs_ioctl_clone_range_args {
+ __s64 src_fd;
+ __u64 src_offset, src_length;
+ __u64 dest_offset;
+};
#endif
#ifndef BTRFS_IOC_DEFRAG
@@ -258,6 +367,48 @@ struct btrfs_ioctl_fs_info_args {
struct btrfs_ioctl_vol_args)
#endif
+#ifndef BTRFS_IOC_CLONE
+#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
+#endif
+
+#ifndef BTRFS_IOC_CLONE_RANGE
+#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
+ struct btrfs_ioctl_clone_range_args)
+#endif
+
+#ifndef BTRFS_IOC_SUBVOL_CREATE
+#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
+ struct btrfs_ioctl_vol_args)
+#endif
+
+#ifndef BTRFS_IOC_SNAP_DESTROY
+#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
+ struct btrfs_ioctl_vol_args)
+#endif
+
+#ifndef BTRFS_IOC_TREE_SEARCH
+#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
+ struct btrfs_ioctl_search_args)
+#endif
+
+#ifndef BTRFS_IOC_INO_LOOKUP
+#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
+ struct btrfs_ioctl_ino_lookup_args)
+#endif
+
+#ifndef BTRFS_IOC_SNAP_CREATE_V2
+#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
+ struct btrfs_ioctl_vol_args_v2)
+#endif
+
+#ifndef BTRFS_IOC_SUBVOL_GETFLAGS
+#define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
+#endif
+
+#ifndef BTRFS_IOC_SUBVOL_SETFLAGS
+#define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
+#endif
+
#ifndef BTRFS_IOC_DEV_INFO
#define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
struct btrfs_ioctl_dev_info_args)

View File

@ -0,0 +1,38 @@
From fb14f86a7188f289dfc4081a6d83a5c9c7ce5a81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 21 Mar 2015 17:40:20 -0400
Subject: [PATCH] timedated: flip internal status after executing operation
timedated would set the internal status before calling out to systemd to do
the actual change. When the operation was refused because of a SELinux denial,
the state kept in timedated would get out of sync, and the second call from
timedatectl would appear to succeed.
https://bugzilla.redhat.com/show_bug.cgi?id=1014315
(cherry picked from commit 192b98b8fe73c8fb4bb3d6540deb93f5fb6eb9d2)
---
src/timedate/timedated.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 753c3d1d65..bee66af24a 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -609,8 +609,6 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
if (r == 0)
return 1;
- c->use_ntp = ntp;
-
r = context_enable_ntp(c, bus, error);
if (r < 0)
return r;
@@ -619,6 +617,8 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
if (r < 0)
return r;
+ c->use_ntp = ntp;
+
log_info("Set NTP to %s", c->use_ntp ? "enabled" : "disabled");
sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL);

View File

@ -0,0 +1,130 @@
From 29b5cd796981c42666189501b8bc41f9da2d0f52 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 21 Mar 2015 19:21:17 -0400
Subject: [PATCH] timedated: fix enable/disable reversal
Bug introduced in 984f1b1d1b. The state was flipped later,
but the enable/disable routine made use of the state to decide
what to do.
context_enable_ntp() and context_start_ntp() now get the desired
state directly, so the Context parameter can be removed.
(cherry picked from commit 81b843990297ad8c813c531fccd8da30bb715bd6)
---
src/timedate/timedated.c | 59 +++++++++++++++++-------------------------------
1 file changed, 21 insertions(+), 38 deletions(-)
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index bee66af24a..f2d23f34b1 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -225,38 +225,23 @@ static int context_read_ntp(Context *c, sd_bus *bus) {
return 0;
}
-static int context_start_ntp(Context *c, sd_bus *bus, sd_bus_error *error) {
+static int context_start_ntp(sd_bus *bus, sd_bus_error *error, bool enabled) {
int r;
- assert(c);
assert(bus);
assert(error);
- if (c->use_ntp)
- r = sd_bus_call_method(
- bus,
- "org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager",
- "StartUnit",
- error,
- NULL,
- "ss",
- "systemd-timesyncd.service",
- "replace");
- else
- r = sd_bus_call_method(
- bus,
- "org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager",
- "StopUnit",
- error,
- NULL,
- "ss",
- "systemd-timesyncd.service",
- "replace");
-
+ r = sd_bus_call_method(
+ bus,
+ "org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Manager",
+ enabled ? "StartUnit" : "StopUnit",
+ error,
+ NULL,
+ "ss",
+ "systemd-timesyncd.service",
+ "replace");
if (r < 0) {
if (sd_bus_error_has_name(error, SD_BUS_ERROR_FILE_NOT_FOUND) ||
sd_bus_error_has_name(error, "org.freedesktop.systemd1.LoadFailed") ||
@@ -269,14 +254,13 @@ static int context_start_ntp(Context *c, sd_bus *bus, sd_bus_error *error) {
return 0;
}
-static int context_enable_ntp(Context*c, sd_bus *bus, sd_bus_error *error) {
+static int context_enable_ntp(sd_bus *bus, sd_bus_error *error, bool enabled) {
int r;
- assert(c);
assert(bus);
assert(error);
- if (c->use_ntp)
+ if (enabled)
r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
@@ -592,15 +576,15 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu
}
static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
- int ntp, interactive;
+ int enabled, interactive;
Context *c = userdata;
int r;
- r = sd_bus_message_read(m, "bb", &ntp, &interactive);
+ r = sd_bus_message_read(m, "bb", &enabled, &interactive);
if (r < 0)
return r;
- if ((bool)ntp == c->use_ntp)
+ if ((bool)enabled == c->use_ntp)
return sd_bus_reply_method_return(m, NULL);
r = bus_verify_polkit_async(m, CAP_SYS_TIME, "org.freedesktop.timedate1.set-ntp", interactive, &c->polkit_registry, error);
@@ -609,17 +593,16 @@ static int method_set_ntp(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus
if (r == 0)
return 1;
- r = context_enable_ntp(c, bus, error);
+ r = context_enable_ntp(bus, error, enabled);
if (r < 0)
return r;
- r = context_start_ntp(c, bus, error);
+ r = context_start_ntp(bus, error, enabled);
if (r < 0)
return r;
- c->use_ntp = ntp;
-
- log_info("Set NTP to %s", c->use_ntp ? "enabled" : "disabled");
+ c->use_ntp = enabled;
+ log_info("Set NTP to %s", enabled ? "enabled" : "disabled");
sd_bus_emit_properties_changed(bus, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", NULL);

View File

@ -0,0 +1,43 @@
From b6df45d1c129fc95078b47d9124eca1143a7fa64 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Sat, 21 Mar 2015 18:50:10 -0400
Subject: [PATCH] core: make SELinux enable/disable check symmetric
We'd use the generic check for disable, and a unit-file-specific one for enable.
Use the more specific one both ways.
systemd[1]: SELinux access check scon=system_u:system_r:systemd_timedated_t:s0 tcon=system_u:system_r:init_t:s0 tclass=system perm=disable path=(null) cmdline=/usr/lib/systemd/systemd-timedated: -13
systemd[1]: SELinux access check scon=system_u:system_r:systemd_timedated_t:s0 tcon=system_u:object_r:systemd_unit_file_t:s0 tclass=service perm=enable path=/usr/lib/systemd/system/systemd-timesyncd.service cmdline=/usr/lib/systemd/systemd-timedated: -13
https://bugzilla.redhat.com/show_bug.cgi?id=1014315
(cherry picked from commit df823e23f04da832ad5fc078176f8c26597a9845)
Conflicts:
src/core/dbus-manager.c
---
src/core/dbus-manager.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 8ba665dc3d..2bc37ba60e 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1772,15 +1772,15 @@ static int method_disable_unit_files_generic(
if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
- r = mac_selinux_access_check(message, verb, error);
+ r = sd_bus_message_read_strv(message, &l);
if (r < 0)
return r;
- r = sd_bus_message_read_strv(message, &l);
+ r = sd_bus_message_read(message, "b", &runtime);
if (r < 0)
return r;
- r = sd_bus_message_read(message, "b", &runtime);
+ r = mac_selinux_unit_access_check_strv(l, message, m, verb, error);
if (r < 0)
return r;

View File

@ -0,0 +1,149 @@
From 533cc35f09181971821d94b6e4ce242b4b966583 Mon Sep 17 00:00:00 2001
From: Michal Schmidt <mschmidt@redhat.com>
Date: Mon, 16 Mar 2015 21:58:35 +0100
Subject: [PATCH] shared: add path_compare(), an ordering path comparison
... and make path_equal() a simple wrapper around it.
(cherry picked from commit 2230852bd9755e1b7bfd1260082471f559b0a005)
---
src/shared/path-util.c | 37 +++++++++++++++++++++++++++----------
src/shared/path-util.h | 1 +
src/test/test-path-util.c | 36 +++++++++++++++++++++++++-----------
3 files changed, 53 insertions(+), 21 deletions(-)
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 70bc1caa2a..d5510bf56f 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -403,12 +403,18 @@ char* path_startswith(const char *path, const char *prefix) {
}
}
-bool path_equal(const char *a, const char *b) {
+int path_compare(const char *a, const char *b) {
+ int d;
+
assert(a);
assert(b);
- if ((a[0] == '/') != (b[0] == '/'))
- return false;
+ /* A relative path and an abolute path must not compare as equal.
+ * Which one is sorted before the other does not really matter.
+ * Here a relative path is ordered before an absolute path. */
+ d = (a[0] == '/') - (b[0] == '/');
+ if (d)
+ return d;
for (;;) {
size_t j, k;
@@ -417,25 +423,36 @@ bool path_equal(const char *a, const char *b) {
b += strspn(b, "/");
if (*a == 0 && *b == 0)
- return true;
+ return 0;
- if (*a == 0 || *b == 0)
- return false;
+ /* Order prefixes first: "/foo" before "/foo/bar" */
+ if (*a == 0)
+ return -1;
+ if (*b == 0)
+ return 1;
j = strcspn(a, "/");
k = strcspn(b, "/");
- if (j != k)
- return false;
+ /* Alphabetical sort: "/foo/aaa" before "/foo/b" */
+ d = memcmp(a, b, MIN(j, k));
+ if (d)
+ return (d > 0) - (d < 0); /* sign of d */
- if (memcmp(a, b, j) != 0)
- return false;
+ /* Sort "/foo/a" before "/foo/aaa" */
+ d = (j > k) - (j < k); /* sign of (j - k) */
+ if (d)
+ return d;
a += j;
b += k;
}
}
+bool path_equal(const char *a, const char *b) {
+ return path_compare(a, b) == 0;
+}
+
bool path_equal_or_files_same(const char *a, const char *b) {
return path_equal(a, b) || files_same(a, b) > 0;
}
diff --git a/src/shared/path-util.h b/src/shared/path-util.h
index bcf116ed3d..ca81b49cbf 100644
--- a/src/shared/path-util.h
+++ b/src/shared/path-util.h
@@ -44,6 +44,7 @@ char* path_make_absolute_cwd(const char *p);
int path_make_relative(const char *from_dir, const char *to_path, char **_r);
char* path_kill_slashes(char *path);
char* path_startswith(const char *path, const char *prefix) _pure_;
+int path_compare(const char *a, const char *b) _pure_;
bool path_equal(const char *a, const char *b) _pure_;
bool path_equal_or_files_same(const char *a, const char *b);
char* path_join(const char *root, const char *path, const char *rest);
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
index 11aa52aaed..6396fcb398 100644
--- a/src/test/test-path-util.c
+++ b/src/test/test-path-util.c
@@ -27,23 +27,37 @@
#include "macro.h"
#include "strv.h"
+#define test_path_compare(a, b, result) { \
+ assert_se(path_compare(a, b) == result); \
+ assert_se(path_compare(b, a) == -result); \
+ assert_se(path_equal(a, b) == !result); \
+ assert_se(path_equal(b, a) == !result); \
+ }
static void test_path(void) {
- assert_se(path_equal("/goo", "/goo"));
- assert_se(path_equal("//goo", "/goo"));
- assert_se(path_equal("//goo/////", "/goo"));
- assert_se(path_equal("goo/////", "goo"));
+ test_path_compare("/goo", "/goo", 0);
+ test_path_compare("/goo", "/goo", 0);
+ test_path_compare("//goo", "/goo", 0);
+ test_path_compare("//goo/////", "/goo", 0);
+ test_path_compare("goo/////", "goo", 0);
+
+ test_path_compare("/goo/boo", "/goo//boo", 0);
+ test_path_compare("//goo/boo", "/goo/boo//", 0);
- assert_se(path_equal("/goo/boo", "/goo//boo"));
- assert_se(path_equal("//goo/boo", "/goo/boo//"));
+ test_path_compare("/", "///", 0);
- assert_se(path_equal("/", "///"));
+ test_path_compare("/x", "x/", 1);
+ test_path_compare("x/", "/", -1);
- assert_se(!path_equal("/x", "x/"));
- assert_se(!path_equal("x/", "/"));
+ test_path_compare("/x/./y", "x/y", 1);
+ test_path_compare("x/.y", "x/y", -1);
- assert_se(!path_equal("/x/./y", "x/y"));
- assert_se(!path_equal("x/.y", "x/y"));
+ test_path_compare("foo", "/foo", -1);
+ test_path_compare("/foo", "/foo/bar", -1);
+ test_path_compare("/foo/aaa", "/foo/b", -1);
+ test_path_compare("/foo/aaa", "/foo/b/a", -1);
+ test_path_compare("/foo/a", "/foo/aaa", -1);
+ test_path_compare("/foo/a/b", "/foo/aaa", -1);
assert_se(path_is_absolute("/"));
assert_se(!path_is_absolute("./"));

View File

@ -0,0 +1,58 @@
From 85a6fabdd3e43cfab0fc6359e9f2a9e368d4a3ed Mon Sep 17 00:00:00 2001
From: Michal Schmidt <mschmidt@redhat.com>
Date: Mon, 16 Mar 2015 22:04:21 +0100
Subject: [PATCH] core/namespace: fix path sorting
The comparison function we use for qsorting paths is overly indifferent.
Consider these 3 paths for sorting:
/foo
/bar
/foo/foo
qsort() may compare:
"/foo" with "/bar" => 0, indifference
"/bar" with "/foo/foo" => 0, indifference
and assume transitively that "/foo" and "/foo/foo" are also indifferent.
But this is wrong, we want "/foo" sorted before "/foo/foo".
The comparison function must be transitive.
Use path_compare(), which behaves properly.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1184016
(cherry picked from commit a0827e2b123010c46cfe4f03eebba57d92f9efc4)
---
src/core/namespace.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 4fecd32363..d4f1c86211 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -91,9 +91,11 @@ static int append_mounts(BindMount **p, char **strv, MountMode mode) {
static int mount_path_compare(const void *a, const void *b) {
const BindMount *p = a, *q = b;
+ int d;
- if (path_equal(p->path, q->path)) {
+ d = path_compare(p->path, q->path);
+ if (!d) {
/* If the paths are equal, check the mode */
if (p->mode < q->mode)
return -1;
@@ -105,13 +107,7 @@ static int mount_path_compare(const void *a, const void *b) {
}
/* If the paths are not equal, then order prefixes first */
- if (path_startswith(p->path, q->path))
- return 1;
-
- if (path_startswith(q->path, p->path))
- return -1;
-
- return 0;
+ return d;
}
static void drop_duplicates(BindMount *m, unsigned *n) {

View File

@ -132,6 +132,27 @@ Patch0088: 0088-man-link-to-fd.o-for-dbus-stuff.patch
Patch0089: 0089-man-fix-name-of-systemd.resource-control-5.patch
Patch0090: 0090-selinux-fix-SEGV-during-switch-root-if-SELinux-polic.patch
Patch0091: 0091-service-don-t-add-After-dependencies-on-.busname-uni.patch
Patch0092: 0092-libudev-monitor-fix-error-path-in-send_device.patch
Patch0093: 0093-core-remove-left-over-debug-message.patch
Patch0094: 0094-units-there-is-no-systemd-udev-hwdb-update.service.patch
Patch0095: 0095-util-remove-redundant-debug-message.patch
Patch0096: 0096-tmpfiles-remove-redundant-debug-message.patch
Patch0097: 0097-sysv-generator-initialize-LookupPaths-just-once.patch
Patch0098: 0098-core-do-not-use-quotes-around-virt-and-arch.patch
Patch0099: 0099-udev-downgrade-has-devpath-and-filled-with-db-file-m.patch
Patch0100: 0100-cryptsetup-generator-remove-warning-about-crypttab-a.patch
Patch0101: 0101-sysctl-tweak-debug-message.patch
Patch0102: 0102-journald-add-syslog-fields-for-audit-messages.patch
Patch0103: 0103-core-remove-useless-debug-message.patch
Patch0104: 0104-man-standard-conf-change-directory-reference-to-wild.patch
Patch0105: 0105-core-don-t-change-removed-devices-to-state-tentative.patch
Patch0106: 0106-fstab-generator-ignore-invalid-swap-priority.patch
Patch0107: 0107-missing.h-add-more-btrfs-types-and-defines.patch
Patch0108: 0108-timedated-flip-internal-status-after-executing-opera.patch
Patch0109: 0109-timedated-fix-enable-disable-reversal.patch
Patch0110: 0110-core-make-SELinux-enable-disable-check-symmetric.patch
Patch0111: 0111-shared-add-path_compare-an-ordering-path-comparison.patch
Patch0112: 0112-core-namespace-fix-path-sorting.patch
# kernel-install patch for grubby, drop if grubby is obsolete
@ -975,6 +996,12 @@ getent passwd systemd-journal-upload >/dev/null 2>&1 || useradd -r -l -g systemd
- Move all parts systemd-journal-{remote,upload} to
systemd-journal-gatewayd subpackage (#1193143).
- Create /var/lib/systemd/journal-upload directory (#1193145).
- Cut out lots of stupid messages at debug level which were obscuring more
important stuff.
- Apply "tentative" state for devices only when they are added, not removed.
- Ignore invalid swap pri= settings (#1204336)
- Fix SELinux check for timedated operations to enable/disable ntp (#1014315)
- Fix comparing of filesystem paths (#1184016)
* Sat Mar 14 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 219-10
- Fixes for bugs 1186018, 1195294, 1185604, 1196452.