From fe20ad692d94ea2f9ec552d79ee575421bddd120 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Sep 04 2013 11:29:05 +0000 Subject: systemd-206-10 - Do not require grubby, lorax now takes care of grubby - cherry-picked a lot of patches from upstream --- diff --git a/0001-80-net-name-slot.rules-only-rename-network-interface.patch b/0001-80-net-name-slot.rules-only-rename-network-interface.patch new file mode 100644 index 0000000..ed5d676 --- /dev/null +++ b/0001-80-net-name-slot.rules-only-rename-network-interface.patch @@ -0,0 +1,39 @@ +From 1848e58772105127f636d527dba028694d15ed15 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Thu, 1 Aug 2013 12:31:38 +0200 +Subject: [PATCH] 80-net-name-slot.rules: only rename network interfaces on + ACTION=="add" + +Otherwise systemd-udevd will rename on "change" and "move" events, +resulting in weird renames in combination with biosdevname + +systemd-udevd[355]: renamed network interface eth0 to em1 +systemd-udevd[355]: renamed network interface eth1 to p3p2 +systemd-udevd[357]: renamed network interface eth0 to p3p1 +systemd-udevd[429]: renamed network interface p3p2 to ens3f1 +systemd-udevd[428]: renamed network interface p3p1 to ens3f0 +systemd-udevd[426]: renamed network interface em1 to enp63s0 + +or + +systemd-udevd[356]: renamed network interface eth0 to em1 +systemd-udevd[356]: renamed network interface eth0 to p3p1 +systemd-udevd[420]: renamed network interface p3p1 to ens3f0 +systemd-udevd[418]: renamed network interface em1 to enp63s0 +systemd-udevd[421]: renamed network interface eth1 to p3p1 +--- + rules/80-net-name-slot.rules | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/rules/80-net-name-slot.rules b/rules/80-net-name-slot.rules +index 15b5bc4..c5f1b38 100644 +--- a/rules/80-net-name-slot.rules ++++ b/rules/80-net-name-slot.rules +@@ -1,6 +1,6 @@ + # do not edit this file, it will be overwritten on update + +-ACTION=="remove", GOTO="net_name_slot_end" ++ACTION!="add", GOTO="net_name_slot_end" + SUBSYSTEM!="net", GOTO="net_name_slot_end" + NAME!="", GOTO="net_name_slot_end" + diff --git a/0004-journal-handle-multiline-syslog-messages.patch b/0004-journal-handle-multiline-syslog-messages.patch new file mode 100644 index 0000000..2eb6e16 --- /dev/null +++ b/0004-journal-handle-multiline-syslog-messages.patch @@ -0,0 +1,76 @@ +From 9d5dbdd18f4c106856f031ae94d4f05aa3259de7 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Thu, 1 Aug 2013 12:14:02 +0200 +Subject: [PATCH] journal: handle multiline syslog messages +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since the journal can handle multiple lines just well natively, +and rsyslog can be configured to handle them as well, there is no need +to truncate messages from syslog() after the first newline. + +Reproducer: + +1. Add following four lines to /etc/rsyslog.conf + + ---------- + $EscapeControlCharactersOnReceive off + $ActionFileDefaultTemplate RSYSLOG_SysklogdFileFormat + $SpaceLFOnReceive on + $DropTrailingLFOnReception off + ---------- + +3. Restart rsyslog + # service rsyslog restart + +4. Compile and run the following program + + ---------- + #include + #include + + int main() + { + syslog(LOG_INFO, "aaa%caaa", '\n'); + return 0; + } + ---------- + +Actual results: +Below message appears in /var/log/messages. + + ---------- +   Sep 7 19:19:39 localhost test2: aaa + ---------- + +Expected results: +Below message, which worked prior to systemd-journald +appears in /var/log/messages. + + ---------- +   Sep 7 19:19:39 localhost test2: aaa aaa + +https://bugzilla.redhat.com/show_bug.cgi?id=855313 +--- + src/journal/journald-server.c | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c +index 60c32b1..c5c195a 100644 +--- a/src/journal/journald-server.c ++++ b/src/journal/journald-server.c +@@ -1240,12 +1240,7 @@ int process_event(Server *s, struct epoll_event *ev) { + char *e; + + if (n > 0 && n_fds == 0) { +- e = memchr(s->buffer, '\n', n); +- if (e) +- *e = 0; +- else +- s->buffer[n] = 0; +- ++ s->buffer[n] = 0; + server_process_syslog_message(s, strstrip(s->buffer), ucred, tv, label, label_len); + } else if (n_fds > 0) + log_warning("Got file descriptors via syslog socket. Ignoring."); diff --git a/0005-man-Fix-copy-paste-error.patch b/0005-man-Fix-copy-paste-error.patch new file mode 100644 index 0000000..16e512d --- /dev/null +++ b/0005-man-Fix-copy-paste-error.patch @@ -0,0 +1,32 @@ +From fad2602f7eb86f8839d5ec7bc0b6bc5ce282e16d Mon Sep 17 00:00:00 2001 +From: Michael Biebl +Date: Tue, 23 Jul 2013 05:03:17 +0200 +Subject: [PATCH] man: Fix copy&paste error + +--- + man/udev.xml | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/man/udev.xml b/man/udev.xml +index 0220725..f107482 100644 +--- a/man/udev.xml ++++ b/man/udev.xml +@@ -704,15 +704,15 @@ + system hwdb directory /usr/lib/udev/hwdb.d, + the volatile runtime directory /run/udev/hwdb.d + and the local administration directory /etc/udev/hwdb.d. +- All rules files are collectively sorted and processed in lexical order, ++ All hwdb files are collectively sorted and processed in lexical order, + regardless of the directories in which they live. However, files with + identical filenames replace each other. Files in /etc + have the highest priority, files in /run take precedence + over files with the same name in /lib. This can be + used to override a system-supplied hwdb file with a local file if needed; +- a symlink in /etc with the same name as a rules file in ++ a symlink in /etc with the same name as a hwdb file in + /lib, pointing to /dev/null, +- disables the rules file entirely. hwdb files must have the extension ++ disables the hwdb file entirely. hwdb files must have the extension + .hwdb; other extensions are ignored. + + The hwdb file contains data records consisting of matches and diff --git a/0006-core-synchronously-block-when-logging.patch b/0006-core-synchronously-block-when-logging.patch new file mode 100644 index 0000000..e81bccd --- /dev/null +++ b/0006-core-synchronously-block-when-logging.patch @@ -0,0 +1,48 @@ +From f173657bccae4dd0cbfe0a7ed33ebc9117b74f05 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 24 Jul 2013 07:24:05 +0200 +Subject: [PATCH] core: synchronously block when logging + +Previously, the logging sockets were asynchronous and if clogged we'd +lose messages. We did this to be extra careful given that PID 1 might +need to spawn the logging daemon as response to PID 1's own log messages +and we really should avoid a deadlock in that case. + +As it turns out this causes loss of too many messages, hence make the +socket blocking again, however put a time limit on it to avoid unbounded +deadlocks in the unlikely case they happen. + +https://bugs.freedesktop.org/show_bug.cgi?id=66664 +--- + src/shared/log.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/src/shared/log.c b/src/shared/log.c +index 27317f7..8f4995a 100644 +--- a/src/shared/log.c ++++ b/src/shared/log.c +@@ -115,16 +115,20 @@ void log_close_syslog(void) { + + static int create_log_socket(int type) { + int fd; ++ struct timeval tv; + +- /* All output to the syslog/journal fds we do asynchronously, +- * and if the buffers are full we just drop the messages */ +- +- fd = socket(AF_UNIX, type|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); ++ fd = socket(AF_UNIX, type|SOCK_CLOEXEC, 0); + if (fd < 0) + return -errno; + + fd_inc_sndbuf(fd, SNDBUF_SIZE); + ++ /* We need a blocking fd here since we'd otherwise lose ++ messages way too early. However, let's not hang forever in the ++ unlikely case of a deadlock. */ ++ timeval_store(&tv, 1*USEC_PER_MINUTE); ++ setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); ++ + return fd; + } + diff --git a/0007-journal-immediately-sync-to-disk-as-soon-as-we-recei.patch b/0007-journal-immediately-sync-to-disk-as-soon-as-we-recei.patch new file mode 100644 index 0000000..22f2dfb --- /dev/null +++ b/0007-journal-immediately-sync-to-disk-as-soon-as-we-recei.patch @@ -0,0 +1,173 @@ +From 81e5007269cc33ff6acf27051b1f3b5b986f878a Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 24 Jul 2013 08:08:57 +0200 +Subject: [PATCH] journal: immediately sync to disk as soon as we receieve an + EMERG/ALERT/CRIT message + +--- + TODO | 2 -- + man/journald.conf.xml | 14 +++++++++++--- + src/journal/journald-server.c | 26 ++++++++++++++++---------- + src/journal/journald-server.h | 2 +- + 4 files changed, 28 insertions(+), 16 deletions(-) + +diff --git a/TODO b/TODO +index ba8bb8e..279ea60 100644 +--- a/TODO ++++ b/TODO +@@ -74,8 +74,6 @@ Features: + + * journald: optionally, log debug messages to /run but everything else to /var + +-* journald: optionally, when messages with a high log priority are logged, sync() immediately. +- + * systemctl list-unit-files should list generated files (and probably with a new state "generated" for them, or so) + + * do we really need both hasprefix() and startswith()? +diff --git a/man/journald.conf.xml b/man/journald.conf.xml +index 487e8d6..9219b3d 100644 +--- a/man/journald.conf.xml ++++ b/man/journald.conf.xml +@@ -348,9 +348,17 @@ + + SyncIntervalSec= + +- The timeout before synchronizing journal +- data to disk. After syncing, journal files have +- the OFFLINE state. Default timeout is 5 minutes. ++ The timeout before ++ synchronizing journal files to ++ disk. After syncing, journal files are ++ placed in the OFFLINE state. Note that ++ syncing is unconditionally done ++ immediately after a log message of ++ priority CRIT, ALERT or EMERG has been ++ logged, this setting hence applies ++ only to messages of the levels ERR, ++ WARNING, NOTICE, INFO, DEBUG. The ++ default timeout is 5 minutes. + + + +diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c +index c5c195a..f417059 100644 +--- a/src/journal/journald-server.c ++++ b/src/journal/journald-server.c +@@ -352,13 +352,12 @@ void server_rotate(Server *s) { + } + + void server_sync(Server *s) { ++ static const struct itimerspec sync_timer_disable = {}; + JournalFile *f; + void *k; + Iterator i; + int r; + +- static const struct itimerspec sync_timer_disable = {}; +- + if (s->system_journal) { + r = journal_file_set_offline(s->system_journal); + if (r < 0) +@@ -443,7 +442,7 @@ bool shall_try_append_again(JournalFile *f, int r) { + return true; + } + +-static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned n) { ++static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned n, int priority) { + JournalFile *f; + bool vacuumed = false; + int r; +@@ -469,7 +468,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned + + r = journal_file_append_entry(f, NULL, iovec, n, &s->seqnum, NULL, NULL); + if (r >= 0) { +- server_schedule_sync(s); ++ server_schedule_sync(s, priority); + return; + } + +@@ -499,7 +498,8 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned + size += iovec[i].iov_len; + + log_error("Failed to write entry (%d items, %zu bytes) despite vacuuming, ignoring: %s", n, size, strerror(-r)); +- } ++ } else ++ server_schedule_sync(s, priority); + } + + static void dispatch_message_real( +@@ -509,6 +509,7 @@ static void dispatch_message_real( + struct timeval *tv, + const char *label, size_t label_len, + const char *unit_id, ++ int priority, + pid_t object_pid) { + + char pid[sizeof("_PID=") + DECIMAL_STR_MAX(pid_t)], +@@ -523,7 +524,6 @@ static void dispatch_message_real( + o_owner_uid[sizeof("OBJECT_SYSTEMD_OWNER_UID=") + DECIMAL_STR_MAX(uid_t)]; + uid_t object_uid; + gid_t object_gid; +- + char *x; + sd_id128_t id; + int r; +@@ -786,7 +786,7 @@ static void dispatch_message_real( + else + journal_uid = 0; + +- write_to_journal(s, journal_uid, iovec, n); ++ write_to_journal(s, journal_uid, iovec, n, priority); + } + + void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) { +@@ -820,7 +820,7 @@ void server_driver_message(Server *s, sd_id128_t message_id, const char *format, + ucred.uid = getuid(); + ucred.gid = getgid(); + +- dispatch_message_real(s, iovec, n, ELEMENTSOF(iovec), &ucred, NULL, NULL, 0, NULL, 0); ++ dispatch_message_real(s, iovec, n, ELEMENTSOF(iovec), &ucred, NULL, NULL, 0, NULL, LOG_INFO, 0); + } + + void server_dispatch_message( +@@ -886,7 +886,7 @@ void server_dispatch_message( + "Suppressed %u messages from %s", rl - 1, path); + + finish: +- dispatch_message_real(s, iovec, n, m, ucred, tv, label, label_len, unit_id, object_pid); ++ dispatch_message_real(s, iovec, n, m, ucred, tv, label, label_len, unit_id, priority, object_pid); + } + + +@@ -1418,11 +1418,17 @@ static int server_open_sync_timer(Server *s) { + return 0; + } + +-int server_schedule_sync(Server *s) { ++int server_schedule_sync(Server *s, int priority) { + int r; + + assert(s); + ++ if (priority <= LOG_CRIT) { ++ /* Immediately sync to disk when this is of priority CRIT, ALERT, EMERG */ ++ server_sync(s); ++ return 0; ++ } ++ + if (s->sync_scheduled) + return 0; + +diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h +index 9ff3300..e856ef2 100644 +--- a/src/journal/journald-server.h ++++ b/src/journal/journald-server.h +@@ -153,7 +153,7 @@ void server_done(Server *s); + void server_sync(Server *s); + void server_vacuum(Server *s); + void server_rotate(Server *s); +-int server_schedule_sync(Server *s); ++int server_schedule_sync(Server *s, int priority); + int server_flush_to_var(Server *s); + int process_event(Server *s, struct epoll_event *ev); + void server_maybe_append_tags(Server *s); diff --git a/0008-initctl-use-irreversible-jobs-when-switching-runleve.patch b/0008-initctl-use-irreversible-jobs-when-switching-runleve.patch new file mode 100644 index 0000000..bbf951a --- /dev/null +++ b/0008-initctl-use-irreversible-jobs-when-switching-runleve.patch @@ -0,0 +1,23 @@ +From ddc8a554f100c77f35df682bb528906b26f5f497 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 23 Jul 2013 22:01:39 -0400 +Subject: [PATCH] initctl: use irreversible jobs when switching runlevels + +Spotted by uau in #systemd. +--- + src/initctl/initctl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c +index 735f1e1..5fbce4a 100644 +--- a/src/initctl/initctl.c ++++ b/src/initctl/initctl.c +@@ -122,7 +122,7 @@ static void change_runlevel(Server *s, int runlevel) { + if (isolate) + mode = "isolate"; + else +- mode = "replace"; ++ mode = "replace-irreversibly"; + + log_debug("Running request %s/start/%s", target, mode); + diff --git a/0009-udev-log-error-if-chmod-chown-of-static-dev-nodes-fa.patch b/0009-udev-log-error-if-chmod-chown-of-static-dev-nodes-fa.patch new file mode 100644 index 0000000..b692951 --- /dev/null +++ b/0009-udev-log-error-if-chmod-chown-of-static-dev-nodes-fa.patch @@ -0,0 +1,39 @@ +From cc1ab04e1ce05fc0aa917249677ab2818ea87eee Mon Sep 17 00:00:00 2001 +From: Tom Gundersen +Date: Wed, 24 Jul 2013 14:55:19 +0200 +Subject: [PATCH] udev: log error if chmod/chown of static dev nodes fails + +--- + src/udev/udev-rules.c | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c +index 8ace705..fe4965f 100644 +--- a/src/udev/udev-rules.c ++++ b/src/udev/udev-rules.c +@@ -2593,13 +2593,21 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) + mode = 0600; + } + if (mode != (stats.st_mode & 01777)) { +- chmod(device_node, mode); +- log_debug("chmod '%s' %#o\n", device_node, mode); ++ r = chmod(device_node, mode); ++ if (r < 0) { ++ log_error("failed to chmod '%s' %#o\n", device_node, mode); ++ return -errno; ++ } else ++ log_debug("chmod '%s' %#o\n", device_node, mode); + } + + if ((uid != 0 && uid != stats.st_uid) || (gid != 0 && gid != stats.st_gid)) { +- chown(device_node, uid, gid); +- log_debug("chown '%s' %u %u\n", device_node, uid, gid); ++ r = chown(device_node, uid, gid); ++ if (r < 0) { ++ log_error("failed to chown '%s' %u %u \n", device_node, uid, gid); ++ return -errno; ++ } else ++ log_debug("chown '%s' %u %u\n", device_node, uid, gid); + } + + utimensat(AT_FDCWD, device_node, NULL, 0); diff --git a/0010-udev-static_node-don-t-touch-permissions-uneccessari.patch b/0010-udev-static_node-don-t-touch-permissions-uneccessari.patch new file mode 100644 index 0000000..bf826c3 --- /dev/null +++ b/0010-udev-static_node-don-t-touch-permissions-uneccessari.patch @@ -0,0 +1,25 @@ +From 3a27b93611af2c6dbed260e269118a1fd226ef27 Mon Sep 17 00:00:00 2001 +From: Tom Gundersen +Date: Wed, 24 Jul 2013 15:05:48 +0200 +Subject: [PATCH] udev: static_node - don't touch permissions uneccessarily + +Don't set default permissions if only TAGS were specified in a rule. +--- + src/udev/udev-rules.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c +index fe4965f..769b670 100644 +--- a/src/udev/udev-rules.c ++++ b/src/udev/udev-rules.c +@@ -2586,6 +2586,10 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) + } + } + ++ /* don't touch the permissions if only the tags were set */ ++ if (mode == 0 && uid == 0 && gid == 0) ++ goto next; ++ + if (mode == 0) { + if (gid > 0) + mode = 0660; diff --git a/0011-tmpfiles-support-passing-prefix-multiple-times.patch b/0011-tmpfiles-support-passing-prefix-multiple-times.patch new file mode 100644 index 0000000..68441df --- /dev/null +++ b/0011-tmpfiles-support-passing-prefix-multiple-times.patch @@ -0,0 +1,87 @@ +From eada3a23db3aed6f679c8d5476618f33d4249cb7 Mon Sep 17 00:00:00 2001 +From: Dave Reisner +Date: Wed, 24 Jul 2013 11:10:05 -0400 +Subject: [PATCH] tmpfiles: support passing --prefix multiple times + +--- + man/systemd-tmpfiles.xml | 3 ++- + src/tmpfiles/tmpfiles.c | 24 +++++++++++++++++++++--- + 2 files changed, 23 insertions(+), 4 deletions(-) + +diff --git a/man/systemd-tmpfiles.xml b/man/systemd-tmpfiles.xml +index 405a9f1..b0f2d9c 100644 +--- a/man/systemd-tmpfiles.xml ++++ b/man/systemd-tmpfiles.xml +@@ -121,7 +121,8 @@ + + Only apply rules that + apply to paths with the specified +- prefix. ++ prefix. This option can be specified ++ multiple times. + + + +diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c +index eae993e..cb15133 100644 +--- a/src/tmpfiles/tmpfiles.c ++++ b/src/tmpfiles/tmpfiles.c +@@ -105,7 +105,7 @@ static bool arg_create = false; + static bool arg_clean = false; + static bool arg_remove = false; + +-static const char *arg_prefix = NULL; ++static char **include_prefixes = NULL; + + static const char conf_file_dirs[] = + "/etc/tmpfiles.d\0" +@@ -1018,6 +1018,21 @@ static bool item_equal(Item *a, Item *b) { + return true; + } + ++static bool should_include_path(const char *path) { ++ char **prefix; ++ ++ /* no explicit paths specified for inclusion, so everything is valid */ ++ if (strv_length(include_prefixes) == 0) ++ return true; ++ ++ STRV_FOREACH(prefix, include_prefixes) { ++ if (path_startswith(path, *prefix)) ++ return true; ++ } ++ ++ return false; ++} ++ + static int parse_line(const char *fname, unsigned line, const char *buffer) { + _cleanup_item_free_ Item *i = NULL; + Item *existing; +@@ -1119,7 +1134,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { + + path_kill_slashes(i->path); + +- if (arg_prefix && !path_startswith(i->path, arg_prefix)) ++ if (!should_include_path(i->path)) + return 0; + + if (user && !streq(user, "-")) { +@@ -1258,7 +1273,8 @@ static int parse_argv(int argc, char *argv[]) { + break; + + case ARG_PREFIX: +- arg_prefix = optarg; ++ if (strv_extend(&include_prefixes, optarg) < 0) ++ return log_oom(); + break; + + case '?': +@@ -1423,6 +1439,8 @@ finish: + hashmap_free(items); + hashmap_free(globs); + ++ strv_free(include_prefixes); ++ + set_free_free(unix_sockets); + + label_finish(); diff --git a/0012-tmpfiles-introduce-exclude-prefix.patch b/0012-tmpfiles-introduce-exclude-prefix.patch new file mode 100644 index 0000000..ced3111 --- /dev/null +++ b/0012-tmpfiles-introduce-exclude-prefix.patch @@ -0,0 +1,135 @@ +From 84601ab5c6e6c17bd489423b693b85377b9b1be9 Mon Sep 17 00:00:00 2001 +From: Dave Reisner +Date: Wed, 24 Jul 2013 11:19:24 -0400 +Subject: [PATCH] tmpfiles: introduce --exclude-prefix + +The opposite of --prefix, allows specifying path prefixes which should +be skipped when processing rules. +--- + man/systemd-tmpfiles.xml | 7 +++++ + shell-completion/systemd-zsh-completion.zsh | 1 + + src/tmpfiles/tmpfiles.c | 44 ++++++++++++++++++----------- + 3 files changed, 36 insertions(+), 16 deletions(-) + +diff --git a/man/systemd-tmpfiles.xml b/man/systemd-tmpfiles.xml +index b0f2d9c..403592d 100644 +--- a/man/systemd-tmpfiles.xml ++++ b/man/systemd-tmpfiles.xml +@@ -124,6 +124,13 @@ + prefix. This option can be specified + multiple times. + ++ ++ ++ Ignore rules that ++ apply to paths with the specified ++ prefix. This option can be specified ++ multiple times. ++ + + + +diff --git a/shell-completion/systemd-zsh-completion.zsh b/shell-completion/systemd-zsh-completion.zsh +index c85e00e..7aebbcd 100644 +--- a/shell-completion/systemd-zsh-completion.zsh ++++ b/shell-completion/systemd-zsh-completion.zsh +@@ -249,6 +249,7 @@ _ctls() + '--clean[Clean up all files and directories with an age parameter configured.]' \ + '--remove[All files and directories marked with r, R in the configuration files are removed.]' \ + '--prefix=[Only apply rules that apply to paths with the specified prefix.]' \ ++ '--exclude-prefix=[Ignore rules that apply to paths with the specified prefix.]' \ + '--help[Prints a short help text and exits.]' \ + '*::files:_files' + ;; +diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c +index cb15133..5eca82a 100644 +--- a/src/tmpfiles/tmpfiles.c ++++ b/src/tmpfiles/tmpfiles.c +@@ -106,6 +106,7 @@ static bool arg_clean = false; + static bool arg_remove = false; + + static char **include_prefixes = NULL; ++static char **exclude_prefixes = NULL; + + static const char conf_file_dirs[] = + "/etc/tmpfiles.d\0" +@@ -1021,16 +1022,19 @@ static bool item_equal(Item *a, Item *b) { + static bool should_include_path(const char *path) { + char **prefix; + +- /* no explicit paths specified for inclusion, so everything is valid */ +- if (strv_length(include_prefixes) == 0) +- return true; ++ STRV_FOREACH(prefix, exclude_prefixes) { ++ if (path_startswith(path, *prefix)) ++ return false; ++ } + + STRV_FOREACH(prefix, include_prefixes) { + if (path_startswith(path, *prefix)) + return true; + } + +- return false; ++ /* no matches, so we should include this path only if we ++ * have no whitelist at all */ ++ return strv_length(include_prefixes) == 0; + } + + static int parse_line(const char *fname, unsigned line, const char *buffer) { +@@ -1219,11 +1223,12 @@ static int help(void) { + + printf("%s [OPTIONS...] [CONFIGURATION FILE...]\n\n" + "Creates, deletes and cleans up volatile and temporary files and directories.\n\n" +- " -h --help Show this help\n" +- " --create Create marked files/directories\n" +- " --clean Clean up marked directories\n" +- " --remove Remove marked files/directories\n" +- " --prefix=PATH Only apply rules that apply to paths with the specified prefix\n", ++ " -h --help Show this help\n" ++ " --create Create marked files/directories\n" ++ " --clean Clean up marked directories\n" ++ " --remove Remove marked files/directories\n" ++ " --prefix=PATH Only apply rules that apply to paths with the specified prefix\n" ++ " --exclude-prefix=PATH Ignore rules that apply to paths with the specified prefix\n", + program_invocation_short_name); + + return 0; +@@ -1235,16 +1240,18 @@ static int parse_argv(int argc, char *argv[]) { + ARG_CREATE, + ARG_CLEAN, + ARG_REMOVE, +- ARG_PREFIX ++ ARG_PREFIX, ++ ARG_EXCLUDE_PREFIX, + }; + + static const struct option options[] = { +- { "help", no_argument, NULL, 'h' }, +- { "create", no_argument, NULL, ARG_CREATE }, +- { "clean", no_argument, NULL, ARG_CLEAN }, +- { "remove", no_argument, NULL, ARG_REMOVE }, +- { "prefix", required_argument, NULL, ARG_PREFIX }, +- { NULL, 0, NULL, 0 } ++ { "help", no_argument, NULL, 'h' }, ++ { "create", no_argument, NULL, ARG_CREATE }, ++ { "clean", no_argument, NULL, ARG_CLEAN }, ++ { "remove", no_argument, NULL, ARG_REMOVE }, ++ { "prefix", required_argument, NULL, ARG_PREFIX }, ++ { "exclude-prefix", required_argument, NULL, ARG_EXCLUDE_PREFIX }, ++ { NULL, 0, NULL, 0 } + }; + + int c; +@@ -1277,6 +1284,11 @@ static int parse_argv(int argc, char *argv[]) { + return log_oom(); + break; + ++ case ARG_EXCLUDE_PREFIX: ++ if (strv_extend(&exclude_prefixes, optarg) < 0) ++ return log_oom(); ++ break; ++ + case '?': + return -EINVAL; + diff --git a/0013-tmpfiles-setup-exclude-dev-prefixes-files.patch b/0013-tmpfiles-setup-exclude-dev-prefixes-files.patch new file mode 100644 index 0000000..978c17e --- /dev/null +++ b/0013-tmpfiles-setup-exclude-dev-prefixes-files.patch @@ -0,0 +1,20 @@ +From a2381ddc5af1bf1524048fe0c6b505167fe0ec73 Mon Sep 17 00:00:00 2001 +From: Dave Reisner +Date: Wed, 24 Jul 2013 11:58:35 -0400 +Subject: [PATCH] tmpfiles-setup: exclude /dev prefixes files + +Fixes Arch Linux bug: https://bugs.archlinux.org/task/36259 +--- + units/systemd-tmpfiles-setup.service.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/units/systemd-tmpfiles-setup.service.in b/units/systemd-tmpfiles-setup.service.in +index 67c7d4a..6f98063 100644 +--- a/units/systemd-tmpfiles-setup.service.in ++++ b/units/systemd-tmpfiles-setup.service.in +@@ -21,4 +21,4 @@ ConditionDirectoryNotEmpty=|/run/tmpfiles.d + [Service] + Type=oneshot + RemainAfterExit=yes +-ExecStart=@rootbindir@/systemd-tmpfiles --create --remove ++ExecStart=@rootbindir@/systemd-tmpfiles --create --remove --exclude-prefix=/dev diff --git a/0014-logind-update-state-file-after-generating-the-sessio.patch b/0014-logind-update-state-file-after-generating-the-sessio.patch new file mode 100644 index 0000000..f05a186 --- /dev/null +++ b/0014-logind-update-state-file-after-generating-the-sessio.patch @@ -0,0 +1,81 @@ +From 49d2e4a62d9c94c4c4aeeb6c4da4b226f9a638a7 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 26 Jul 2013 17:32:19 +0200 +Subject: [PATCH] logind: update state file after generating the session fifo, + not before + +https://bugs.freedesktop.org/show_bug.cgi?id=67273 +--- + src/login/logind-dbus.c | 7 ++++++- + src/login/logind-session-dbus.c | 4 ++++ + src/machine/machined-dbus.c | 3 ++- + 3 files changed, 12 insertions(+), 2 deletions(-) + +diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c +index 39af637..b5e975a 100644 +--- a/src/login/logind-dbus.c ++++ b/src/login/logind-dbus.c +@@ -643,6 +643,10 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message) { + + session->create_message = dbus_message_ref(message); + ++ /* Now, let's wait until the slice unit and stuff got ++ * created. We send the reply back from ++ * session_send_create_reply().*/ ++ + return 0; + + fail: +@@ -2356,7 +2360,6 @@ DBusHandlerResult bus_message_filter( + if (streq_ptr(path, s->scope_job)) { + free(s->scope_job); + s->scope_job = NULL; +- session_save(s); + + if (s->started) { + if (streq(result, "done")) +@@ -2366,6 +2369,8 @@ DBusHandlerResult bus_message_filter( + session_send_create_reply(s, &error); + } + } ++ ++ session_save(s); + } + + session_add_to_gc_queue(s); +diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c +index 62b9ffd..210f756 100644 +--- a/src/login/logind-session-dbus.c ++++ b/src/login/logind-session-dbus.c +@@ -535,6 +535,10 @@ int session_send_create_reply(Session *s, DBusError *error) { + if (!s->create_message) + return 0; + ++ /* This is called after the session scope was successfully ++ * created, and finishes where bus_manager_create_session() ++ * left off. */ ++ + if (error) { + DBusError buffer; + +diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c +index 1e8bc60..6c4d50b 100644 +--- a/src/machine/machined-dbus.c ++++ b/src/machine/machined-dbus.c +@@ -543,7 +543,6 @@ DBusHandlerResult bus_message_filter( + if (streq_ptr(path, mm->scope_job)) { + free(mm->scope_job); + mm->scope_job = NULL; +- machine_save(mm); + + if (mm->started) { + if (streq(result, "done")) +@@ -553,6 +552,8 @@ DBusHandlerResult bus_message_filter( + machine_send_create_reply(mm, &error); + } + } ++ ++ machine_save(mm); + } + + machine_add_to_gc_queue(mm); diff --git a/0015-journalctl-use-_COMM-match-for-scripts.patch b/0015-journalctl-use-_COMM-match-for-scripts.patch new file mode 100644 index 0000000..ae625b8 --- /dev/null +++ b/0015-journalctl-use-_COMM-match-for-scripts.patch @@ -0,0 +1,177 @@ +From 8517d72d5e52fb99eedfe4667303d5883fd38698 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Fri, 19 Jul 2013 04:02:50 -0400 +Subject: [PATCH] journalctl: use _COMM= match for scripts + +In case of scripts, _EXE is set to the interpreter name, and +_COMM is set based on the file name. Add a match for _COMM, +and _EXE if the interpreter is not a link (e.g. for yum, +the interpreter is /usr/bin/python, but it is a link to +/usr/bin/python2, which in turn is a link to /usr/bin/python2.7, +at least on Fedora, so we end up with _EXE=/usr/bin/python2.7). +I don't think that such link chasing makes sense, because +the final _EXE name is more likely to change. +--- + src/journal/journalctl.c | 30 ++++++++++++++++++++++++++---- + src/shared/fileio.c | 29 +++++++++++++++++++++++++++++ + src/shared/fileio.h | 2 ++ + src/test/test-fileio.c | 35 +++++++++++++++++++++++++++++++++++ + 4 files changed, 92 insertions(+), 4 deletions(-) + +diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c +index 083a597..dde2ed7 100644 +--- a/src/journal/journalctl.c ++++ b/src/journal/journalctl.c +@@ -45,6 +45,7 @@ + #include "logs-show.h" + #include "util.h" + #include "path-util.h" ++#include "fileio.h" + #include "build.h" + #include "pager.h" + #include "logs-show.h" +@@ -627,8 +628,9 @@ static int add_matches(sd_journal *j, char **args) { + if (streq(*i, "+")) + r = sd_journal_add_disjunction(j); + else if (path_is_absolute(*i)) { +- _cleanup_free_ char *p, *t = NULL; ++ _cleanup_free_ char *p, *t = NULL, *t2 = NULL; + const char *path; ++ _cleanup_free_ char *interpreter = NULL; + struct stat st; + + p = canonicalize_file_name(*i); +@@ -639,9 +641,27 @@ static int add_matches(sd_journal *j, char **args) { + return -errno; + } + +- if (S_ISREG(st.st_mode) && (0111 & st.st_mode)) +- t = strappend("_EXE=", path); +- else if (S_ISCHR(st.st_mode)) ++ if (S_ISREG(st.st_mode) && (0111 & st.st_mode)) { ++ if (executable_is_script(path, &interpreter) > 0) { ++ _cleanup_free_ char *comm; ++ ++ comm = strndup(path_get_file_name(path), 15); ++ if (!comm) ++ return log_oom(); ++ ++ t = strappend("_COMM=", comm); ++ ++ /* Append _EXE only if the interpreter is not a link. ++ Otherwise it might be outdated often. */ ++ if (lstat(interpreter, &st) == 0 && ++ !S_ISLNK(st.st_mode)) { ++ t2 = strappend("_EXE=", interpreter); ++ if (!t2) ++ return log_oom(); ++ } ++ } else ++ t = strappend("_EXE=", path); ++ } else if (S_ISCHR(st.st_mode)) + asprintf(&t, "_KERNEL_DEVICE=c%u:%u", major(st.st_rdev), minor(st.st_rdev)); + else if (S_ISBLK(st.st_mode)) + asprintf(&t, "_KERNEL_DEVICE=b%u:%u", major(st.st_rdev), minor(st.st_rdev)); +@@ -654,6 +674,8 @@ static int add_matches(sd_journal *j, char **args) { + return log_oom(); + + r = sd_journal_add_match(j, t, 0); ++ if (t2) ++ r = sd_journal_add_match(j, t2, 0); + } else + r = sd_journal_add_match(j, *i, 0); + +diff --git a/src/shared/fileio.c b/src/shared/fileio.c +index dc13c9e..2b1dab8 100644 +--- a/src/shared/fileio.c ++++ b/src/shared/fileio.c +@@ -593,3 +593,32 @@ int write_env_file(const char *fname, char **l) { + + return r; + } ++ ++int executable_is_script(const char *path, char **interpreter) { ++ int r; ++ char _cleanup_free_ *line = NULL; ++ int len; ++ char *ans; ++ ++ assert(path); ++ ++ r = read_one_line_file(path, &line); ++ if (r < 0) ++ return r; ++ ++ if (!startswith(line, "#!")) ++ return 0; ++ ++ ans = strstrip(line + 2); ++ len = strcspn(ans, " \t"); ++ ++ if (len == 0) ++ return 0; ++ ++ ans = strndup(ans, len); ++ if (!ans) ++ return -ENOMEM; ++ ++ *interpreter = ans; ++ return 1; ++} +diff --git a/src/shared/fileio.h b/src/shared/fileio.h +index 0ca6878..a0aae28 100644 +--- a/src/shared/fileio.h ++++ b/src/shared/fileio.h +@@ -35,3 +35,5 @@ int read_full_file(const char *fn, char **contents, size_t *size); + int parse_env_file(const char *fname, const char *separator, ...) _sentinel_; + int load_env_file(const char *fname, const char *separator, char ***l); + int write_env_file(const char *fname, char **l); ++ ++int executable_is_script(const char *path, char **interpreter); +diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c +index d56f7cc..b08e796 100644 +--- a/src/test/test-fileio.c ++++ b/src/test/test-fileio.c +@@ -139,7 +139,42 @@ static void test_parse_env_file(void) { + unlink("/tmp/test-fileio"); + } + ++static void test_executable_is_script(void) { ++ char t[] = "/tmp/test-executable-XXXXXX"; ++ int fd, r; ++ FILE *f; ++ char *command; ++ ++ fd = mkostemp(t, O_CLOEXEC); ++ assert_se(fd >= 0); ++ ++ f = fdopen(fd, "w"); ++ assert_se(f); ++ ++ fputs("#! /bin/script -a -b \ngoo goo", f); ++ fflush(f); ++ ++ r = executable_is_script(t, &command); ++ assert_se(r > 0); ++ assert_se(streq(command, "/bin/script")); ++ free(command); ++ ++ r = executable_is_script("/bin/sh", &command); ++ assert_se(r == 0); ++ ++ r = executable_is_script("/usr/bin/yum", &command); ++ assert_se(r > 0 || r == -ENOENT); ++ if (r > 0) { ++ assert_se(startswith(command, "/")); ++ free(command); ++ } ++ ++ fclose(f); ++ unlink(t); ++} ++ + int main(int argc, char *argv[]) { + test_parse_env_file(); ++ test_executable_is_script(); + return 0; + } diff --git a/0016-man-systemd.unit-fix-volatile-path.patch b/0016-man-systemd.unit-fix-volatile-path.patch new file mode 100644 index 0000000..aa8cd39 --- /dev/null +++ b/0016-man-systemd.unit-fix-volatile-path.patch @@ -0,0 +1,24 @@ +From fb65edbfc52681e54b8af6fceab780497034d8e7 Mon Sep 17 00:00:00 2001 +From: Brandon Philips +Date: Sat, 27 Jul 2013 09:49:58 -0700 +Subject: [PATCH] man: systemd.unit: fix volatile path + +The volatile path was '/run/systemd/systemd' when it should be +'/run/systemd/system'. Fix. +--- + man/systemd.unit.xml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml +index f6a0791..2f65ec6 100644 +--- a/man/systemd.unit.xml ++++ b/man/systemd.unit.xml +@@ -285,7 +285,7 @@ + Local configuration + + +- /run/systemd/systemd ++ /run/systemd/system + Volatile units + + diff --git a/0017-man-link-up-scope-slice-units-from-systemd.unit-5.patch b/0017-man-link-up-scope-slice-units-from-systemd.unit-5.patch new file mode 100644 index 0000000..8fa0d66 --- /dev/null +++ b/0017-man-link-up-scope-slice-units-from-systemd.unit-5.patch @@ -0,0 +1,63 @@ +From f2ec9c58f792df949cc18581ccb0280d94d078b1 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 24 Jul 2013 17:31:17 +0200 +Subject: [PATCH] man: link up scope+slice units from systemd.unit(5) + +--- + man/systemd.unit.xml | 21 +++++++++++++++------ + 1 file changed, 15 insertions(+), 6 deletions(-) + +diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml +index 2f65ec6..a577e91 100644 +--- a/man/systemd.unit.xml ++++ b/man/systemd.unit.xml +@@ -60,7 +60,9 @@ + target.target, + path.path, + timer.timer, +- snapshot.snapshot ++ snapshot.snapshot, ++ slice.slice, ++ scope.scope + + /etc/systemd/system/* + /run/systemd/system/* +@@ -81,12 +83,15 @@ + A unit configuration file encodes information + about a service, a socket, a device, a mount point, an + automount point, a swap file or partition, a start-up +- target, a file system path, or a timer controlled and +- supervised by +- systemd1. The +- syntax is inspired by systemd1, ++ a temporary system state snapshot, a resource ++ management slice or a group of externally created ++ processes. The syntax is inspired by XDG +- Desktop Entry Specification .desktop files, which are in turn ++ Desktop Entry Specification ++ .desktop files, which are in turn + inspired by Microsoft Windows + .ini files. + +@@ -110,6 +115,8 @@ + systemd.path5, + systemd.timer5, + systemd.snapshot5. ++ systemd.slice5. ++ systemd.scope5. + + + Unit files are loaded from a set of paths +@@ -1324,6 +1331,8 @@ + systemd.path5, + systemd.timer5, + systemd.snapshot5, ++ systemd.scope5, ++ systemd.slice5, + systemd.time7, + capabilities7, + systemd.directives7, diff --git a/0018-man-there-is-no-session-mode-only-user-mode.patch b/0018-man-there-is-no-session-mode-only-user-mode.patch new file mode 100644 index 0000000..12a47b2 --- /dev/null +++ b/0018-man-there-is-no-session-mode-only-user-mode.patch @@ -0,0 +1,22 @@ +From 5b09d0b9082447bea8cd0365a632305133e0277f Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 24 Jul 2013 17:31:37 +0200 +Subject: [PATCH] man: there is no session mode, only user mode + +--- + man/systemd.unit.xml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml +index a577e91..1b71538 100644 +--- a/man/systemd.unit.xml ++++ b/man/systemd.unit.xml +@@ -317,7 +317,7 @@ + + + +- Load path when running in session mode (<option>--user</option>). ++ Load path when running in user mode (<option>--user</option>). + + + diff --git a/0019-journal-fix-hashmap-leak-in-mmap-cache.patch b/0019-journal-fix-hashmap-leak-in-mmap-cache.patch new file mode 100644 index 0000000..5ae4141 --- /dev/null +++ b/0019-journal-fix-hashmap-leak-in-mmap-cache.patch @@ -0,0 +1,37 @@ +From 7ed8571a3dbfd768488c1db082e0bebb2c88fbcb Mon Sep 17 00:00:00 2001 +From: George McCollister +Date: Thu, 1 Aug 2013 12:40:01 -0500 +Subject: [PATCH] journal: fix hashmap leak in mmap-cache + +hashmap_free() wasn't being called on m->contexts and m->fds resulting +in a leak. + +To reproduce do: + while(1) { + sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); + sd_journal_close(j); + } + +Memory usage will increase until OOM. +--- + src/journal/mmap-cache.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c +index 767f555..03b57be 100644 +--- a/src/journal/mmap-cache.c ++++ b/src/journal/mmap-cache.c +@@ -307,9 +307,13 @@ static void mmap_cache_free(MMapCache *m) { + while ((c = hashmap_first(m->contexts))) + context_free(c); + ++ hashmap_free(m->contexts); ++ + while ((f = hashmap_first(m->fds))) + fd_free(f); + ++ hashmap_free(m->fds); ++ + while (m->unused) + window_free(m->unused); + diff --git a/0020-systemd-delta-Only-print-colors-when-on-a-tty.patch b/0020-systemd-delta-Only-print-colors-when-on-a-tty.patch new file mode 100644 index 0000000..9f40384 --- /dev/null +++ b/0020-systemd-delta-Only-print-colors-when-on-a-tty.patch @@ -0,0 +1,306 @@ +From 2c8837069cfd00a0a440d229f2086899cf43cd62 Mon Sep 17 00:00:00 2001 +From: Daniel Schaal +Date: Fri, 2 Aug 2013 07:59:02 +0200 +Subject: [PATCH] systemd-delta: Only print colors when on a tty + +This make systemd-delta follow the behaviour of systemctl +and journalctl. + +https://bugs.freedesktop.org/show_bug.cgi?id=67656 + +[zj: unify color query methods between those three programs.] +--- + src/delta/delta.c | 15 +++++--- + src/journal/journalctl.c | 5 ++- + src/shared/util.h | 16 +++++++++ + src/systemctl/systemctl.c | 88 +++++++++++++++++------------------------------ + 4 files changed, 60 insertions(+), 64 deletions(-) + +diff --git a/src/delta/delta.c b/src/delta/delta.c +index 49c2fc3..b3272d9 100644 +--- a/src/delta/delta.c ++++ b/src/delta/delta.c +@@ -66,7 +66,8 @@ static int notify_override_masked(const char *top, const char *bottom) { + if (!(arg_flags & SHOW_MASKED)) + return 0; + +- printf(ANSI_HIGHLIGHT_RED_ON "[MASKED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); ++ printf("%s%s%s %s → %s\n", ++ ansi_highlight_red(), "[MASKED]", ansi_highlight_off(), top, bottom); + return 1; + } + +@@ -74,7 +75,8 @@ static int notify_override_equivalent(const char *top, const char *bottom) { + if (!(arg_flags & SHOW_EQUIVALENT)) + return 0; + +- printf(ANSI_HIGHLIGHT_GREEN_ON "[EQUIVALENT]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); ++ printf("%s%s%s %s → %s\n", ++ ansi_highlight_green(), "[EQUIVALENT]", ansi_highlight(), top, bottom); + return 1; + } + +@@ -82,7 +84,8 @@ static int notify_override_redirected(const char *top, const char *bottom) { + if (!(arg_flags & SHOW_REDIRECTED)) + return 0; + +- printf(ANSI_HIGHLIGHT_ON "[REDIRECTED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); ++ printf("%s%s%s %s → %s\n", ++ ansi_highlight(), "[REDIRECTED]", ansi_highlight_off(), top, bottom); + return 1; + } + +@@ -90,7 +93,8 @@ static int notify_override_overridden(const char *top, const char *bottom) { + if (!(arg_flags & SHOW_OVERRIDDEN)) + return 0; + +- printf(ANSI_HIGHLIGHT_ON "[OVERRIDDEN]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); ++ printf("%s%s%s %s → %s\n", ++ ansi_highlight(), "[OVERRIDDEN]", ansi_highlight_off(), top, bottom); + return 1; + } + +@@ -98,7 +102,8 @@ static int notify_override_extended(const char *top, const char *bottom) { + if (!(arg_flags & SHOW_EXTENDED)) + return 0; + +- printf(ANSI_HIGHLIGHT_ON "[EXTENDED]" ANSI_HIGHLIGHT_OFF " %s → %s\n", top, bottom); ++ printf("%s%s%s %s → %s\n", ++ ansi_highlight(), "[EXTENDED]", ansi_highlight_off(), top, bottom); + return 1; + } + +diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c +index dde2ed7..feea6bf 100644 +--- a/src/journal/journalctl.c ++++ b/src/journal/journalctl.c +@@ -1605,14 +1605,13 @@ int main(int argc, char *argv[]) { + + if (!arg_merge) { + sd_id128_t boot_id; +- const char *color_on = on_tty() ? ANSI_HIGHLIGHT_ON : "", +- *color_off = on_tty() ? ANSI_HIGHLIGHT_OFF : ""; + + r = sd_journal_get_monotonic_usec(j, NULL, &boot_id); + if (r >= 0) { + if (previous_boot_id_valid && + !sd_id128_equal(boot_id, previous_boot_id)) +- printf("%s-- Reboot --%s\n", color_on, color_off); ++ printf("%s-- Reboot --%s\n", ++ ansi_highlight(), ansi_highlight_off()); + + previous_boot_id = boot_id; + previous_boot_id_valid = true; +diff --git a/src/shared/util.h b/src/shared/util.h +index ac999c6..3be692e 100644 +--- a/src/shared/util.h ++++ b/src/shared/util.h +@@ -374,6 +374,22 @@ void columns_lines_cache_reset(int _unused_ signum); + + bool on_tty(void); + ++static inline const char *ansi_highlight(void) { ++ return on_tty() ? ANSI_HIGHLIGHT_ON : ""; ++} ++ ++static inline const char *ansi_highlight_red(void) { ++ return on_tty() ? ANSI_HIGHLIGHT_RED_ON : ""; ++} ++ ++static inline const char *ansi_highlight_green(void) { ++ return on_tty() ? ANSI_HIGHLIGHT_GREEN_ON : ""; ++} ++ ++static inline const char *ansi_highlight_off(void) { ++ return on_tty() ? ANSI_HIGHLIGHT_OFF : ""; ++} ++ + int running_in_chroot(void); + + char *ellipsize(const char *s, size_t length, unsigned percent); +diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c +index 9f47b2c..aca033b 100644 +--- a/src/systemctl/systemctl.c ++++ b/src/systemctl/systemctl.c +@@ -175,30 +175,6 @@ static void polkit_agent_open_if_enabled(void) { + } + #endif + +-static const char *ansi_highlight(bool b) { +- +- if (!on_tty()) +- return ""; +- +- return b ? ANSI_HIGHLIGHT_ON : ANSI_HIGHLIGHT_OFF; +-} +- +-static const char *ansi_highlight_red(bool b) { +- +- if (!on_tty()) +- return ""; +- +- return b ? ANSI_HIGHLIGHT_RED_ON : ANSI_HIGHLIGHT_OFF; +-} +- +-static const char *ansi_highlight_green(bool b) { +- +- if (!on_tty()) +- return ""; +- +- return b ? ANSI_HIGHLIGHT_GREEN_ON : ANSI_HIGHLIGHT_OFF; +-} +- + static int translate_bus_error_to_exit_status(int r, const DBusError *error) { + assert(error); + +@@ -381,14 +357,14 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) { + + if (streq(u->load_state, "error") || + streq(u->load_state, "not-found")) { +- on_loaded = on = ansi_highlight_red(true); +- off_loaded = off = ansi_highlight_red(false); ++ on_loaded = on = ansi_highlight_red(); ++ off_loaded = off = ansi_highlight_off(); + } else + on_loaded = off_loaded = ""; + + if (streq(u->active_state, "failed")) { +- on_active = on = ansi_highlight_red(true); +- off_active = off = ansi_highlight_red(false); ++ on_active = on = ansi_highlight_red(); ++ off_active = off = ansi_highlight_off(); + } else + on_active = off_active = ""; + +@@ -416,11 +392,11 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) { + if (job_count) + printf("JOB = Pending job for the unit.\n"); + puts(""); +- on = ansi_highlight(true); +- off = ansi_highlight(false); ++ on = ansi_highlight(); ++ off = ansi_highlight_off(); + } else { +- on = ansi_highlight_red(true); +- off = ansi_highlight_red(false); ++ on = ansi_highlight_red(); ++ off = ansi_highlight_off(); + } + + if (arg_all) +@@ -683,13 +659,13 @@ static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) { + printf("\n"); + } + +- on = ansi_highlight(true); +- off = ansi_highlight(false); ++ on = ansi_highlight(); ++ off = ansi_highlight_off(); + if (!arg_no_legend) + printf("\n"); + } else { +- on = ansi_highlight_red(true); +- off = ansi_highlight_red(false); ++ on = ansi_highlight_red(); ++ off = ansi_highlight_off(); + } + + if (!arg_no_legend) { +@@ -838,11 +814,11 @@ static void output_unit_file_list(const UnitFileList *units, unsigned c) { + u->state == UNIT_FILE_MASKED_RUNTIME || + u->state == UNIT_FILE_DISABLED || + u->state == UNIT_FILE_INVALID) { +- on = ansi_highlight_red(true); +- off = ansi_highlight_red(false); ++ on = ansi_highlight_red(); ++ off = ansi_highlight_off(); + } else if (u->state == UNIT_FILE_ENABLED) { +- on = ansi_highlight_green(true); +- off = ansi_highlight_green(false); ++ on = ansi_highlight_green(); ++ off = ansi_highlight_off(); + } else + on = off = ""; + +@@ -1250,8 +1226,8 @@ static void list_jobs_print(struct job_info* jobs, size_t n) { + assert(n == 0 || jobs); + + if (n == 0) { +- on = ansi_highlight_green(true); +- off = ansi_highlight_green(false); ++ on = ansi_highlight_green(); ++ off = ansi_highlight_off(); + + printf("%sNo jobs running.%s\n", on, off); + return; +@@ -1287,8 +1263,8 @@ static void list_jobs_print(struct job_info* jobs, size_t n) { + _cleanup_free_ char *e = NULL; + + if (streq(j->state, "running")) { +- on = ansi_highlight(true); +- off = ansi_highlight(false); ++ on = ansi_highlight(); ++ off = ansi_highlight_off(); + } else + on = off = ""; + +@@ -1301,8 +1277,8 @@ static void list_jobs_print(struct job_info* jobs, size_t n) { + } + } + +- on = ansi_highlight(true); +- off = ansi_highlight(false); ++ on = ansi_highlight(); ++ off = ansi_highlight_off(); + + if (on_tty()) + printf("\n%s%zu jobs listed%s.\n", on, n, off); +@@ -2588,8 +2564,8 @@ static void print_status_info(UnitStatusInfo *i) { + printf(" Follow: unit currently follows state of %s\n", i->following); + + if (streq_ptr(i->load_state, "error")) { +- on = ansi_highlight_red(true); +- off = ansi_highlight_red(false); ++ on = ansi_highlight_red(); ++ off = ansi_highlight_off(); + } else + on = off = ""; + +@@ -2639,11 +2615,11 @@ static void print_status_info(UnitStatusInfo *i) { + ss = streq_ptr(i->active_state, i->sub_state) ? NULL : i->sub_state; + + if (streq_ptr(i->active_state, "failed")) { +- on = ansi_highlight_red(true); +- off = ansi_highlight_red(false); ++ on = ansi_highlight_red(); ++ off = ansi_highlight_off(); + } else if (streq_ptr(i->active_state, "active") || streq_ptr(i->active_state, "reloading")) { +- on = ansi_highlight_green(true); +- off = ansi_highlight_green(false); ++ on = ansi_highlight_green(); ++ off = ansi_highlight_off(); + } else + on = off = ""; + +@@ -2718,8 +2694,8 @@ static void print_status_info(UnitStatusInfo *i) { + + good = is_clean_exit_lsb(p->code, p->status, NULL); + if (!good) { +- on = ansi_highlight_red(true); +- off = ansi_highlight_red(false); ++ on = ansi_highlight_red(); ++ off = ansi_highlight_off(); + } else + on = off = ""; + +@@ -2838,8 +2814,8 @@ static void print_status_info(UnitStatusInfo *i) { + + if (i->need_daemon_reload) + printf("\n%sWarning:%s Unit file changed on disk, 'systemctl %sdaemon-reload' recommended.\n", +- ansi_highlight_red(true), +- ansi_highlight_red(false), ++ ansi_highlight_red(), ++ ansi_highlight_off(), + arg_scope == UNIT_FILE_SYSTEM ? "" : "--user "); + } + diff --git a/0021-systemd-fix-segv-in-snapshot-creation.patch b/0021-systemd-fix-segv-in-snapshot-creation.patch new file mode 100644 index 0000000..34b79fb --- /dev/null +++ b/0021-systemd-fix-segv-in-snapshot-creation.patch @@ -0,0 +1,26 @@ +From 2c853443d3518f638b58f30cd866ca2d4c401281 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 6 Aug 2013 21:30:34 -0400 +Subject: [PATCH] systemd: fix segv in snapshot creation + +https://bugs.freedesktop.org/show_bug.cgi?id=67848 +--- + src/core/snapshot.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/core/snapshot.c b/src/core/snapshot.c +index 1423854..d11239d 100644 +--- a/src/core/snapshot.c ++++ b/src/core/snapshot.c +@@ -221,8 +221,10 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, DBusError *e, Sn + if (asprintf(&n, "snapshot-%u.snapshot", ++ m->n_snapshots) < 0) + return -ENOMEM; + +- if (!manager_get_unit(m, n)) ++ if (!manager_get_unit(m, n)) { ++ name = n; + break; ++ } + + free(n); + n = NULL; diff --git a/0022-udev-hwdb-try-reading-modalias-for-usb-before-fallin.patch b/0022-udev-hwdb-try-reading-modalias-for-usb-before-fallin.patch new file mode 100644 index 0000000..cc8084f --- /dev/null +++ b/0022-udev-hwdb-try-reading-modalias-for-usb-before-fallin.patch @@ -0,0 +1,32 @@ +From a6dfef02531465a318de68ac2cd3343250b9ef3a Mon Sep 17 00:00:00 2001 +From: Kay Sievers +Date: Wed, 7 Aug 2013 13:10:01 +0200 +Subject: [PATCH] udev: hwdb - try reading modalias for usb before falling back + to the composed one + +--- + src/udev/udev-builtin-hwdb.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c +index f1c0ca9..d6aa96b 100644 +--- a/src/udev/udev-builtin-hwdb.c ++++ b/src/udev/udev-builtin-hwdb.c +@@ -102,14 +102,13 @@ static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device + if (subsystem && !streq(dsubsys, subsystem)) + continue; + ++ modalias = udev_device_get_property_value(d, "MODALIAS"); ++ + /* the usb_device does not have a modalias, compose one */ +- if (streq(dsubsys, "usb")) ++ if (!modalias && streq(dsubsys, "usb")) + modalias = modalias_usb(d, s, sizeof(s)); + + if (!modalias) +- modalias = udev_device_get_property_value(d, "MODALIAS"); +- +- if (!modalias) + continue; + + n = udev_builtin_hwdb_lookup(dev, prefix, modalias, filter, test); diff --git a/0023-udevd-respect-the-log-level-set-in-etc-udev-udev.con.patch b/0023-udevd-respect-the-log-level-set-in-etc-udev-udev.con.patch new file mode 100644 index 0000000..ae48c24 --- /dev/null +++ b/0023-udevd-respect-the-log-level-set-in-etc-udev-udev.con.patch @@ -0,0 +1,29 @@ +From 0e842bc91f0a60d06aecf23d5881773d5c66af59 Mon Sep 17 00:00:00 2001 +From: Tom Gundersen +Date: Thu, 8 Aug 2013 21:44:02 +0200 +Subject: [PATCH] udevd: respect the log-level set in /etc/udev/udev.conf + +A regression introduced when we moved to systemd's logging is that the only +way to adjust the log-level of the udev daemon is via the env var, kernel +commandline or the commandline. + +This reintroduces support for specifying this in the configuration file. +--- + src/udev/udevd.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/udev/udevd.c b/src/udev/udevd.c +index 45ec3d6..7c6c5d6 100644 +--- a/src/udev/udevd.c ++++ b/src/udev/udevd.c +@@ -923,7 +923,10 @@ int main(int argc, char *argv[]) + log_set_target(LOG_TARGET_AUTO); + log_parse_environment(); + log_open(); ++ + udev_set_log_fn(udev, udev_main_log); ++ log_set_max_level(udev_get_log_priority(udev)); ++ + log_debug("version %s\n", VERSION); + label_init("/dev"); + diff --git a/0024-fstab-generator-respect-noauto-nofail-when-adding-sy.patch b/0024-fstab-generator-respect-noauto-nofail-when-adding-sy.patch new file mode 100644 index 0000000..1dbf1b1 --- /dev/null +++ b/0024-fstab-generator-respect-noauto-nofail-when-adding-sy.patch @@ -0,0 +1,45 @@ +From 03c6b09de9b0d2b96657bc4b2b6d59b8425e3d12 Mon Sep 17 00:00:00 2001 +From: WANG Chao +Date: Thu, 8 Aug 2013 15:18:11 +0800 +Subject: [PATCH] fstab-generator: respect noauto/nofail when adding sysroot + mount + +Currently we don't respect noauto/nofail root mount options (from +rootflags kernel cmdline). We should map these two flags to the +corresponding boolean variable noauto and nofail when calling +add_mount(). +--- + src/fstab-generator/fstab-generator.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index c17299f..87b17cd 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -492,6 +492,7 @@ static int parse_new_root_from_proc_cmdline(void) { + char *w, *state; + int r; + size_t l; ++ bool noauto, nofail; + + r = read_one_line_file("/proc/cmdline", &line); + if (r < 0) { +@@ -547,6 +548,9 @@ static int parse_new_root_from_proc_cmdline(void) { + } + } + ++ noauto = !!strstr(opts, "noauto"); ++ nofail = !!strstr(opts, "nofail"); ++ + if (!what) { + log_debug("Could not find a root= entry on the kernel commandline."); + return 0; +@@ -558,7 +562,7 @@ static int parse_new_root_from_proc_cmdline(void) { + } + + log_debug("Found entry what=%s where=/sysroot type=%s", what, type); +- r = add_mount(what, "/sysroot", type, opts, 0, false, false, false, ++ r = add_mount(what, "/sysroot", type, opts, 0, noauto, nofail, false, + false, NULL, NULL, NULL, SPECIAL_INITRD_ROOT_FS_TARGET, "/proc/cmdline"); + + return (r < 0) ? r : 0; diff --git a/0025-service-always-unwatch-PIDs-before-forgetting-old-on.patch b/0025-service-always-unwatch-PIDs-before-forgetting-old-on.patch new file mode 100644 index 0000000..daa6f86 --- /dev/null +++ b/0025-service-always-unwatch-PIDs-before-forgetting-old-on.patch @@ -0,0 +1,43 @@ +From 7372290556ee2df52a0dbd87dc2af6bd610198de Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 9 Aug 2013 16:40:57 +0200 +Subject: [PATCH] service: always unwatch PIDs before forgetting old ones + +--- + src/core/service.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/src/core/service.c b/src/core/service.c +index b98f11a..df49ce1 100644 +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -191,6 +191,8 @@ static int service_set_main_pid(Service *s, pid_t pid) { + if (pid == getpid()) + return -EINVAL; + ++ service_unwatch_main_pid(s); ++ + s->main_pid = pid; + s->main_pid_known = true; + +@@ -2158,10 +2160,8 @@ static void service_enter_start(Service *s) { + assert(s->exec_command[SERVICE_EXEC_START]); + assert(!s->exec_command[SERVICE_EXEC_START]->command_next || s->type == SERVICE_ONESHOT); + +- if (s->type == SERVICE_FORKING) +- service_unwatch_control_pid(s); +- else +- service_unwatch_main_pid(s); ++ service_unwatch_control_pid(s); ++ service_unwatch_main_pid(s); + + /* We want to ensure that nobody leaks processes from + * START_PRE here, so let's go on a killing spree, People +@@ -3751,6 +3751,7 @@ static void service_reset_failed(Unit *u) { + + static int service_kill(Unit *u, KillWho who, int signo, DBusError *error) { + Service *s = SERVICE(u); ++ + return unit_kill_common(u, who, signo, s->main_pid, s->control_pid, error); + } + diff --git a/0026-units-disable-kmod-static-nodes.service-in-container.patch b/0026-units-disable-kmod-static-nodes.service-in-container.patch new file mode 100644 index 0000000..bc4dfa0 --- /dev/null +++ b/0026-units-disable-kmod-static-nodes.service-in-container.patch @@ -0,0 +1,30 @@ +From cdeb74502d64ea47d1751afc2de82d51ef192c88 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Mon, 19 Aug 2013 16:59:42 -0400 +Subject: [PATCH] units: disable kmod-static-nodes.service in containers + +Fixes https://bugzilla.redhat.com/show_bug.cgi?id=998122. + +Note: upstream kmod has a patch [1] to exit with a warning if +modules.devname is missing. We could use new %v specifier to make this +service conditional on the existence of this file, but this could +mask a kernel installation error, hence we should let kmod run +even if the file doesn't exist. + +[1] http://git.kernel.org/cgit/utils/kernel/kmod/kmod.git/commit/?id=ae17710117 +--- + units/kmod-static-nodes.service.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/units/kmod-static-nodes.service.in b/units/kmod-static-nodes.service.in +index cdfc6e5..98664ea 100644 +--- a/units/kmod-static-nodes.service.in ++++ b/units/kmod-static-nodes.service.in +@@ -9,6 +9,7 @@ + Description=Create list of required static device nodes for the current kernel + DefaultDependencies=no + Before=sysinit.target systemd-tmpfiles-setup-dev.service ++ConditionVirtualization=!container + + [Service] + Type=oneshot diff --git a/0027-use-CAP_MKNOD-ConditionCapability.patch b/0027-use-CAP_MKNOD-ConditionCapability.patch new file mode 100644 index 0000000..ffd18c8 --- /dev/null +++ b/0027-use-CAP_MKNOD-ConditionCapability.patch @@ -0,0 +1,31 @@ +From 035b40d564a47fb53a78f08a7bbf218a6920061d Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 21 Aug 2013 20:35:44 -0700 +Subject: [PATCH] use CAP_MKNOD ConditionCapability + +Fixes errors seen when booting VMs on QEMU like + +systemd[1]: kmod-static-nodes.service: main process exited, code=exited, status=203/EXEC +systemd[1]: Failed to start Create list of required static device nodes for the current kernel. +systemd[1]: Unit kmod-static-nodes.service entered failed state. + +Make sure that mknod capability is available + +Signed-off-by: Khem Raj +--- + units/kmod-static-nodes.service.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/units/kmod-static-nodes.service.in b/units/kmod-static-nodes.service.in +index 98664ea..d8a8420 100644 +--- a/units/kmod-static-nodes.service.in ++++ b/units/kmod-static-nodes.service.in +@@ -9,7 +9,7 @@ + Description=Create list of required static device nodes for the current kernel + DefaultDependencies=no + Before=sysinit.target systemd-tmpfiles-setup-dev.service +-ConditionVirtualization=!container ++ConditionCapability=CAP_MKNOD + + [Service] + Type=oneshot diff --git a/0028-fstab-generator-read-rd.fstab-on-off-switch-correctl.patch b/0028-fstab-generator-read-rd.fstab-on-off-switch-correctl.patch new file mode 100644 index 0000000..40f3141 --- /dev/null +++ b/0028-fstab-generator-read-rd.fstab-on-off-switch-correctl.patch @@ -0,0 +1,25 @@ +From 81e19a8767e4347df71a2874e724e50b43ee930d Mon Sep 17 00:00:00 2001 +From: WANG Chao +Date: Fri, 9 Aug 2013 17:01:50 +0800 +Subject: [PATCH] fstab-generator: read rd.fstab=on/off switch correctly + +--- + src/fstab-generator/fstab-generator.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 87b17cd..5a2074e 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -600,9 +600,9 @@ static int parse_proc_cmdline(void) { + } else if (startswith(word, "rd.fstab=")) { + + if (in_initrd()) { +- r = parse_boolean(word + 6); ++ r = parse_boolean(word + 9); + if (r < 0) +- log_warning("Failed to parse fstab switch %s. Ignoring.", word + 6); ++ log_warning("Failed to parse fstab switch %s. Ignoring.", word + 9); + else + arg_enabled = r; + } diff --git a/0029-backlight-add-minimal-tool-to-save-restore-screen-br.patch b/0029-backlight-add-minimal-tool-to-save-restore-screen-br.patch new file mode 100644 index 0000000..d414bb6 --- /dev/null +++ b/0029-backlight-add-minimal-tool-to-save-restore-screen-br.patch @@ -0,0 +1,298 @@ +From 032e57b4e9a90dc11352f1d6640ee246e3f32fb7 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 14 Aug 2013 01:57:02 +0200 +Subject: [PATCH] backlight: add minimal tool to save/restore screen brightness + across reboots + +As many laptops don't save/restore screen brightness across reboots, +let's do this in systemd with a minimal tool, that restores the +brightness as early as possible, and saves it as late as possible. This +will cover consoles and graphical logins, but graphical desktops should +do their own per-user stuff probably. + +This only touches firmware brightness controls for now. +--- + .gitignore | 1 + + Makefile.am | 20 ++++++ + configure.ac | 9 +++ + rules/99-systemd.rules.in | 4 ++ + rules/Makefile | 1 + + src/backlight/Makefile | 1 + + src/backlight/backlight.c | 126 ++++++++++++++++++++++++++++++++++++ + units/.gitignore | 1 + + units/systemd-backlight@.service.in | 21 ++++++ + 9 files changed, 184 insertions(+) + create mode 120000 rules/Makefile + create mode 120000 src/backlight/Makefile + create mode 100644 src/backlight/backlight.c + create mode 100644 units/systemd-backlight@.service.in + +diff --git a/.gitignore b/.gitignore +index bdf9d4a..379a3c1 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -29,6 +29,7 @@ + /systemd-ac-power + /systemd-analyze + /systemd-ask-password ++/systemd-backlight + /systemd-binfmt + /systemd-bootchart + /systemd-cat +diff --git a/Makefile.am b/Makefile.am +index 7933de6..0059b1d 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -3267,6 +3267,26 @@ EXTRA_DIST += \ + units/systemd-random-seed.service.in + + # ------------------------------------------------------------------------------ ++if ENABLE_BACKLIGHT ++rootlibexec_PROGRAMS += \ ++ systemd-backlight ++ ++nodist_systemunit_DATA += \ ++ units/systemd-backlight@.service ++ ++systemd_backlight_SOURCES = \ ++ src/backlight/backlight.c ++ ++systemd_backlight_LDADD = \ ++ libsystemd-label.la \ ++ libsystemd-shared.la \ ++ libudev-private.la ++endif ++ ++EXTRA_DIST += \ ++ units/systemd-backlight@.service.in ++ ++# ------------------------------------------------------------------------------ + if HAVE_LIBCRYPTSETUP + rootlibexec_PROGRAMS += \ + systemd-cryptsetup +diff --git a/configure.ac b/configure.ac +index 759073a..f7237bd 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -667,6 +667,14 @@ fi + AM_CONDITIONAL(ENABLE_RANDOMSEED, [test "$have_randomseed" = "yes"]) + + # ------------------------------------------------------------------------------ ++have_backlight=no ++AC_ARG_ENABLE(backlight, AS_HELP_STRING([--disable-backlight], [disable backlight tools])) ++if test "x$enable_backlight" != "xno"; then ++ have_backlight=yes ++fi ++AM_CONDITIONAL(ENABLE_BACKLIGHT, [test "$have_backlight" = "yes"]) ++ ++# ------------------------------------------------------------------------------ + have_logind=no + AC_ARG_ENABLE(logind, AS_HELP_STRING([--disable-logind], [disable login daemon])) + if test "x$enable_logind" != "xno"; then +@@ -992,6 +1000,7 @@ AC_MSG_RESULT([ + quotacheck: ${have_quotacheck} + tmpfiles: ${have_tmpfiles} + randomseed: ${have_randomseed} ++ backlight: ${have_backlight} + logind: ${have_logind} + machined: ${have_machined} + hostnamed: ${have_hostnamed} +diff --git a/rules/99-systemd.rules.in b/rules/99-systemd.rules.in +index e9b2da7..ac4bc86 100644 +--- a/rules/99-systemd.rules.in ++++ b/rules/99-systemd.rules.in +@@ -51,6 +51,10 @@ SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701??: + + ACTION=="add", SUBSYSTEM=="net", KERNEL!="lo", RUN+="@rootlibexecdir@/systemd-sysctl --prefix=/proc/sys/net/ipv4/conf/$name --prefix=/proc/sys/net/ipv4/neigh/$name --prefix=/proc/sys/net/ipv6/conf/$name --prefix=/proc/sys/net/ipv6/neigh/$name" + ++# Pull in backlight save/restore for all firmware backlight devices ++ ++ACTION=="add", SUBSYSTEM=="backlight", ATTR{type}=="firmware", TAG+="systemd", ENV{SYSTEMD_WANTS}+="systemd-backlight@sys%p.service" ++ + # Asynchronously mount file systems implemented by these modules as + # soon as they are loaded. + +diff --git a/rules/Makefile b/rules/Makefile +new file mode 120000 +index 0000000..bd10475 +--- /dev/null ++++ b/rules/Makefile +@@ -0,0 +1 @@ ++../src/Makefile +\ No newline at end of file +diff --git a/src/backlight/Makefile b/src/backlight/Makefile +new file mode 120000 +index 0000000..d0b0e8e +--- /dev/null ++++ b/src/backlight/Makefile +@@ -0,0 +1 @@ ++../Makefile +\ No newline at end of file +diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c +new file mode 100644 +index 0000000..3378907 +--- /dev/null ++++ b/src/backlight/backlight.c +@@ -0,0 +1,126 @@ ++/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ ++ ++/*** ++ This file is part of systemd. ++ ++ Copyright 2013 Lennart Poettering ++ ++ 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 . ++***/ ++ ++#include ++ ++#include "util.h" ++#include "mkdir.h" ++#include "fileio.h" ++ ++int main(int argc, char *argv[]) { ++ struct udev *udev = NULL; ++ struct udev_device *device = NULL; ++ _cleanup_free_ char *saved = NULL; ++ int r; ++ ++ if (argc != 3) { ++ log_error("This program requires two arguments."); ++ return EXIT_FAILURE; ++ } ++ ++ log_set_target(LOG_TARGET_AUTO); ++ log_parse_environment(); ++ log_open(); ++ ++ umask(0022); ++ ++ r = mkdir_p("/var/lib/backlight", 0755); ++ if (r < 0) { ++ log_error("Failed to create backlight directory: %s", strerror(-r)); ++ goto finish; ++ } ++ ++ udev = udev_new(); ++ if (!udev) { ++ r = log_oom(); ++ goto finish; ++ } ++ ++ device = udev_device_new_from_syspath(udev, argv[2]); ++ if (!device) { ++ r = log_oom(); ++ goto finish; ++ } ++ ++ if (!streq_ptr(udev_device_get_subsystem(device), "backlight")) { ++ log_error("Not a backlight device: %s", argv[2]); ++ r = -ENODEV; ++ goto finish; ++ } ++ ++ saved = strappend("/var/lib/backlight/", udev_device_get_sysname(device)); ++ if (!saved) { ++ r = log_oom(); ++ goto finish; ++ } ++ ++ if (streq(argv[1], "load")) { ++ _cleanup_free_ char *value = NULL; ++ ++ r = read_one_line_file(saved, &value); ++ if (r < 0) { ++ ++ if (r == -ENOENT) { ++ r = 0; ++ goto finish; ++ } ++ ++ log_error("Failed to read %s: %s", saved, strerror(-r)); ++ goto finish; ++ } ++ ++ r = udev_device_set_sysattr_value(device, "brightness", value); ++ if (r < 0) { ++ log_error("Failed to write system attribute: %s", strerror(-r)); ++ goto finish; ++ } ++ ++ } else if (streq(argv[1], "save")) { ++ const char *value; ++ ++ value = udev_device_get_sysattr_value(device, "brightness"); ++ if (!value) { ++ log_error("Failed to read system attribute: %s", strerror(-r)); ++ goto finish; ++ } ++ ++ r = write_string_file(saved, value); ++ if (r < 0) { ++ log_error("Failed to write %s: %s", saved, strerror(-r)); ++ goto finish; ++ } ++ ++ } else { ++ log_error("Unknown verb %s.", argv[1]); ++ r = -EINVAL; ++ goto finish; ++ } ++ ++finish: ++ if (device) ++ udev_device_unref(device); ++ ++ if (udev) ++ udev_unref(udev); ++ ++ return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; ++ ++} +diff --git a/units/.gitignore b/units/.gitignore +index 9aee00f..9c65075 100644 +--- a/units/.gitignore ++++ b/units/.gitignore +@@ -1,3 +1,4 @@ ++/systemd-backlight@.service + /halt-local.service + /rc-local.service + /systemd-hybrid-sleep.service +diff --git a/units/systemd-backlight@.service.in b/units/systemd-backlight@.service.in +new file mode 100644 +index 0000000..14b1219 +--- /dev/null ++++ b/units/systemd-backlight@.service.in +@@ -0,0 +1,21 @@ ++# 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. ++ ++[Unit] ++Description=Load/Save Screen Backlight Brightness of %f ++Documentation=man:systemd-backlight@.service(8) ++DefaultDependencies=no ++RequiresMountsFor=/var/lib/backlight ++Conflicts=shutdown.target ++After=systemd-readahead-collect.service systemd-readahead-replay.service systemd-remount-fs.service ++Before=sysinit.target shutdown.target ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++ExecStart=@rootlibexecdir@/systemd-backlight load %f ++ExecStop=@rootlibexecdir@/systemd-backlight save %f diff --git a/0030-backlight-instead-of-syspath-use-sysname-for-identif.patch b/0030-backlight-instead-of-syspath-use-sysname-for-identif.patch new file mode 100644 index 0000000..85bb8e1 --- /dev/null +++ b/0030-backlight-instead-of-syspath-use-sysname-for-identif.patch @@ -0,0 +1,69 @@ +From 3437438503da8aa7e0549dde61f10f2bb0fb5805 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 14 Aug 2013 02:55:57 +0200 +Subject: [PATCH] backlight: instead of syspath use sysname for identifying + backlight devices + +This makes the description string of the backlight service a bit nicer. +--- + rules/99-systemd.rules.in | 2 +- + src/backlight/backlight.c | 10 ++++++++-- + units/systemd-backlight@.service.in | 6 +++--- + 3 files changed, 12 insertions(+), 6 deletions(-) + +diff --git a/rules/99-systemd.rules.in b/rules/99-systemd.rules.in +index ac4bc86..bbb7d0c 100644 +--- a/rules/99-systemd.rules.in ++++ b/rules/99-systemd.rules.in +@@ -53,7 +53,7 @@ ACTION=="add", SUBSYSTEM=="net", KERNEL!="lo", RUN+="@rootlibexecdir@/systemd-sy + + # Pull in backlight save/restore for all firmware backlight devices + +-ACTION=="add", SUBSYSTEM=="backlight", ATTR{type}=="firmware", TAG+="systemd", ENV{SYSTEMD_WANTS}+="systemd-backlight@sys%p.service" ++ACTION=="add", SUBSYSTEM=="backlight", ATTR{type}=="firmware", TAG+="systemd", ENV{SYSTEMD_WANTS}+="systemd-backlight@$name.service" + + # Asynchronously mount file systems implemented by these modules as + # soon as they are loaded. +diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c +index 3378907..1ef0b45 100644 +--- a/src/backlight/backlight.c ++++ b/src/backlight/backlight.c +@@ -54,9 +54,15 @@ int main(int argc, char *argv[]) { + goto finish; + } + +- device = udev_device_new_from_syspath(udev, argv[2]); ++ errno = 0; ++ device = udev_device_new_from_subsystem_sysname(udev, "backlight", argv[2]); + if (!device) { +- r = log_oom(); ++ if (errno != 0) { ++ log_error("Failed to get backlight device: %m"); ++ r = -errno; ++ } else ++ r = log_oom(); ++ + goto finish; + } + +diff --git a/units/systemd-backlight@.service.in b/units/systemd-backlight@.service.in +index 14b1219..b0e75db 100644 +--- a/units/systemd-backlight@.service.in ++++ b/units/systemd-backlight@.service.in +@@ -6,7 +6,7 @@ + # (at your option) any later version. + + [Unit] +-Description=Load/Save Screen Backlight Brightness of %f ++Description=Load/Save Screen Backlight Brightness of %I + Documentation=man:systemd-backlight@.service(8) + DefaultDependencies=no + RequiresMountsFor=/var/lib/backlight +@@ -17,5 +17,5 @@ Before=sysinit.target shutdown.target + [Service] + Type=oneshot + RemainAfterExit=yes +-ExecStart=@rootlibexecdir@/systemd-backlight load %f +-ExecStop=@rootlibexecdir@/systemd-backlight save %f ++ExecStart=@rootlibexecdir@/systemd-backlight load %I ++ExecStop=@rootlibexecdir@/systemd-backlight save %I diff --git a/0031-sysctl-allow-overwriting-of-values-specified-in-late.patch b/0031-sysctl-allow-overwriting-of-values-specified-in-late.patch new file mode 100644 index 0000000..365cab7 --- /dev/null +++ b/0031-sysctl-allow-overwriting-of-values-specified-in-late.patch @@ -0,0 +1,94 @@ +From e3435020cb50691abac53965a7ddf6f66991926f Mon Sep 17 00:00:00 2001 +From: Kay Sievers +Date: Thu, 15 Aug 2013 18:35:03 +0200 +Subject: [PATCH] sysctl: allow overwriting of values specified in "later" + files + +--- + NEWS | 9 +++++++++ + src/sysctl/sysctl.c | 16 ++++++++-------- + units/systemd-sysctl.service.in | 1 - + 3 files changed, 17 insertions(+), 9 deletions(-) + +diff --git a/NEWS b/NEWS +index f9929d0..9d989d3 100644 +--- a/NEWS ++++ b/NEWS +@@ -2,6 +2,15 @@ systemd System and Service Manager + + CHANGES WITH 206: + ++ * The systemd-sysctl tool does no longer natively read the ++ file /etc/sysctl.conf. If desired, the file should be ++ symlinked from /etc/sysctl.d/99-sysctl.conf. Apart from ++ providing legacy support by a symlink rather than built-in ++ code, it also makes the otherwise hidden order of application ++ of the different files visible. ++ ++CHANGES WITH 206: ++ + * The documentation has been updated to cover the various new + concepts introduced with 205. + +diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c +index db18dd9..b5670db 100644 +--- a/src/sysctl/sysctl.c ++++ b/src/sysctl/sysctl.c +@@ -135,6 +135,7 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno + log_debug("parse: %s\n", path); + while (!feof(f)) { + char l[LINE_MAX], *p, *value, *new_value, *property, *existing; ++ void *v; + int k; + + if (!fgets(l, sizeof(l), f)) { +@@ -167,13 +168,14 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno + p = normalize_sysctl(strstrip(p)); + value = strstrip(value); + +- existing = hashmap_get(sysctl_options, p); ++ existing = hashmap_get2(sysctl_options, p, &v); + if (existing) { +- if (!streq(value, existing)) +- log_warning("Duplicate assignment of %s in file '%s', ignoring.", +- p, path); ++ if (streq(value, existing)) ++ continue; + +- continue; ++ log_info("Overwriting earlier assignment of %s in file '%s'.", p, path); ++ free(hashmap_remove(sysctl_options, p)); ++ free(v); + } + + property = strdup(p); +@@ -188,7 +190,7 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno + + k = hashmap_put(sysctl_options, property, new_value); + if (k < 0) { +- log_error("Failed to add sysctl variable %s to hashmap: %s", property, strerror(-r)); ++ log_error("Failed to add sysctl variable %s to hashmap: %s", property, strerror(-k)); + free(property); + free(new_value); + return k; +@@ -304,8 +306,6 @@ int main(int argc, char *argv[]) { + goto finish; + } + +- r = parse_file(sysctl_options, "/etc/sysctl.conf", true); +- + STRV_FOREACH(f, files) { + k = parse_file(sysctl_options, *f, true); + if (k < 0 && r == 0) +diff --git a/units/systemd-sysctl.service.in b/units/systemd-sysctl.service.in +index 45e1ceb..5baf22c 100644 +--- a/units/systemd-sysctl.service.in ++++ b/units/systemd-sysctl.service.in +@@ -13,7 +13,6 @@ Conflicts=shutdown.target + After=systemd-readahead-collect.service systemd-readahead-replay.service + Before=sysinit.target shutdown.target + ConditionPathIsReadWrite=/proc/sys/ +-ConditionPathExists=|/etc/sysctl.conf + ConditionDirectoryNotEmpty=|/lib/sysctl.d + ConditionDirectoryNotEmpty=|/usr/lib/sysctl.d + ConditionDirectoryNotEmpty=|/usr/local/lib/sysctl.d diff --git a/0032-systemd-python-fix-initialization-of-_Reader-objects.patch b/0032-systemd-python-fix-initialization-of-_Reader-objects.patch new file mode 100644 index 0000000..546ca04 --- /dev/null +++ b/0032-systemd-python-fix-initialization-of-_Reader-objects.patch @@ -0,0 +1,37 @@ +From 7efa944f689234f12798d737f9597f93621193da Mon Sep 17 00:00:00 2001 +From: Steven Hiscocks +Date: Thu, 15 Aug 2013 12:50:32 -0400 +Subject: [PATCH] systemd-python: fix initialization of _Reader objects + +https://bugzilla.redhat.com/show_bug.cgi?id=995575 +--- + src/python-systemd/_reader.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c +index 6ac2f20..be8ada2 100644 +--- a/src/python-systemd/_reader.c ++++ b/src/python-systemd/_reader.c +@@ -64,6 +64,10 @@ static PyStructSequence_Desc Monotonic_desc = { + }; + #endif + ++/** ++ * Convert a Python sequence object into a strv (char**), and ++ * None into a NULL pointer. ++ */ + static int strv_converter(PyObject* obj, void *_result) { + char ***result = _result; + Py_ssize_t i, len; +@@ -73,6 +77,11 @@ static int strv_converter(PyObject* obj, void *_result) { + if (!obj) + goto cleanup; + ++ if (obj == Py_None) { ++ *result = NULL; ++ return 1; ++ } ++ + if (!PySequence_Check(obj)) + return 0; + diff --git a/0033-udevd-simplify-sigterm-check.patch b/0033-udevd-simplify-sigterm-check.patch new file mode 100644 index 0000000..c3fbcdf --- /dev/null +++ b/0033-udevd-simplify-sigterm-check.patch @@ -0,0 +1,30 @@ +From 65a43fc88f420d5be42f6c443ce920c1852f6998 Mon Sep 17 00:00:00 2001 +From: Kay Sievers +Date: Thu, 15 Aug 2013 19:51:08 +0200 +Subject: [PATCH] udevd: simplify sigterm check + +--- + src/udev/udevd.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/src/udev/udevd.c b/src/udev/udevd.c +index 7c6c5d6..fd799cc 100644 +--- a/src/udev/udevd.c ++++ b/src/udev/udevd.c +@@ -314,13 +314,11 @@ static void worker_new(struct event *event) + udev_device_unref(dev); + dev = NULL; + +- if (udev_event->sigterm) { +- udev_event_unref(udev_event); +- goto out; +- } +- + udev_event_unref(udev_event); + ++ if (udev_event->sigterm) ++ goto out; ++ + /* wait for more device messages from main udevd, or term signal */ + while (dev == NULL) { + struct epoll_event ev[4]; diff --git a/0034-libudev-fix-hwdb-validation-to-look-for-the-new-file.patch b/0034-libudev-fix-hwdb-validation-to-look-for-the-new-file.patch new file mode 100644 index 0000000..259d6df --- /dev/null +++ b/0034-libudev-fix-hwdb-validation-to-look-for-the-new-file.patch @@ -0,0 +1,22 @@ +From e122454310eeee15bad6974f5315ff0cb3be5ab6 Mon Sep 17 00:00:00 2001 +From: Kay Sievers +Date: Thu, 15 Aug 2013 19:54:03 +0200 +Subject: [PATCH] libudev: fix hwdb validation to look for the *new* file + +--- + 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 5645a11..de1cb83 100644 +--- a/src/libudev/libudev-hwdb.c ++++ b/src/libudev/libudev-hwdb.c +@@ -358,7 +358,7 @@ bool udev_hwdb_validate(struct udev_hwdb *hwdb) { + return false; + if (!hwdb->f) + return false; +- if (fstat(fileno(hwdb->f), &st) < 0) ++ if (stat("/etc/udev/hwdb.bin", &st) < 0) + return true; + if (timespec_load(&hwdb->st.st_mtim) != timespec_load(&st.st_mtim)) + return true; diff --git a/0035-units-make-fsck-units-remain-after-exit.patch b/0035-units-make-fsck-units-remain-after-exit.patch new file mode 100644 index 0000000..b44d98d --- /dev/null +++ b/0035-units-make-fsck-units-remain-after-exit.patch @@ -0,0 +1,50 @@ +From ac2279a50aee4c8c5fabb645d185ad6c9e61d553 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Thu, 15 Aug 2013 15:07:57 -0400 +Subject: [PATCH] units: make fsck units remain after exit + +Without this, fsck would be re-run if any other service which pulls +in a target requiring one of the mounts was started after fsck was done +but before the initial transaction was done. + +https://bugs.freedesktop.org/show_bug.cgi?id=66784 +--- + units/systemd-fsck-root.service.in | 4 ++-- + units/systemd-fsck@.service.in | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/units/systemd-fsck-root.service.in b/units/systemd-fsck-root.service.in +index 563129b..4388314 100644 +--- a/units/systemd-fsck-root.service.in ++++ b/units/systemd-fsck-root.service.in +@@ -7,7 +7,7 @@ + + [Unit] + Description=File System Check on Root Device +-Documentation=man:systemd-fsck@.service(8) ++Documentation=man:systemd-fsck-root.service(8) + DefaultDependencies=no + After=systemd-readahead-collect.service systemd-readahead-replay.service + Before=local-fs.target shutdown.target +@@ -16,7 +16,7 @@ ConditionPathIsReadWrite=!/ + + [Service] + Type=oneshot +-RemainAfterExit=no ++RemainAfterExit=yes + ExecStart=@rootlibexecdir@/systemd-fsck + StandardOutput=journal+console + FsckPassNo=1 +diff --git a/units/systemd-fsck@.service.in b/units/systemd-fsck@.service.in +index b3c71eb..e229cdc 100644 +--- a/units/systemd-fsck@.service.in ++++ b/units/systemd-fsck@.service.in +@@ -15,7 +15,7 @@ Before=shutdown.target + + [Service] + Type=oneshot +-RemainAfterExit=no ++RemainAfterExit=yes + ExecStart=@rootlibexecdir@/systemd-fsck %f + StandardOutput=journal+console + TimeoutSec=0 diff --git a/0036-udev-replace-CAP_MKNOD-by-writable-sys-condition.patch b/0036-udev-replace-CAP_MKNOD-by-writable-sys-condition.patch new file mode 100644 index 0000000..08a2739 --- /dev/null +++ b/0036-udev-replace-CAP_MKNOD-by-writable-sys-condition.patch @@ -0,0 +1,64 @@ +From bb8f5a48fef4adbe1a8bd57eb8a8d1d346447781 Mon Sep 17 00:00:00 2001 +From: Kay Sievers +Date: Sat, 17 Aug 2013 19:07:42 +0200 +Subject: [PATCH] udev: replace CAP_MKNOD by writable /sys condition + +--- + units/systemd-udev-settle.service.in | 2 +- + units/systemd-udev-trigger.service.in | 2 +- + units/systemd-udevd-control.socket | 2 +- + units/systemd-udevd-kernel.socket | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/units/systemd-udev-settle.service.in b/units/systemd-udev-settle.service.in +index 037dd9a..0817803 100644 +--- a/units/systemd-udev-settle.service.in ++++ b/units/systemd-udev-settle.service.in +@@ -16,7 +16,7 @@ DefaultDependencies=no + Wants=systemd-udevd.service + After=systemd-udev-trigger.service + Before=sysinit.target +-ConditionCapability=CAP_MKNOD ++ConditionPathIsReadWrite=/sys + + [Service] + Type=oneshot +diff --git a/units/systemd-udev-trigger.service.in b/units/systemd-udev-trigger.service.in +index 604c369..0c33909 100644 +--- a/units/systemd-udev-trigger.service.in ++++ b/units/systemd-udev-trigger.service.in +@@ -12,7 +12,7 @@ DefaultDependencies=no + Wants=systemd-udevd.service + After=systemd-udevd-kernel.socket systemd-udevd-control.socket + Before=sysinit.target +-ConditionCapability=CAP_MKNOD ++ConditionPathIsReadWrite=/sys + + [Service] + Type=oneshot +diff --git a/units/systemd-udevd-control.socket b/units/systemd-udevd-control.socket +index ca17102..8330a1c 100644 +--- a/units/systemd-udevd-control.socket ++++ b/units/systemd-udevd-control.socket +@@ -10,7 +10,7 @@ Description=udev Control Socket + Documentation=man:systemd-udevd.service(8) man:udev(7) + DefaultDependencies=no + Before=sockets.target +-ConditionCapability=CAP_MKNOD ++ConditionPathIsReadWrite=/sys + + [Socket] + Service=systemd-udevd.service +diff --git a/units/systemd-udevd-kernel.socket b/units/systemd-udevd-kernel.socket +index 4b8a5b0..39b7809 100644 +--- a/units/systemd-udevd-kernel.socket ++++ b/units/systemd-udevd-kernel.socket +@@ -10,7 +10,7 @@ Description=udev Kernel Socket + Documentation=man:systemd-udevd.service(8) man:udev(7) + DefaultDependencies=no + Before=sockets.target +-ConditionCapability=CAP_MKNOD ++ConditionPathIsReadWrite=/sys + + [Socket] + Service=systemd-udevd.service diff --git a/0037-libudev-enumerate.c-udev_enumerate_get_list_entry-fi.patch b/0037-libudev-enumerate.c-udev_enumerate_get_list_entry-fi.patch new file mode 100644 index 0000000..8f35f67 --- /dev/null +++ b/0037-libudev-enumerate.c-udev_enumerate_get_list_entry-fi.patch @@ -0,0 +1,63 @@ +From 9656356ef09c12a3c0d73bf84b7c6704d37bea47 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Mon, 19 Aug 2013 15:18:43 +0200 +Subject: [PATCH] libudev-enumerate.c:udev_enumerate_get_list_entry() fixed + possible stale pointer + +If a realloc() happens in syspath_add(), the move_later pointer could +point to an invalid memory region. + +Let move_later store the array index, instead of the pointer to the +entry. +--- + src/libudev/libudev-enumerate.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c +index 5ccaabd..3e79107 100644 +--- a/src/libudev/libudev-enumerate.c ++++ b/src/libudev/libudev-enumerate.c +@@ -270,8 +270,9 @@ _public_ struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enume + return NULL; + if (!udev_enumerate->devices_uptodate) { + unsigned int i; ++ int move_later = -1; + unsigned int max; +- struct syspath *prev = NULL, *move_later = NULL; ++ struct syspath *prev = NULL; + size_t move_later_prefix = 0; + + udev_list_cleanup(&udev_enumerate->devices_list); +@@ -303,23 +304,25 @@ _public_ struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enume + move_later_prefix = devices_delay_later(udev_enumerate->udev, entry->syspath); + + if (move_later_prefix > 0) { +- move_later = entry; ++ move_later = i; + continue; + } + } + +- if (move_later && +- !strneq(entry->syspath, move_later->syspath, move_later_prefix)) { ++ if ((move_later >= 0) && ++ !strneq(entry->syspath, udev_enumerate->devices[move_later].syspath, move_later_prefix)) { + +- udev_list_entry_add(&udev_enumerate->devices_list, move_later->syspath, NULL); +- move_later = NULL; ++ udev_list_entry_add(&udev_enumerate->devices_list, ++ udev_enumerate->devices[move_later].syspath, NULL); ++ move_later = -1; + } + + udev_list_entry_add(&udev_enumerate->devices_list, entry->syspath, NULL); + } + +- if (move_later) +- udev_list_entry_add(&udev_enumerate->devices_list, move_later->syspath, NULL); ++ if (move_later >= 0) ++ udev_list_entry_add(&udev_enumerate->devices_list, ++ udev_enumerate->devices[move_later].syspath, NULL); + + /* add and cleanup delayed devices from end of list */ + for (i = max; i < udev_enumerate->devices_cur; i++) { diff --git a/0038-journal-fix-parsing-of-facility-in-syslog-messages.patch b/0038-journal-fix-parsing-of-facility-in-syslog-messages.patch new file mode 100644 index 0000000..2669222 --- /dev/null +++ b/0038-journal-fix-parsing-of-facility-in-syslog-messages.patch @@ -0,0 +1,86 @@ +From 376cb2b4d456d50167756ec49176bf6cffd052a7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Fri, 26 Jul 2013 12:57:33 -0400 +Subject: [PATCH] journal: fix parsing of facility in syslog messages + +In 49998b383 (journald: do not overwrite syslog facility when +parsing priority) journald started ignoring facility part when +reading service stderr to convert to syslog messages. In this +case it is fine, because only the priority is allowed. + +But the same codepath is used for syslog messages, where the +facility should be used. Split the two codepaths by explicitly +specyfing whether the facility should be ignored or not. + +https://bugzilla.redhat.com/show_bug.cgi?id=988814 +--- + src/journal/journald-stream.c | 2 +- + src/journal/journald-syslog.c | 12 ++++++++---- + src/journal/journald-syslog.h | 2 +- + 3 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c +index e98fe94..9c4efec 100644 +--- a/src/journal/journald-stream.c ++++ b/src/journal/journald-stream.c +@@ -90,7 +90,7 @@ static int stdout_stream_log(StdoutStream *s, const char *p) { + priority = s->priority; + + if (s->level_prefix) +- syslog_parse_priority((char**) &p, &priority); ++ syslog_parse_priority((char**) &p, &priority, false); + + if (s->forward_to_syslog || s->server->forward_to_syslog) + server_forward_syslog(s->server, syslog_fixup_facility(priority), s->identifier, p, &s->ucred, NULL); +diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c +index 7cbb346..c2770a5 100644 +--- a/src/journal/journald-syslog.c ++++ b/src/journal/journald-syslog.c +@@ -236,7 +236,7 @@ size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid) + return e; + } + +-void syslog_parse_priority(char **p, int *priority) { ++void syslog_parse_priority(char **p, int *priority, bool with_facility) { + int a = 0, b = 0, c = 0; + int k; + +@@ -265,10 +265,14 @@ void syslog_parse_priority(char **p, int *priority) { + } else + return; + +- if (a < 0 || b < 0 || c < 0) ++ if (a < 0 || b < 0 || c < 0 || ++ (!with_facility && (a || b || c > 7))) + return; + +- *priority = (*priority & LOG_FACMASK) | (a*100 + b*10 + c); ++ if (with_facility) ++ *priority = a*100 + b*10 + c; ++ else ++ *priority = (*priority & LOG_FACMASK) | c; + *p += k; + } + +@@ -361,7 +365,7 @@ void server_process_syslog_message( + assert(buf); + + orig = buf; +- syslog_parse_priority((char**) &buf, &priority); ++ syslog_parse_priority((char**) &buf, &priority, true); + + if (s->forward_to_syslog) + forward_syslog_raw(s, priority, orig, ucred, tv); +diff --git a/src/journal/journald-syslog.h b/src/journal/journald-syslog.h +index 324b70e..8ccdb77 100644 +--- a/src/journal/journald-syslog.h ++++ b/src/journal/journald-syslog.h +@@ -25,7 +25,7 @@ + + int syslog_fixup_facility(int priority) _const_; + +-void syslog_parse_priority(char **p, int *priority); ++void syslog_parse_priority(char **p, int *priority, bool with_facility); + size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid); + + void server_forward_syslog(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred, struct timeval *tv); diff --git a/0039-cgroup.c-check-return-value-of-unit_realize_cgroup_n.patch b/0039-cgroup.c-check-return-value-of-unit_realize_cgroup_n.patch new file mode 100644 index 0000000..b5d4e5b --- /dev/null +++ b/0039-cgroup.c-check-return-value-of-unit_realize_cgroup_n.patch @@ -0,0 +1,30 @@ +From 092ce0fbd755a56fe2fd25a28519fe974ebf1d2f Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Fri, 23 Aug 2013 18:46:06 +0200 +Subject: [PATCH] cgroup.c: check return value of unit_realize_cgroup_now() + +do not recurse further, if unit_realize_cgroup_now() failed +--- + src/core/cgroup.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 5a1c3ad..50b17f3 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -432,8 +432,13 @@ static int unit_realize_cgroup_now(Unit *u) { + return 0; + + /* First, realize parents */ +- if (UNIT_ISSET(u->slice)) +- unit_realize_cgroup_now(UNIT_DEREF(u->slice)); ++ if (UNIT_ISSET(u->slice)) { ++ int r; ++ ++ r = unit_realize_cgroup_now(UNIT_DEREF(u->slice)); ++ if (r < 0) ++ return r; ++ } + + /* And then do the real work */ + return unit_create_cgroups(u, mask); diff --git a/0040-Revert-cgroup.c-check-return-value-of-unit_realize_c.patch b/0040-Revert-cgroup.c-check-return-value-of-unit_realize_c.patch new file mode 100644 index 0000000..1aa2244 --- /dev/null +++ b/0040-Revert-cgroup.c-check-return-value-of-unit_realize_c.patch @@ -0,0 +1,31 @@ +From c3cfb3213c9ac33679e4b9f01379e6520b769155 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 28 Aug 2013 15:42:34 +0200 +Subject: [PATCH] Revert "cgroup.c: check return value of + unit_realize_cgroup_now()" + +This reverts commit 092ce0fbd755a56fe2fd25a28519fe974ebf1d2f. +--- + src/core/cgroup.c | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 50b17f3..5a1c3ad 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -432,13 +432,8 @@ static int unit_realize_cgroup_now(Unit *u) { + return 0; + + /* First, realize parents */ +- if (UNIT_ISSET(u->slice)) { +- int r; +- +- r = unit_realize_cgroup_now(UNIT_DEREF(u->slice)); +- if (r < 0) +- return r; +- } ++ if (UNIT_ISSET(u->slice)) ++ unit_realize_cgroup_now(UNIT_DEREF(u->slice)); + + /* And then do the real work */ + return unit_create_cgroups(u, mask); diff --git a/0041-Do-not-realloc-strings-which-are-already-in-the-hash.patch b/0041-Do-not-realloc-strings-which-are-already-in-the-hash.patch new file mode 100644 index 0000000..6666a34 --- /dev/null +++ b/0041-Do-not-realloc-strings-which-are-already-in-the-hash.patch @@ -0,0 +1,71 @@ +From 882c606d2a0d8effbd218059ea7f050c351e4019 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 28 Aug 2013 15:33:35 +0200 +Subject: [PATCH] Do not realloc strings, which are already in the hashmap as + keys + +This prevents corruption of the hashmap, because we would free() the +keys in the hashmap, if the unit is already in there, with the same +cgroup path. +--- + src/core/cgroup.c | 18 ++++++++++++++---- + src/core/unit.c | 2 +- + 2 files changed, 15 insertions(+), 5 deletions(-) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 5a1c3ad..3eeb475 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -382,6 +382,7 @@ static CGroupControllerMask unit_get_siblings_mask(Unit *u) { + static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) { + char *path = NULL; + int r; ++ bool is_in_hash = false; + + assert(u); + +@@ -390,8 +391,14 @@ static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) { + return -ENOMEM; + + r = hashmap_put(u->manager->cgroup_unit, path, u); +- if (r < 0) ++ if (r == 0) ++ is_in_hash = true; ++ ++ if (r < 0) { ++ free(path); ++ log_error("cgroup %s exists already: %s", path, strerror(-r)); + return r; ++ } + + /* First, create our own group */ + r = cg_create_with_mask(mask, path); +@@ -405,9 +412,12 @@ static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) { + log_error("Failed to migrate cgroup %s: %s", path, strerror(-r)); + } + +- /* And remember the new data */ +- free(u->cgroup_path); +- u->cgroup_path = path; ++ if (!is_in_hash) { ++ /* And remember the new data */ ++ free(u->cgroup_path); ++ u->cgroup_path = path; ++ } ++ + u->cgroup_realized = true; + u->cgroup_mask = mask; + +diff --git a/src/core/unit.c b/src/core/unit.c +index 0e9329f..ac488cf 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -2337,7 +2337,7 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) { + free(u->cgroup_path); + u->cgroup_path = s; + +- hashmap_put(u->manager->cgroup_unit, s, u); ++ assert(hashmap_put(u->manager->cgroup_unit, s, u) == 1); + continue; + } + diff --git a/systemd-python-fix-initialization-of-_Reader-objects.patch b/systemd-python-fix-initialization-of-_Reader-objects.patch deleted file mode 100644 index a12d6ef..0000000 --- a/systemd-python-fix-initialization-of-_Reader-objects.patch +++ /dev/null @@ -1,40 +0,0 @@ -From c2748ce28c7111037f312c5446335f5538e673e8 Mon Sep 17 00:00:00 2001 -From: Steven Hiscocks -Date: Thu, 15 Aug 2013 12:50:32 -0400 -Subject: [PATCH] systemd-python: fix initialization of _Reader objects - -https://bugzilla.redhat.com/show_bug.cgi?id=995575 ---- - src/python-systemd/_reader.c | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c -index a678f69..3b1003b 100644 ---- a/src/python-systemd/_reader.c -+++ b/src/python-systemd/_reader.c -@@ -64,6 +64,10 @@ static PyStructSequence_Desc Monotonic_desc = { - }; - #endif - -+/** -+ * Convert a Python sequence object into a strv (char**), and -+ * None into a NULL pointer. -+ */ - static int strv_converter(PyObject* obj, void *_result) { - char ***result = _result; - Py_ssize_t i, len; -@@ -73,6 +77,11 @@ static int strv_converter(PyObject* obj, void *_result) { - if (!obj) - goto cleanup; - -+ if (obj == Py_None) { -+ *result = NULL; -+ return 1; -+ } -+ - if (!PySequence_Check(obj)) - return 0; - --- -1.8.2.562.g931e949 - diff --git a/systemd.spec b/systemd.spec index 32dc3e2..31a3e56 100644 --- a/systemd.spec +++ b/systemd.spec @@ -16,7 +16,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 206 -Release: 9%{?gitcommit:.git%{gitcommit}}%{?dist} +Release: 10%{?gitcommit:.git%{gitcommit}}%{?dist} # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: A System and Service Manager @@ -36,9 +36,49 @@ Source4: listen.conf # Prevent accidental removal of the systemd package Source6: yum-protect-systemd.conf +Patch0001: 0001-80-net-name-slot.rules-only-rename-network-interface.patch +Patch0004: 0004-journal-handle-multiline-syslog-messages.patch +Patch0005: 0005-man-Fix-copy-paste-error.patch +Patch0006: 0006-core-synchronously-block-when-logging.patch +Patch0007: 0007-journal-immediately-sync-to-disk-as-soon-as-we-recei.patch +Patch0008: 0008-initctl-use-irreversible-jobs-when-switching-runleve.patch +Patch0009: 0009-udev-log-error-if-chmod-chown-of-static-dev-nodes-fa.patch +Patch0010: 0010-udev-static_node-don-t-touch-permissions-uneccessari.patch +Patch0011: 0011-tmpfiles-support-passing-prefix-multiple-times.patch +Patch0012: 0012-tmpfiles-introduce-exclude-prefix.patch +Patch0013: 0013-tmpfiles-setup-exclude-dev-prefixes-files.patch +Patch0014: 0014-logind-update-state-file-after-generating-the-sessio.patch +Patch0015: 0015-journalctl-use-_COMM-match-for-scripts.patch +Patch0016: 0016-man-systemd.unit-fix-volatile-path.patch +Patch0017: 0017-man-link-up-scope-slice-units-from-systemd.unit-5.patch +Patch0018: 0018-man-there-is-no-session-mode-only-user-mode.patch +Patch0019: 0019-journal-fix-hashmap-leak-in-mmap-cache.patch +Patch0020: 0020-systemd-delta-Only-print-colors-when-on-a-tty.patch +Patch0021: 0021-systemd-fix-segv-in-snapshot-creation.patch +Patch0022: 0022-udev-hwdb-try-reading-modalias-for-usb-before-fallin.patch +Patch0023: 0023-udevd-respect-the-log-level-set-in-etc-udev-udev.con.patch +Patch0024: 0024-fstab-generator-respect-noauto-nofail-when-adding-sy.patch +Patch0025: 0025-service-always-unwatch-PIDs-before-forgetting-old-on.patch +Patch0026: 0026-units-disable-kmod-static-nodes.service-in-container.patch +Patch0027: 0027-use-CAP_MKNOD-ConditionCapability.patch +Patch0028: 0028-fstab-generator-read-rd.fstab-on-off-switch-correctl.patch +Patch0029: 0029-backlight-add-minimal-tool-to-save-restore-screen-br.patch +Patch0030: 0030-backlight-instead-of-syspath-use-sysname-for-identif.patch +Patch0031: 0031-sysctl-allow-overwriting-of-values-specified-in-late.patch +Patch0032: 0032-systemd-python-fix-initialization-of-_Reader-objects.patch +Patch0033: 0033-udevd-simplify-sigterm-check.patch +Patch0034: 0034-libudev-fix-hwdb-validation-to-look-for-the-new-file.patch +Patch0035: 0035-units-make-fsck-units-remain-after-exit.patch +Patch0036: 0036-udev-replace-CAP_MKNOD-by-writable-sys-condition.patch +Patch0037: 0037-libudev-enumerate.c-udev_enumerate_get_list_entry-fi.patch +Patch0038: 0038-journal-fix-parsing-of-facility-in-syslog-messages.patch +Patch0039: 0039-cgroup.c-check-return-value-of-unit_realize_cgroup_n.patch +Patch0040: 0040-Revert-cgroup.c-check-return-value-of-unit_realize_c.patch +Patch0041: 0041-Do-not-realloc-strings-which-are-already-in-the-hash.patch + + # kernel-install patch for grubby, drop if grubby is obsolete Patch1000: kernel-install-grubby.patch -Patch1001: systemd-python-fix-initialization-of-_Reader-objects.patch Patch1002: systemd-python-check-for-oom-give-nicer-error-messag.patch %global num_patches %{lua: c=0; for i,p in ipairs(patches) do c=c+1; end; print(c);} @@ -85,7 +125,6 @@ Requires(pre): /usr/sbin/groupadd Requires: dbus Requires: %{name}-libs = %{version}-%{release} Requires: kmod >= 14 -Requires: grubby Provides: /bin/systemctl Provides: /sbin/shutdown Provides: syslog @@ -197,7 +236,39 @@ systemd-journal-gatewayd serves journal events over the network using HTTP. git commit -a -q -m "%{version} baseline." # Apply all the patches. - git am %{patches} + git am \ + --exclude .gitignore \ + --exclude docs/.gitignore \ + --exclude docs/gudev/.gitignore \ + --exclude docs/libudev/.gitignore \ + --exclude docs/sysvinit/.gitignore \ + --exclude docs/var-log/.gitignore \ + --exclude hwdb/.gitignore \ + --exclude m4/.gitignore \ + --exclude man/.gitignore \ + --exclude po/.gitignore \ + --exclude rules/.gitignore \ + --exclude src/.gitignore \ + --exclude src/analyze/.gitignore \ + --exclude src/core/.gitignore \ + --exclude src/gudev/.gitignore \ + --exclude src/hostname/.gitignore \ + --exclude src/journal/.gitignore \ + --exclude src/libsystemd-daemon/.gitignore \ + --exclude src/libsystemd-id128/.gitignore \ + --exclude src/libudev/.gitignore \ + --exclude src/locale/.gitignore \ + --exclude src/login/.gitignore \ + --exclude src/python-systemd/.gitignore \ + --exclude src/python-systemd/docs/.gitignore \ + --exclude src/timedate/.gitignore \ + --exclude src/udev/.gitignore \ + --exclude src/udev/scsi_id/.gitignore \ + --exclude sysctl.d/.gitignore \ + --exclude test/.gitignore \ + --exclude units/.gitignore \ + --exclude units/user/.gitignore \ + %{patches} %endif %build @@ -626,6 +697,10 @@ getent passwd systemd-journal-gateway >/dev/null 2>&1 || useradd -r -l -u 191 -g %{_datadir}/systemd/gatewayd %changelog +* Wed Sep 04 2013 Harald Hoyer 206-10 +- Do not require grubby, lorax now takes care of grubby +- cherry-picked a lot of patches from upstream + * Tue Aug 27 2013 Dennis Gilmore - 206-9 - Require grubby, Fedora installs require grubby, - kernel-install took over from new-kernel-pkg