Submitted By:            Armin K. <krejzi at email dot com>
Date:                    2014-11-28
Initial Package Version: 217
Upstream Status:         Fixed
Origin:                  Upstream
Description:             Various post release fixes from the v217-stable repository.

--- a/hwdb/20-bluetooth-vendor-product.hwdb	2014-10-07 15:59:01.416605635 +0200
+++ b/hwdb/20-bluetooth-vendor-product.hwdb	2014-11-28 14:56:53.857865437 +0100
@@ -1166,3 +1166,60 @@
 
 bluetooth:v0182*
  ID_VENDOR_FROM_DATABASE=HOP Ubiquitous
+
+bluetooth:v0183*
+ ID_VENDOR_FROM_DATABASE=To Be Assigned
+
+bluetooth:v0184*
+ ID_VENDOR_FROM_DATABASE=Nectar
+
+bluetooth:v0185*
+ ID_VENDOR_FROM_DATABASE=bel'apps LLC
+
+bluetooth:v0186*
+ ID_VENDOR_FROM_DATABASE=CORE Lighting Ltd
+
+bluetooth:v0187*
+ ID_VENDOR_FROM_DATABASE=Seraphim Sense Ltd
+
+bluetooth:v0188*
+ ID_VENDOR_FROM_DATABASE=Unico RBC
+
+bluetooth:v0189*
+ ID_VENDOR_FROM_DATABASE=Physical Enterprises Inc.
+
+bluetooth:v018A*
+ ID_VENDOR_FROM_DATABASE=Able Trend Technology Limited
+
+bluetooth:v018B*
+ ID_VENDOR_FROM_DATABASE=Konica Minolta, Inc.
+
+bluetooth:v018C*
+ ID_VENDOR_FROM_DATABASE=Wilo SE
+
+bluetooth:v018D*
+ ID_VENDOR_FROM_DATABASE=Extron Design Services
+
+bluetooth:v018E*
+ ID_VENDOR_FROM_DATABASE=Fitbit, Inc.
+
+bluetooth:v018F*
+ ID_VENDOR_FROM_DATABASE=Fireflies Systems
+
+bluetooth:v0190*
+ ID_VENDOR_FROM_DATABASE=Intelletto Technologies Inc.
+
+bluetooth:v0191*
+ ID_VENDOR_FROM_DATABASE=FDK CORPORATION
+
+bluetooth:v0192*
+ ID_VENDOR_FROM_DATABASE=Cloudleaf, Inc
+
+bluetooth:v0193*
+ ID_VENDOR_FROM_DATABASE=Maveric Automation LLC
+
+bluetooth:v0194*
+ ID_VENDOR_FROM_DATABASE=Acoustic Stream Corporation
+
+bluetooth:v0195*
+ ID_VENDOR_FROM_DATABASE=Zuli
--- a/hwdb/60-keyboard.hwdb	2014-10-22 17:11:04.000077227 +0200
+++ b/hwdb/60-keyboard.hwdb	2014-11-28 14:56:53.851865373 +0100
@@ -230,6 +230,11 @@
 keyboard:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1210:pvr*
  KEYBOARD_KEY_84=wlan
 
+# Dell Inspiron 1520
+keyboard:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1520:pvr*
+ KEYBOARD_KEY_85=unknown  # Brightness Down, also emitted by acpi-video, ignore
+ KEYBOARD_KEY_86=unknown  # Brightness Up, also emitted by acpi-video, ignore
+
 # Latitude XT2
 keyboard:dmi:bvn*:bvr*:bd*:svnDell*:pnLatitude*XT2:pvr*
  KEYBOARD_KEY_9b=up                                     # tablet rocker up
--- a/src/core/machine-id-setup.c	2014-08-21 17:24:21.130557087 +0200
+++ b/src/core/machine-id-setup.c	2014-11-28 14:56:53.861865480 +0100
@@ -162,7 +162,7 @@
 int machine_id_setup(const char *root) {
         const char *etc_machine_id, *run_machine_id;
         _cleanup_close_ int fd = -1;
-        bool writable = false;
+        bool writable = true;
         struct stat st;
         char id[34]; /* 32 + \n + \0 */
         int r;
@@ -186,12 +186,19 @@
 
                 mkdir_parents(etc_machine_id, 0755);
                 fd = open(etc_machine_id, O_RDWR|O_CREAT|O_CLOEXEC|O_NOCTTY, 0444);
-                if (fd >= 0)
-                        writable = true;
-                else {
+                if (fd < 0) {
+                        int old_errno = errno;
+
                         fd = open(etc_machine_id, O_RDONLY|O_CLOEXEC|O_NOCTTY);
                         if (fd < 0) {
-                                log_error("Cannot open %s: %m", etc_machine_id);
+                                if (old_errno == EROFS && errno == ENOENT)
+                                        log_error("System cannot boot: Missing /etc/machine-id and /etc is mounted read-only.\n"
+                                                  "Booting up is supported only when:\n"
+                                                  "1) /etc/machine-id exists and is populated.\n"
+                                                  "2) /etc/machine-id exists and is empty.\n"
+                                                  "3) /etc/machine-id is missing and /etc is writable.\n");
+                                else
+                                        log_error("Cannot open %s: %m", etc_machine_id);
                                 return -errno;
                         }
 
--- a/src/core/manager.c	2014-10-28 17:25:51.560723266 +0100
+++ b/src/core/manager.c	2014-11-28 14:56:53.874865620 +0100
@@ -662,9 +662,11 @@
                         return -errno;
                 }
 
-                if (m->running_as == SYSTEMD_SYSTEM)
+                if (m->running_as == SYSTEMD_SYSTEM) {
                         m->notify_socket = strdup("/run/systemd/notify");
-                else {
+                        if (!m->notify_socket)
+                                return log_oom();
+                } else {
                         const char *e;
 
                         e = getenv("XDG_RUNTIME_DIR");
@@ -674,9 +676,11 @@
                         }
 
                         m->notify_socket = strappend(e, "/systemd/notify");
+                        if (!m->notify_socket)
+                                return log_oom();
+
+                        mkdir_parents_label(m->notify_socket, 0755);
                 }
-                if (!m->notify_socket)
-                        return log_oom();
 
                 strncpy(sa.un.sun_path, m->notify_socket, sizeof(sa.un.sun_path)-1);
                 r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));
@@ -2584,45 +2588,13 @@
         return unit_inactive_or_pending(u);
 }
 
-void manager_check_finished(Manager *m) {
+static void manager_notify_finished(Manager *m) {
         char userspace[FORMAT_TIMESPAN_MAX], initrd[FORMAT_TIMESPAN_MAX], kernel[FORMAT_TIMESPAN_MAX], sum[FORMAT_TIMESPAN_MAX];
         usec_t firmware_usec, loader_usec, kernel_usec, initrd_usec, userspace_usec, total_usec;
-        Unit *u = NULL;
-        Iterator i;
-
-        assert(m);
-
-        if (m->n_running_jobs == 0)
-                m->jobs_in_progress_event_source = sd_event_source_unref(m->jobs_in_progress_event_source);
-
-        if (hashmap_size(m->jobs) > 0) {
-
-                if (m->jobs_in_progress_event_source)
-                        sd_event_source_set_time(m->jobs_in_progress_event_source, now(CLOCK_MONOTONIC) + JOBS_IN_PROGRESS_WAIT_USEC);
-
-                return;
-        }
-
-        manager_flip_auto_status(m, false);
-
-        /* Notify Type=idle units that we are done now */
-        m->idle_pipe_event_source = sd_event_source_unref(m->idle_pipe_event_source);
-        manager_close_idle_pipe(m);
-
-        /* Turn off confirm spawn now */
-        m->confirm_spawn = false;
 
-        /* No need to update ask password status when we're going non-interactive */
-        manager_close_ask_password(m);
-
-        /* This is no longer the first boot */
-        manager_set_first_boot(m, false);
-
-        if (dual_timestamp_is_set(&m->finish_timestamp))
+        if (m->test_run)
                 return;
 
-        dual_timestamp_get(&m->finish_timestamp);
-
         if (m->running_as == SYSTEMD_SYSTEM && detect_container(NULL) <= 0) {
 
                 /* Note that m->kernel_usec.monotonic is always at 0,
@@ -2677,10 +2649,6 @@
                            NULL);
         }
 
-        SET_FOREACH(u, m->startup_units, i)
-                if (u->cgroup_path)
-                        cgroup_context_apply(unit_get_cgroup_context(u), unit_get_cgroup_mask(u), u->cgroup_path, manager_state(m));
-
         bus_manager_send_finished(m, firmware_usec, loader_usec, kernel_usec, initrd_usec, userspace_usec, total_usec);
 
         sd_notifyf(false,
@@ -2689,6 +2657,50 @@
                    format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC));
 }
 
+void manager_check_finished(Manager *m) {
+        Unit *u = NULL;
+        Iterator i;
+
+        assert(m);
+
+        if (m->n_running_jobs == 0)
+                m->jobs_in_progress_event_source = sd_event_source_unref(m->jobs_in_progress_event_source);
+
+        if (hashmap_size(m->jobs) > 0) {
+
+                if (m->jobs_in_progress_event_source)
+                        sd_event_source_set_time(m->jobs_in_progress_event_source, now(CLOCK_MONOTONIC) + JOBS_IN_PROGRESS_WAIT_USEC);
+
+                return;
+        }
+
+        manager_flip_auto_status(m, false);
+
+        /* Notify Type=idle units that we are done now */
+        m->idle_pipe_event_source = sd_event_source_unref(m->idle_pipe_event_source);
+        manager_close_idle_pipe(m);
+
+        /* Turn off confirm spawn now */
+        m->confirm_spawn = false;
+
+        /* No need to update ask password status when we're going non-interactive */
+        manager_close_ask_password(m);
+
+        /* This is no longer the first boot */
+        manager_set_first_boot(m, false);
+
+        if (dual_timestamp_is_set(&m->finish_timestamp))
+                return;
+
+        dual_timestamp_get(&m->finish_timestamp);
+
+        manager_notify_finished(m);
+
+        SET_FOREACH(u, m->startup_units, i)
+                if (u->cgroup_path)
+                        cgroup_context_apply(unit_get_cgroup_context(u), unit_get_cgroup_mask(u), u->cgroup_path, manager_state(m));
+}
+
 static int create_generator_dir(Manager *m, char **generator, const char *name) {
         char *p;
         int r;
--- a/src/core/timer.c	2014-10-07 15:59:01.449587235 +0200
+++ b/src/core/timer.c	2014-11-28 14:56:53.877865652 +0100
@@ -521,6 +521,7 @@
 
 static int timer_start(Unit *u) {
         Timer *t = TIMER(u);
+        TimerValue *v;
 
         assert(t);
         assert(t->state == TIMER_DEAD || t->state == TIMER_FAILED);
@@ -530,6 +531,11 @@
 
         t->last_trigger = DUAL_TIMESTAMP_NULL;
 
+        /* Reenable all timers that depend on unit activation time */
+        LIST_FOREACH(value, v, t->values)
+                if (v->base == TIMER_ACTIVE)
+                        v->disabled = false;
+
         if (t->stamp_path) {
                 struct stat st;
 
--- a/src/core/transaction.c	2014-10-07 15:59:01.449587235 +0200
+++ b/src/core/transaction.c	2014-11-28 14:56:53.865865523 +0100
@@ -377,9 +377,9 @@
                 for (k = from; k; k = ((k->generation == generation && k->marker != k) ? k->marker : NULL)) {
 
                         /* logging for j not k here here to provide consistent narrative */
-                        log_info_unit(j->unit->id,
-                                      "Found dependency on %s/%s",
-                                      k->unit->id, job_type_to_string(k->type));
+                        log_warning_unit(j->unit->id,
+                                         "Found dependency on %s/%s",
+                                         k->unit->id, job_type_to_string(k->type));
 
                         if (!delete && hashmap_get(tr->jobs, k->unit) &&
                             !unit_matters_to_anchor(k->unit, k)) {
--- a/src/journal/journald-server.c	2014-10-27 12:48:29.292966277 +0100
+++ b/src/journal/journald-server.c	2014-11-28 14:56:53.869865566 +0100
@@ -1655,6 +1655,7 @@
         free(s->buffer);
         free(s->tty_path);
         free(s->cgroup_root);
+        free(s->hostname_field);
 
         if (s->mmap)
                 mmap_cache_unref(s->mmap);
--- a/src/journal/journal-vacuum.c	2014-07-29 19:51:00.720285727 +0200
+++ b/src/journal/journal-vacuum.c	2014-11-28 14:56:53.869865566 +0100
@@ -275,7 +275,11 @@
 
                 patch_realtime(directory, p, &st, &realtime);
 
-                GREEDY_REALLOC(list, n_allocated, n_list + 1);
+                if (!GREEDY_REALLOC(list, n_allocated, n_list + 1)) {
+                        free(p);
+                        r = -ENOMEM;
+                        goto finish;
+                }
 
                 list[n_list].filename = p;
                 list[n_list].usage = 512UL * (uint64_t) st.st_blocks;
--- a/src/libsystemd/sd-bus/bus-match.c	2014-10-07 15:59:01.463579428 +0200
+++ b/src/libsystemd/sd-bus/bus-match.c	2014-11-28 14:56:53.845865308 +0100
@@ -537,7 +537,7 @@
         else if (BUS_MATCH_CAN_HASH(t))
                 n = hashmap_get(c->compare.children, value_str);
         else {
-                for (n = c->child; !value_node_same(n, t, value_u8, value_str); n = n->next)
+                for (n = c->child; n && !value_node_same(n, t, value_u8, value_str); n = n->next)
                         ;
         }
 
--- a/src/libsystemd-network/sd-dhcp6-client.c	2014-10-13 17:19:31.020675595 +0200
+++ b/src/libsystemd-network/sd-dhcp6-client.c	2014-11-28 14:56:53.859865459 +0100
@@ -200,19 +200,19 @@
 
         switch (type) {
         case DHCP6_DUID_LLT:
-                if (duid_len <= sizeof(client->duid.llt))
+                if (duid_len <= sizeof(client->duid.llt) - 2)
                         return -EINVAL;
                 break;
         case DHCP6_DUID_EN:
-                if (duid_len != sizeof(client->duid.en))
+                if (duid_len != sizeof(client->duid.en) - 2)
                         return -EINVAL;
                 break;
         case DHCP6_DUID_LL:
-                if (duid_len <= sizeof(client->duid.ll))
+                if (duid_len <= sizeof(client->duid.ll) - 2)
                         return -EINVAL;
                 break;
         case DHCP6_DUID_UUID:
-                if (duid_len != sizeof(client->duid.uuid))
+                if (duid_len != sizeof(client->duid.uuid) - 2)
                         return -EINVAL;
                 break;
         default:
@@ -222,7 +222,7 @@
 
         client->duid.raw.type = htobe16(type);
         memcpy(&client->duid.raw.data, duid, duid_len);
-        client->duid_len = duid_len;
+        client->duid_len = duid_len + 2;  /* +2 for sizeof(type) */
 
         return 0;
 }
--- a/src/libsystemd-network/sd-dhcp-client.c	2014-10-13 17:19:31.019675598 +0200
+++ b/src/libsystemd-network/sd-dhcp-client.c	2014-11-28 14:56:53.852865383 +0100
@@ -1269,6 +1269,9 @@
                 if (r >= 0) {
                         client->timeout_resend =
                                 sd_event_source_unref(client->timeout_resend);
+                        client->receive_message =
+                                sd_event_source_unref(client->receive_message);
+                        client->fd = asynchronous_close(client->fd);
 
                         if (IN_SET(client->state, DHCP_STATE_REQUESTING,
                                    DHCP_STATE_REBOOTING))
--- a/src/libudev/libudev.c	2014-03-18 18:05:49.964378252 +0100
+++ b/src/libudev/libudev.c	2014-11-28 14:56:53.864865512 +0100
@@ -119,7 +119,7 @@
 {
         struct udev *udev;
         const char *env;
-        FILE *f;
+        _cleanup_fclose_ FILE *f = NULL;
 
         udev = new0(struct udev, 1);
         if (udev == NULL)
@@ -132,7 +132,7 @@
         f = fopen("/etc/udev/udev.conf", "re");
         if (f != NULL) {
                 char line[UTIL_LINE_SIZE];
-                int line_nr = 0;
+                unsigned line_nr = 0;
 
                 while (fgets(line, sizeof(line), f)) {
                         size_t len;
@@ -153,7 +153,7 @@
                         /* split key/value */
                         val = strchr(key, '=');
                         if (val == NULL) {
-                                udev_err(udev, "missing <key>=<value> in /etc/udev/udev.conf[%i]; skip line\n", line_nr);
+                                udev_err(udev, "/etc/udev/udev.conf:%u: missing assignment,  skipping line.\n", line_nr);
                                 continue;
                         }
                         val[0] = '\0';
@@ -185,7 +185,7 @@
                         /* unquote */
                         if (val[0] == '"' || val[0] == '\'') {
                                 if (val[len-1] != val[0]) {
-                                        udev_err(udev, "inconsistent quoting in /etc/udev/udev.conf[%i]; skip line\n", line_nr);
+                                        udev_err(udev, "/etc/udev/udev.conf:%u: inconsistent quoting, skipping line.\n", line_nr);
                                         continue;
                                 }
                                 val[len-1] = '\0';
@@ -193,17 +193,29 @@
                         }
 
                         if (streq(key, "udev_log")) {
-                                udev_set_log_priority(udev, util_log_priority(val));
+                                int prio;
+
+                                prio = util_log_priority(val);
+                                if (prio < 0)
+                                        udev_err(udev, "/etc/udev/udev.conf:%u: invalid logging level '%s', ignoring.\n", line_nr, val);
+                                else
+                                        udev_set_log_priority(udev, prio);
                                 continue;
                         }
                 }
-                fclose(f);
         }
 
         /* environment overrides config */
         env = secure_getenv("UDEV_LOG");
-        if (env != NULL)
-                udev_set_log_priority(udev, util_log_priority(env));
+        if (env != NULL) {
+                int prio;
+
+                prio = util_log_priority(env);
+                if (prio < 0)
+                        udev_err(udev, "$UDEV_LOG specifies invalid logging level '%s', ignoring.\n", env);
+                else
+                        udev_set_log_priority(udev, prio);
+        }
 
         return udev;
 }
--- a/src/libudev/libudev-util.c	2014-10-07 15:59:01.469576083 +0200
+++ b/src/libudev/libudev-util.c	2014-11-28 14:56:53.858865448 +0100
@@ -159,9 +159,13 @@
         char *endptr;
         int prio;
 
-        prio = strtol(priority, &endptr, 10);
-        if (endptr[0] == '\0' || isspace(endptr[0]))
-                return prio;
+        prio = strtoul(priority, &endptr, 10);
+        if (endptr[0] == '\0' || isspace(endptr[0])) {
+                if (prio >= 0 && prio <= 7)
+                        return prio;
+                else
+                        return -ERANGE;
+        }
 
         return log_level_from_string(priority);
 }
--- a/src/nspawn/nspawn.c	2014-10-27 12:48:29.295966274 +0100
+++ b/src/nspawn/nspawn.c	2014-11-28 14:56:53.856865426 +0100
@@ -758,7 +758,7 @@
                  * and char devices. */
                 if (S_ISDIR(source_st.st_mode)) {
                         r = mkdir_label(where, 0755);
-                        if (r < 0) {
+                        if (r < 0 && errno != EEXIST) {
                                 log_error("Failed to create mount point %s: %s", where, strerror(-r));
 
                                 return r;
@@ -2931,33 +2931,30 @@
         }
 
         switch (status.si_code) {
+
         case CLD_EXITED:
                 r = status.si_status;
                 if (r == 0) {
                         if (!arg_quiet)
-                                log_debug("Container %s exited successfully.",
-                                          arg_machine);
+                                log_debug("Container %s exited successfully.", arg_machine);
 
                         *container = CONTAINER_TERMINATED;
-                } else {
-                        log_error("Container %s failed with error code %i.",
-                                  arg_machine, status.si_status);
-                }
+                } else
+                        log_error("Container %s failed with error code %i.", arg_machine, status.si_status);
+
                 break;
 
         case CLD_KILLED:
                 if (status.si_status == SIGINT) {
                         if (!arg_quiet)
-                                log_info("Container %s has been shut down.",
-                                         arg_machine);
+                                log_info("Container %s has been shut down.", arg_machine);
 
                         *container = CONTAINER_TERMINATED;
                         r = 0;
                         break;
                 } else if (status.si_status == SIGHUP) {
                         if (!arg_quiet)
-                                log_info("Container %s is being rebooted.",
-                                         arg_machine);
+                                log_info("Container %s is being rebooted.", arg_machine);
 
                         *container = CONTAINER_REBOOTED;
                         r = 0;
@@ -2966,15 +2963,13 @@
                 /* CLD_KILLED fallthrough */
 
         case CLD_DUMPED:
-                log_error("Container %s terminated by signal %s.",
-                          arg_machine, signal_to_string(status.si_status));
-                r = -1;
+                log_error("Container %s terminated by signal %s.", arg_machine, signal_to_string(status.si_status));
+                r = -EIO;
                 break;
 
         default:
-                log_error("Container %s failed due to unknown reason.",
-                          arg_machine);
-                r = -1;
+                log_error("Container %s failed due to unknown reason.", arg_machine);
+                r = -EIO;
                 break;
         }
 
--- a/src/shared/copy.h	2014-07-03 17:08:58.551812677 +0200
+++ b/src/shared/copy.h	2014-11-28 14:56:53.853865394 +0100
@@ -21,6 +21,9 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include <stdbool.h>
+#include <sys/types.h>
+
 int copy_file(const char *from, const char *to, int flags, mode_t mode);
 int copy_tree(const char *from, const char *to, bool merge);
 int copy_bytes(int fdf, int fdt, off_t max_bytes);
--- a/src/shared/install.c	2014-10-27 12:48:29.296966273 +0100
+++ b/src/shared/install.c	2014-11-28 14:56:53.854865405 +0100
@@ -1620,12 +1620,10 @@
         STRV_FOREACH(i, files) {
                 UnitFileState state;
 
+                /* We only want to know if this unit is masked, so we ignore
+                 * errors from unit_file_get_state, deferring other checks.
+                 * This allows templated units to be enabled on the fly. */
                 state = unit_file_get_state(scope, root_dir, *i);
-                if (state < 0) {
-                        log_error("Failed to get unit file state for %s: %s", *i, strerror(-state));
-                        return state;
-                }
-
                 if (state == UNIT_FILE_MASKED || state == UNIT_FILE_MASKED_RUNTIME) {
                         log_error("Failed to enable unit: Unit %s is masked", *i);
                         return -ENOTSUP;
--- a/src/shared/locale-util.h	2014-10-07 15:59:01.479570507 +0200
+++ b/src/shared/locale-util.h	2014-11-28 14:56:53.853865394 +0100
@@ -21,6 +21,10 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include <stdbool.h>
+
+#include "macro.h"
+
 typedef enum LocaleVariable {
         /* We don't list LC_ALL here on purpose. People should be
          * using LANG instead. */
--- a/src/shared/logs-show.c	2014-10-22 23:22:47.769220675 +0200
+++ b/src/shared/logs-show.c	2014-11-28 14:56:53.871865587 +0100
@@ -365,7 +365,7 @@
                 fprintf(f, " %.*s", (int) comm_len, comm);
                 n += comm_len + 1;
         } else
-                fputc(' ', f);
+                fputs(" unknown", f);
 
         if (pid && shall_print(pid, pid_len, flags)) {
                 fprintf(f, "[%.*s]", (int) pid_len, pid);
--- a/src/systemctl/systemctl.c	2014-10-17 13:49:08.074598460 +0200
+++ b/src/systemctl/systemctl.c	2014-11-28 14:56:53.876865641 +0100
@@ -301,21 +301,37 @@
 }
 
 static bool output_show_unit(const UnitInfo *u, char **patterns) {
-        const char *dot;
-
         if (!strv_isempty(patterns)) {
                 char **pattern;
 
                 STRV_FOREACH(pattern, patterns)
                         if (fnmatch(*pattern, u->id, FNM_NOESCAPE) == 0)
-                                return true;
+                                goto next;
                 return false;
         }
 
-        return (!arg_types || ((dot = strrchr(u->id, '.')) &&
-                               strv_find(arg_types, dot+1))) &&
-                (arg_all || !(streq(u->active_state, "inactive")
-                              || u->following[0]) || u->job_id > 0);
+next:
+        if (arg_types) {
+                const char *dot;
+
+                dot = strrchr(u->id, '.');
+                if (!dot)
+                        return false;
+
+                if (!strv_find(arg_types, dot+1))
+                        return false;
+        }
+
+        if (arg_all)
+                return true;
+
+        if (u->job_id > 0)
+                return true;
+
+        if (streq(u->active_state, "inactive") || u->following[0])
+                return false;
+
+        return true;
 }
 
 static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
@@ -1231,18 +1247,33 @@
 }
 
 static bool output_show_unit_file(const UnitFileList *u, char **patterns) {
-        const char *dot;
-
         if (!strv_isempty(patterns)) {
                 char **pattern;
 
                 STRV_FOREACH(pattern, patterns)
                         if (fnmatch(*pattern, basename(u->path), FNM_NOESCAPE) == 0)
-                                return true;
+                                goto next;
                 return false;
         }
 
-        return !arg_types || ((dot = strrchr(u->path, '.')) && strv_find(arg_types, dot+1));
+next:
+        if (!strv_isempty(arg_types)) {
+                const char *dot;
+
+                dot = strrchr(u->path, '.');
+                if (!dot)
+                        return false;
+
+                if (!strv_find(arg_types, dot+1))
+                        return false;
+        }
+
+        if (!strv_isempty(arg_states)) {
+                if (!strv_find(arg_states, unit_file_state_to_string(u->state)))
+                        return false;
+        }
+
+        return true;
 }
 
 static void output_unit_file_list(const UnitFileList *units, unsigned c) {
@@ -6917,8 +6948,13 @@
 
 static int halt_now(enum action a) {
 
-/* Make sure C-A-D is handled by the kernel from this
-         * point on... */
+        /* The kernel will automaticall flush ATA disks and suchlike
+         * on reboot(), but the file systems need to be synce'd
+         * explicitly in advance. */
+        sync();
+
+        /* Make sure C-A-D is handled by the kernel from this point
+         * on... */
         reboot(RB_ENABLE_CAD);
 
         switch (a) {
--- a/src/udev/udevd.c	2014-10-23 17:13:15.784717951 +0200
+++ b/src/udev/udevd.c	2014-11-28 14:56:53.873865609 +0100
@@ -967,7 +967,7 @@
                 return;
 
         FOREACH_WORD_QUOTED(word, l, line, state) {
-                char *s, *opt;
+                char *s, *opt, *value;
 
                 s = strndup(word, l);
                 if (!s)
@@ -979,24 +979,24 @@
                 else
                         opt = s;
 
-                if (startswith(opt, "udev.log-priority=")) {
+                if ((value = startswith(opt, "udev.log-priority="))) {
                         int prio;
 
-                        prio = util_log_priority(opt + 18);
+                        prio = util_log_priority(value);
                         log_set_max_level(prio);
                         udev_set_log_priority(udev, prio);
-                } else if (startswith(opt, "udev.children-max=")) {
-                        r = safe_atoi(opt + 18, &arg_children_max);
+                } else if ((value = startswith(opt, "udev.children-max="))) {
+                        r = safe_atoi(value, &arg_children_max);
                         if (r < 0)
-                                log_warning("Invalid udev.children-max ignored: %s", opt + 18);
-                } else if (startswith(opt, "udev.exec-delay=")) {
-                        r = safe_atoi(opt + 16, &arg_exec_delay);
+                                log_warning("Invalid udev.children-max ignored: %s", value);
+                } else if ((value = startswith(opt, "udev.exec-delay="))) {
+                        r = safe_atoi(value, &arg_exec_delay);
                         if (r < 0)
-                                log_warning("Invalid udev.exec-delay ignored: %s", opt + 16);
-                } else if (startswith(opt, "udev.event-timeout=")) {
-                        r = safe_atou64(opt + 16, &arg_event_timeout_usec);
+                                log_warning("Invalid udev.exec-delay ignored: %s", value);
+                } else if ((value = startswith(opt, "udev.event-timeout="))) {
+                        r = safe_atou64(value, &arg_event_timeout_usec);
                         if (r < 0) {
-                                log_warning("Invalid udev.event-timeout ignored: %s", opt + 16);
+                                log_warning("Invalid udev.event-timeout ignored: %s", value);
                                 break;
                         }
                         arg_event_timeout_usec *= USEC_PER_SEC;
--- a/units/basic.target	2014-10-28 02:19:55.429947979 +0100
+++ b/units/basic.target	2014-11-28 14:56:53.875865630 +0100
@@ -8,8 +8,8 @@
 [Unit]
 Description=Basic System
 Documentation=man:systemd.special(7)
+
 Requires=sysinit.target
+After=sysinit.target
 Wants=sockets.target timers.target paths.target slices.target
-After=sysinit.target sockets.target timers.target paths.target slices.target
-JobTimeoutSec=15min
-JobTimeoutAction=poweroff-force
+After=sockets.target paths.target slices.target
--- a/units/poweroff.target	2014-10-28 02:19:55.429947979 +0100
+++ b/units/poweroff.target	2014-11-28 14:56:53.875865630 +0100
@@ -12,8 +12,6 @@
 Requires=systemd-poweroff.service
 After=systemd-poweroff.service
 AllowIsolate=yes
-JobTimeoutSec=30min
-JobTimeoutAction=poweroff-force
 
 [Install]
 Alias=ctrl-alt-del.target
--- a/units/reboot.target	2014-10-28 02:19:55.429947979 +0100
+++ b/units/reboot.target	2014-11-28 14:56:53.875865630 +0100
@@ -12,8 +12,6 @@
 Requires=systemd-reboot.service
 After=systemd-reboot.service
 AllowIsolate=yes
-JobTimeoutSec=30min
-JobTimeoutAction=reboot-force
 
 [Install]
 Alias=ctrl-alt-del.target
--- a/units/systemd-journal-flush.service.in	2014-10-23 00:39:42.449739860 +0200
+++ b/units/systemd-journal-flush.service.in	2014-11-28 14:58:53.776225146 +0100
@@ -6,12 +6,13 @@
 #  (at your option) any later version.
 
 [Unit]
-Description=Trigger Flushing of Journal to Persistent Storage
+Description=Flush Journal to Persistent Storage
 Documentation=man:systemd-journald.service(8) man:journald.conf(5)
 DefaultDependencies=no
 Requires=systemd-journald.service
-After=systemd-journald.service local-fs.target remote-fs.target
+After=systemd-journald.service
 Before=systemd-user-sessions.service systemd-tmpfiles-setup.service
+RequiresMountsFor=/var/log/journal
 
 [Service]
 ExecStart=@rootbindir@/journalctl --flush
--- a/units/timers.target	2013-08-13 22:02:52.832756455 +0200
+++ b/units/timers.target	2014-11-28 14:56:53.867865544 +0100
@@ -8,3 +8,6 @@
 [Unit]
 Description=Timers
 Documentation=man:systemd.special(7)
+
+DefaultDependencies=no
+Conflicts=shutdown.target
