summary refs log tree commit diff
path: root/pkgs/os-specific/linux/systemd/fixes.patch
blob: 0ad420cd35cc433ef32198e567545d2bd829f8fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
diff --git a/man/systemd.special.xml b/man/systemd.special.xml
index 7164b1e..29401eb 100644
--- a/man/systemd.special.xml
+++ b/man/systemd.special.xml
@@ -381,7 +381,7 @@
                                         this unit during
                                         installation. This is best
                                         configured via
-                                        <varname>WantedBy=multi-uer.target</varname>
+                                        <varname>WantedBy=multi-user.target</varname>
                                         in the unit's
                                         <literal>[Install]</literal>
                                         section.</para>
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/rules/99-systemd.rules.in b/rules/99-systemd.rules.in
index d17bdd9..040b10e 100644
--- a/rules/99-systemd.rules.in
+++ b/rules/99-systemd.rules.in
@@ -14,10 +14,6 @@ KERNEL=="vport*", TAG+="systemd"
 SUBSYSTEM=="block", KERNEL!="ram*|loop*", TAG+="systemd"
 SUBSYSTEM=="block", KERNEL!="ram*|loop*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", ENV{SYSTEMD_READY}="0"
 
-# Ignore encrypted devices with no identified superblock on it, since
-# we are probably still calling mke2fs or mkswap on it.
-SUBSYSTEM=="block", KERNEL!="ram*|loop*", ENV{DM_UUID}=="CRYPT-*", ENV{ID_PART_TABLE_TYPE}=="", ENV{ID_FS_USAGE}=="", ENV{SYSTEMD_READY}="0"
-
 # Ignore raid devices that are not yet assembled and started
 SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="md*", TEST!="md/array_state", ENV{SYSTEMD_READY}="0"
 SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="md*", ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0"
diff --git a/src/core/cgroup-semantics.c b/src/core/cgroup-semantics.c
index 82b02bb..7df9d01 100644
--- a/src/core/cgroup-semantics.c
+++ b/src/core/cgroup-semantics.c
@@ -255,7 +255,7 @@ static int map_blkio(const CGroupSemantics *s, const char *value, char **ret) {
 }
 
 static const CGroupSemantics semantics[] = {
-        { "cpu",     "cpu.shares",                 "CPUShare",              false, parse_cpu_shares,          NULL,       NULL },
+        { "cpu",     "cpu.shares",                 "CPUShares",             false, parse_cpu_shares,          NULL,       NULL },
         { "memory",  "memory.soft_limit_in_bytes", "MemorySoftLimit",       false, parse_memory_limit,        NULL,       NULL },
         { "memory",  "memory.limit_in_bytes",      "MemoryLimit",           false, parse_memory_limit,        NULL,       NULL },
         { "devices", "devices.allow",              "DeviceAllow",           true,  parse_device,              map_device, NULL },
diff --git a/src/core/dbus-execute.h b/src/core/dbus-execute.h
index 91d70e5..698102f 100644
--- a/src/core/dbus-execute.h
+++ b/src/core/dbus-execute.h
@@ -63,7 +63,7 @@
         "  <property name=\"CPUSchedulingPolicy\" type=\"i\" access=\"read\"/>\n" \
         "  <property name=\"CPUSchedulingPriority\" type=\"i\" access=\"read\"/>\n" \
         "  <property name=\"CPUAffinity\" type=\"ay\" access=\"read\"/>\n" \
-        "  <property name=\"TimerSlackNS\" type=\"t\" access=\"read\"/>\n" \
+        "  <property name=\"TimerSlackNSec\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"CPUSchedulingResetOnFork\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"NonBlocking\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"StandardInput\" type=\"s\" access=\"read\"/>\n" \
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 56b02a1..2b6d799 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1550,7 +1550,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                 _cleanup_strv_free_ char **l = NULL;
                 char **e = NULL;
 
-                SELINUX_ACCESS_CHECK(connection, message, "reboot");
+                SELINUX_ACCESS_CHECK(connection, message, "reload");
 
                 r = bus_parse_strv(message, &l);
                 if (r == -ENOMEM)
@@ -1577,7 +1577,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                 _cleanup_strv_free_ char **l = NULL;
                 char **e = NULL;
 
-                SELINUX_ACCESS_CHECK(connection, message, "reboot");
+                SELINUX_ACCESS_CHECK(connection, message, "reload");
 
                 r = bus_parse_strv(message, &l);
                 if (r == -ENOMEM)
@@ -1605,7 +1605,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                 char **f = NULL;
                 DBusMessageIter iter;
 
-                SELINUX_ACCESS_CHECK(connection, message, "reboot");
+                SELINUX_ACCESS_CHECK(connection, message, "reload");
 
                 if (!dbus_message_iter_init(message, &iter))
                         goto oom;
diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c
index 2e99fba..e72749a 100644
--- a/src/core/dbus-swap.c
+++ b/src/core/dbus-swap.c
@@ -93,6 +93,7 @@ static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_swap_append_swap_result, swap_result,
 static const BusProperty bus_swap_properties[] = {
         { "What",       bus_property_append_string, "s", offsetof(Swap, what),  true },
         { "Priority",   bus_swap_append_priority,   "i", 0 },
+        { "TimeoutUSec",bus_property_append_usec,   "t", offsetof(Swap, timeout_usec)},
         BUS_EXEC_COMMAND_PROPERTY("ExecActivate",   offsetof(Swap, exec_command[SWAP_EXEC_ACTIVATE]),   false),
         BUS_EXEC_COMMAND_PROPERTY("ExecDeactivate", offsetof(Swap, exec_command[SWAP_EXEC_DEACTIVATE]), false),
         { "ControlPID", bus_property_append_pid,    "u", offsetof(Swap, control_pid) },
diff --git a/src/core/main.c b/src/core/main.c
index 7fc06be..101ce79 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1590,14 +1590,14 @@ int main(int argc, char *argv[]) {
                         log_error("Failed to adjust timer slack: %m");
 
         if (arg_capability_bounding_set_drop) {
-                r = capability_bounding_set_drop(arg_capability_bounding_set_drop, true);
+                r = capability_bounding_set_drop_usermode(arg_capability_bounding_set_drop);
                 if (r < 0) {
-                        log_error("Failed to drop capability bounding set: %s", strerror(-r));
+                        log_error("Failed to drop capability bounding set of usermode helpers: %s", strerror(-r));
                         goto finish;
                 }
-                r = capability_bounding_set_drop_usermode(arg_capability_bounding_set_drop);
+                r = capability_bounding_set_drop(arg_capability_bounding_set_drop, true);
                 if (r < 0) {
-                        log_error("Failed to drop capability bounding set of usermode helpers: %s", strerror(-r));
+                        log_error("Failed to drop capability bounding set: %s", strerror(-r));
                         goto finish;
                 }
         }
@@ -1650,6 +1650,7 @@ int main(int argc, char *argv[]) {
         /* This will close all file descriptors that were opened, but
          * not claimed by any unit. */
         fdset_free(fds);
+        fds = NULL;
 
         if (serialization) {
                 fclose(serialization);
@@ -1857,7 +1858,7 @@ finish:
                         char_array_0(sfd);
 
                         i = 0;
-                        args[i++] = SYSTEMD_BINARY_PATH;
+                        args[i++] = "/run/current-system/systemd/lib/systemd/systemd";
                         if (switch_root_dir)
                                 args[i++] = "--switched-root";
                         args[i++] = arg_running_as == SYSTEMD_SYSTEM ? "--system" : "--user";
diff --git a/src/core/manager.c b/src/core/manager.c
index c7f8f20..0508628 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1372,7 +1372,7 @@ static int manager_process_signal_fd(Manager *m) {
 
                 case SIGINT:
                         if (m->running_as == SYSTEMD_SYSTEM) {
-                                manager_start_target(m, SPECIAL_CTRL_ALT_DEL_TARGET, JOB_REPLACE);
+                                manager_start_target(m, SPECIAL_CTRL_ALT_DEL_TARGET, JOB_REPLACE_IRREVERSIBLY);
                                 break;
                         }
 
diff --git a/src/core/service.c b/src/core/service.c
index 3617c24..4d0e2ad 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -2642,6 +2642,9 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
         if (s->exec_context.var_tmp_dir)
                 unit_serialize_item(u, f, "var-tmp-dir", s->exec_context.var_tmp_dir);
 
+        if (s->forbid_restart)
+                unit_serialize_item(u, f, "forbid-restart", yes_no(s->forbid_restart));
+
         return 0;
 }
 
@@ -2776,6 +2779,14 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
                         return log_oom();
 
                 s->exec_context.var_tmp_dir = t;
+        } else if (streq(key, "forbid-restart")) {
+                int b;
+
+                b = parse_boolean(value);
+                if (b < 0)
+                        log_debug_unit(u->id, "Failed to parse forbid-restart value %s", value);
+                else
+                        s->forbid_restart = b;
         } else
                 log_debug_unit(u->id, "Unknown serialization key '%s'", key);
 
diff --git a/src/core/snapshot.c b/src/core/snapshot.c
index a63eccd..a6807eb 100644
--- a/src/core/snapshot.c
+++ b/src/core/snapshot.c
@@ -217,8 +217,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);
                 }
diff --git a/src/core/umount.c b/src/core/umount.c
index 1e95ad7..9f0e471 100644
--- a/src/core/umount.c
+++ b/src/core/umount.c
@@ -435,6 +435,8 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, bool log_e
                  * anyway, since we are running from it. They have
                  * already been remounted ro. */
                 if (path_equal(m->path, "/")
+                    || path_equal(m->path, "/nix")
+                    || path_equal(m->path, "/nix/store")
 #ifndef HAVE_SPLIT_USR
                     || path_equal(m->path, "/usr")
 #endif
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index 81b7708..edd0b40 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -111,6 +111,7 @@ static int create_disk(
                 "Conflicts=umount.target\n"
                 "DefaultDependencies=no\n"
                 "BindsTo=dev-mapper-%i.device\n"
+                "IgnoreOnIsolate=true\n"
                 "After=systemd-readahead-collect.service systemd-readahead-replay.service\n",
                 f);
 
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index c17299f..6b3e67e 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -351,7 +351,7 @@ static int add_mount(
 
         if (automount && !path_equal(where, "/")) {
                 automount_name = unit_name_from_path(where, ".automount");
-                if (!name)
+                if (!automount_name)
                         return log_oom();
 
                 automount_unit = strjoin(arg_dest, "/", automount_name, NULL);
@@ -596,9 +596,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/src/journal/journal-file.c b/src/journal/journal-file.c
index 38499a6..bb80905 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -907,6 +907,8 @@ static int journal_file_append_field(
 
         osize = offsetof(Object, field.payload) + size;
         r = journal_file_append_object(f, OBJECT_FIELD, osize, &o, &p);
+        if (r < 0)
+                return r;
 
         o->field.hash = htole64(hash);
         memcpy(o->field.payload, field, size);
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 88163c0..e09ba4c 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -333,8 +333,10 @@ void server_rotate(Server *s) {
                 if (r < 0)
                         if (f)
                                 log_error("Failed to rotate %s: %s", f->path, strerror(-r));
-                        else
+                        else {
                                 log_error("Failed to create user journal: %s", strerror(-r));
+                                hashmap_remove(s->user_journals, k);
+                        }
                 else {
                         hashmap_replace(s->user_journals, k, f);
                         server_fix_perms(s, f, PTR_TO_UINT32(k));
@@ -975,7 +977,8 @@ int process_event(Server *s, struct epoll_event *ev) {
                 ssize_t n;
 
                 if (ev->events != EPOLLIN) {
-                        log_error("Got invalid event from epoll.");
+                        log_error("Got invalid event from epoll for %s: %"PRIx32,
+                                  "signal fd", ev->events);
                         return -EIO;
                 }
 
@@ -1024,8 +1027,12 @@ int process_event(Server *s, struct epoll_event *ev) {
         } else if (ev->data.fd == s->dev_kmsg_fd) {
                 int r;
 
-                if (ev->events != EPOLLIN) {
-                        log_error("Got invalid event from epoll.");
+                if (ev->events & EPOLLERR)
+                        log_warning("/dev/kmsg buffer overrun, some messages lost.");
+
+                if (!(ev->events & EPOLLIN)) {
+                        log_error("Got invalid event from epoll for %s: %"PRIx32,
+                                  "/dev/kmsg", ev->events);
                         return -EIO;
                 }
 
@@ -1039,7 +1046,9 @@ int process_event(Server *s, struct epoll_event *ev) {
                    ev->data.fd == s->syslog_fd) {
 
                 if (ev->events != EPOLLIN) {
-                        log_error("Got invalid event from epoll.");
+                        log_error("Got invalid event from epoll for %s: %"PRIx32,
+                                  ev->data.fd == s->native_fd ? "native fd" : "syslog fd",
+                                  ev->events);
                         return -EIO;
                 }
 
@@ -1140,12 +1149,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.");
@@ -1167,7 +1171,8 @@ int process_event(Server *s, struct epoll_event *ev) {
         } else if (ev->data.fd == s->stdout_fd) {
 
                 if (ev->events != EPOLLIN) {
-                        log_error("Got invalid event from epoll.");
+                        log_error("Got invalid event from epoll for %s: %"PRIx32,
+                                  "stdout fd", ev->events);
                         return -EIO;
                 }
 
@@ -1178,6 +1183,8 @@ int process_event(Server *s, struct epoll_event *ev) {
                 StdoutStream *stream;
 
                 if ((ev->events|EPOLLIN|EPOLLHUP) != (EPOLLIN|EPOLLHUP)) {
+                        log_error("Got invalid event from epoll for %s: %"PRIx32,
+                                  "stdout stream", ev->events);
                         log_error("Got invalid event from epoll.");
                         return -EIO;
                 }
diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
index 54bf114..bd197d0 100644
--- a/src/journal/mmap-cache.c
+++ b/src/journal/mmap-cache.c
@@ -308,9 +308,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/src/libsystemd-bus/bus-internal.c b/src/libsystemd-bus/bus-internal.c
index 0e66f3d..cac948e 100644
--- a/src/libsystemd-bus/bus-internal.c
+++ b/src/libsystemd-bus/bus-internal.c
@@ -63,7 +63,7 @@ bool object_path_is_valid(const char *p) {
 
 bool interface_name_is_valid(const char *p) {
         const char *q;
-        bool dot, found_dot;
+        bool dot, found_dot = false;
 
         if (isempty(p))
                 return false;
@@ -103,7 +103,7 @@ bool interface_name_is_valid(const char *p) {
 
 bool service_name_is_valid(const char *p) {
         const char *q;
-        bool dot, found_dot, unique;
+        bool dot, found_dot = false, unique;
 
         if (isempty(p))
                 return false;
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 7d6d848..b0eb2f1 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -1088,11 +1088,11 @@ static int dispatch_rqueue(sd_bus *bus, sd_bus_message **m) {
                 if (r == 0)
                         return ret;
 
-                r = 1;
+                ret = 1;
         } while (!z);
 
         *m = z;
-        return 1;
+        return ret;
 }
 
 int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial) {
diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c
index 5ccaabd..100c1fb 100644
--- a/src/libudev/libudev-enumerate.c
+++ b/src/libudev/libudev-enumerate.c
@@ -299,7 +299,7 @@ _public_ struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enume
                         /* skip to be delayed devices, and move the to
                          * the point where the prefix changes. We can
                          * only move one item at a time. */
-                        if (!move_later) {
+                        if (move_later == -1) {
                                 move_later_prefix = devices_delay_later(udev_enumerate->udev, entry->syspath);
 
                                 if (move_later_prefix > 0) {
@@ -718,6 +718,8 @@ static bool match_subsystem(struct udev_enumerate *udev_enumerate, const char *s
 {
         struct udev_list_entry *list_entry;
 
+        subsystem = subsystem ? : "";
+
         udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->subsystem_nomatch_list)) {
                 if (fnmatch(udev_list_entry_get_name(list_entry), subsystem, 0) == 0)
                         return false;
@@ -826,23 +828,27 @@ nomatch:
 static int parent_add_child(struct udev_enumerate *enumerate, const char *path)
 {
         struct udev_device *dev;
+        int r = 0;
 
         dev = udev_device_new_from_syspath(enumerate->udev, path);
         if (dev == NULL)
                 return -ENODEV;
 
         if (!match_subsystem(enumerate, udev_device_get_subsystem(dev)))
-                return 0;
+                goto nomatch;
         if (!match_sysname(enumerate, udev_device_get_sysname(dev)))
-                return 0;
+                goto nomatch;
         if (!match_property(enumerate, dev))
-                return 0;
+                goto nomatch;
         if (!match_sysattr(enumerate, dev))
-                return 0;
+                goto nomatch;
 
         syspath_add(enumerate, udev_device_get_syspath(dev));
+        r = 1;
+
+nomatch:
         udev_device_unref(dev);
-        return 1;
+        return r;
 }
 
 static int parent_crawl_children(struct udev_enumerate *enumerate, const char *path, int maxdepth)
diff --git a/src/libudev/libudev.sym b/src/libudev/libudev.sym
index 8e09430..1e6f885 100644
--- a/src/libudev/libudev.sym
+++ b/src/libudev/libudev.sym
@@ -109,5 +109,6 @@ global:
 } LIBUDEV_189;
 
 LIBUDEV_199 {
+global:
         udev_device_set_sysattr_value;
 } LIBUDEV_196;
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index 7b19ee0..49ee420 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -302,8 +302,8 @@ int main(int argc, char *argv[]) {
 
                 STRV_FOREACH(i, arg_proc_cmdline_modules) {
                         k = load_module(ctx, *i);
-                        if (k < 0)
-                                r = EXIT_FAILURE;
+                        if (k < 0 && r == 0)
+                                r = k;
                 }
 
                 r = conf_files_list_nulstr(&files, ".conf", NULL, conf_file_dirs);
diff --git a/src/nss-myhostname/netlink.c b/src/nss-myhostname/netlink.c
index b1ef912..4f2ab5c 100644
--- a/src/nss-myhostname/netlink.c
+++ b/src/nss-myhostname/netlink.c
@@ -113,6 +113,10 @@ static int read_reply(int fd, struct address **list, unsigned *n_list) {
                     ifaddrmsg->ifa_scope == RT_SCOPE_NOWHERE)
                         continue;
 
+                if (ifaddrmsg->ifa_family == AF_INET6 &&
+                    ifaddrmsg->ifa_scope == RT_SCOPE_LINK)
+                        continue;
+
                 if (ifaddrmsg->ifa_flags & IFA_F_DEPRECATED)
                         continue;
 
diff --git a/src/shared/efivars.c b/src/shared/efivars.c
index 8d004ba..99340c9 100644
--- a/src/shared/efivars.c
+++ b/src/shared/efivars.c
@@ -383,7 +383,8 @@ int efi_get_boot_options(uint16_t **options) {
                 list[count ++] = id;
         }
 
-        qsort(list, count, sizeof(uint16_t), cmp_uint16);
+        if (list)
+                qsort(list, count, sizeof(uint16_t), cmp_uint16);
 
         *options = list;
         return count;
diff --git a/src/shared/env-util.c b/src/shared/env-util.c
index 6a52fb9..598222c 100644
--- a/src/shared/env-util.c
+++ b/src/shared/env-util.c
@@ -406,7 +406,9 @@ char **strv_env_clean_log(char **e, const char *message) {
                 e[k++] = *p;
         }
 
-        e[k] = NULL;
+        if (e)
+                e[k] = NULL;
+
         return e;
 }
 
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/src/shared/polkit.c b/src/shared/polkit.c
index cea7074..1c5e9e3 100644
--- a/src/shared/polkit.c
+++ b/src/shared/polkit.c
@@ -38,12 +38,8 @@ int verify_polkit(
 
 #ifdef ENABLE_POLKIT
         DBusMessage *m = NULL, *reply = NULL;
-        const char *unix_process = "unix-process", *pid = "pid", *starttime = "start-time", *cancel_id = "";
+        const char *system_bus_name = "system-bus-name", *name = "name", *cancel_id = "";
         uint32_t flags = interactive ? 1 : 0;
-        pid_t pid_raw;
-        uint32_t pid_u32;
-        unsigned long long starttime_raw;
-        uint64_t starttime_u64;
         DBusMessageIter iter_msg, iter_struct, iter_array, iter_dict, iter_variant;
         int r;
         dbus_bool_t authorized = FALSE, challenge = FALSE;
@@ -68,14 +64,6 @@ int verify_polkit(
 
 #ifdef ENABLE_POLKIT
 
-        pid_raw = bus_get_unix_process_id(c, sender, error);
-        if (pid_raw == 0)
-                return -EINVAL;
-
-        r = get_starttime_of_pid(pid_raw, &starttime_raw);
-        if (r < 0)
-                return r;
-
         m = dbus_message_new_method_call(
                         "org.freedesktop.PolicyKit1",
                         "/org/freedesktop/PolicyKit1/Authority",
@@ -86,22 +74,13 @@ int verify_polkit(
 
         dbus_message_iter_init_append(m, &iter_msg);
 
-        pid_u32 = (uint32_t) pid_raw;
-        starttime_u64 = (uint64_t) starttime_raw;
-
         if (!dbus_message_iter_open_container(&iter_msg, DBUS_TYPE_STRUCT, NULL, &iter_struct) ||
-            !dbus_message_iter_append_basic(&iter_struct, DBUS_TYPE_STRING, &unix_process) ||
+            !dbus_message_iter_append_basic(&iter_struct, DBUS_TYPE_STRING, &system_bus_name) ||
             !dbus_message_iter_open_container(&iter_struct, DBUS_TYPE_ARRAY, "{sv}", &iter_array) ||
             !dbus_message_iter_open_container(&iter_array, DBUS_TYPE_DICT_ENTRY, NULL, &iter_dict) ||
-            !dbus_message_iter_append_basic(&iter_dict, DBUS_TYPE_STRING, &pid) ||
-            !dbus_message_iter_open_container(&iter_dict, DBUS_TYPE_VARIANT, "u", &iter_variant) ||
-            !dbus_message_iter_append_basic(&iter_variant, DBUS_TYPE_UINT32, &pid_u32) ||
-            !dbus_message_iter_close_container(&iter_dict, &iter_variant) ||
-            !dbus_message_iter_close_container(&iter_array, &iter_dict) ||
-            !dbus_message_iter_open_container(&iter_array, DBUS_TYPE_DICT_ENTRY, NULL, &iter_dict) ||
-            !dbus_message_iter_append_basic(&iter_dict, DBUS_TYPE_STRING, &starttime) ||
-            !dbus_message_iter_open_container(&iter_dict, DBUS_TYPE_VARIANT, "t", &iter_variant) ||
-            !dbus_message_iter_append_basic(&iter_variant, DBUS_TYPE_UINT64, &starttime_u64) ||
+            !dbus_message_iter_append_basic(&iter_dict, DBUS_TYPE_STRING, &name) ||
+            !dbus_message_iter_open_container(&iter_dict, DBUS_TYPE_VARIANT, "s", &iter_variant) ||
+            !dbus_message_iter_append_basic(&iter_variant, DBUS_TYPE_STRING, &sender) ||
             !dbus_message_iter_close_container(&iter_dict, &iter_variant) ||
             !dbus_message_iter_close_container(&iter_array, &iter_dict) ||
             !dbus_message_iter_close_container(&iter_struct, &iter_array) ||
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 3cca861..f6052dd 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1482,7 +1482,7 @@ static DBusHandlerResult wait_filter(DBusConnection *connection, DBusMessage *me
 
         } else if (dbus_message_is_signal(message, "org.freedesktop.systemd1.Manager", "JobRemoved")) {
                 uint32_t id;
-                const char *path, *result, *unit;
+                const char *path, *result, *unit, *r;
 
                 if (dbus_message_get_args(message, &error,
                                           DBUS_TYPE_UINT32, &id,
@@ -1491,7 +1491,11 @@ static DBusHandlerResult wait_filter(DBusConnection *connection, DBusMessage *me
                                           DBUS_TYPE_STRING, &result,
                                           DBUS_TYPE_INVALID)) {
 
-                        free(set_remove(d->set, (char*) path));
+                        r = set_remove(d->set, (char*) path);
+                        if (!r)
+                                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+                        free(r);
 
                         if (!isempty(result))
                                 d->result = strdup(result);
@@ -1511,7 +1515,11 @@ static DBusHandlerResult wait_filter(DBusConnection *connection, DBusMessage *me
                         /* Compatibility with older systemd versions <
                          * 183 during upgrades. This should be dropped
                          * one day. */
-                        free(set_remove(d->set, (char*) path));
+                        r = set_remove(d->set, (char*) path);
+                        if (!r)
+                                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+                        free(r);
 
                         if (*result)
                                 d->result = strdup(result);
@@ -1867,7 +1875,7 @@ static int start_unit_one(
                         return log_oom();
 
                 r = set_consume(s, p);
-                if (r < 0) {
+                if (r < 0 && r != -EEXIST) {
                         log_error("Failed to add path to set.");
                         return r;
                 }
diff --git a/units/emergency.service.in b/units/emergency.service.in
index 442f0e0..6b7eafd 100644
--- a/units/emergency.service.in
+++ b/units/emergency.service.in
@@ -15,7 +15,6 @@ Before=shutdown.target
 [Service]
 Environment=HOME=/root
 WorkingDirectory=/root
-ExecStartPre=-/bin/plymouth quit
 ExecStartPre=-/bin/echo -e 'Welcome to emergency mode! After logging in, type "journalctl -xb" to view\\nsystem logs, "systemctl reboot" to reboot, "systemctl default" to try again\\nto boot into default mode.'
 ExecStart=-/sbin/sulogin
 ExecStopPost=@SYSTEMCTL@ --fail --no-block default
diff --git a/units/local-fs.target b/units/local-fs.target
index 18c3d74..a09054c 100644
--- a/units/local-fs.target
+++ b/units/local-fs.target
@@ -11,3 +11,5 @@ Documentation=man:systemd.special(7)
 After=local-fs-pre.target
 OnFailure=emergency.target
 OnFailureIsolate=no
+
+X-StopOnReconfiguration=yes
diff --git a/units/remote-fs.target b/units/remote-fs.target
index 09213e8..47b4cf5 100644
--- a/units/remote-fs.target
+++ b/units/remote-fs.target
@@ -10,5 +10,7 @@ Description=Remote File Systems
 Documentation=man:systemd.special(7)
 After=remote-fs-pre.target
 
+X-StopOnReconfiguration=yes
+
 [Install]
 WantedBy=multi-user.target
diff --git a/units/rescue.service.m4.in b/units/rescue.service.m4.in
index 269797a..2c640f4 100644
--- a/units/rescue.service.m4.in
+++ b/units/rescue.service.m4.in
@@ -16,7 +16,6 @@ Before=shutdown.target
 [Service]
 Environment=HOME=/root
 WorkingDirectory=/root
-ExecStartPre=-/bin/plymouth quit
 ExecStartPre=-/bin/echo -e 'Welcome to rescue mode! Type "systemctl default" or ^D to enter default mode.\\nType "journalctl -xb" to view system logs. Type "systemctl reboot" to reboot.'
 ExecStart=-/sbin/sulogin
 ExecStopPost=-@SYSTEMCTL@ --fail --no-block default
diff --git a/units/sysinit.target b/units/sysinit.target
index 8f4fb8f..e0f0147 100644
--- a/units/sysinit.target
+++ b/units/sysinit.target
@@ -9,6 +9,5 @@
 Description=System Initialization
 Documentation=man:systemd.special(7)
 Conflicts=emergency.service emergency.target
-Wants=local-fs.target swap.target
-After=local-fs.target swap.target emergency.service emergency.target
+After=emergency.service emergency.target
 RefuseManualStart=yes
diff --git a/units/systemd-journald.service.in b/units/systemd-journald.service.in
index ab2e50c..9563a7d 100644
--- a/units/systemd-journald.service.in
+++ b/units/systemd-journald.service.in
@@ -24,3 +24,8 @@ CapabilityBoundingSet=CAP_SYS_ADMIN CAP_DAC_OVERRIDE CAP_SYS_PTRACE CAP_SYSLOG C
 # Increase the default a bit in order to allow many simultaneous
 # services being run since we keep one fd open per service.
 LimitNOFILE=16384
+
+# Don't restart journald, since that causes services connected to
+# journald to stop logging (see
+# https://bugs.freedesktop.org/show_bug.cgi?id=56043).
+X-RestartIfChanged=no
diff --git a/units/systemd-user-sessions.service.in b/units/systemd-user-sessions.service.in
index 0869e73..b6ed958 100644
--- a/units/systemd-user-sessions.service.in
+++ b/units/systemd-user-sessions.service.in
@@ -15,3 +15,6 @@ Type=oneshot
 RemainAfterExit=yes
 ExecStart=@rootlibexecdir@/systemd-user-sessions start
 ExecStop=@rootlibexecdir@/systemd-user-sessions stop
+
+# Restart kills all active sessions.
+X-RestartIfChanged=no