Merge remote-tracking branch 'origin/systemd-216' into staging

+93 -2644
+20 -22
nixos/modules/config/nsswitch.nix
··· 35 35 36 36 config = { 37 37 38 - environment.etc = 39 - [ # Name Service Switch configuration file. Required by the C library. 40 - # !!! Factor out the mdns stuff. The avahi module should define 41 - # an option used by this module. 42 - { source = pkgs.writeText "nsswitch.conf" 43 - '' 44 - passwd: files ldap 45 - group: files ldap 46 - shadow: files ldap 47 - hosts: files ${optionalString nssmdns "mdns_minimal [NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"} ${optionalString nsswins "wins"} myhostname 48 - networks: files dns 49 - ethers: files 50 - services: files 51 - protocols: files 52 - ''; 53 - target = "nsswitch.conf"; 54 - } 55 - ]; 38 + # Name Service Switch configuration file. Required by the C 39 + # library. !!! Factor out the mdns stuff. The avahi module 40 + # should define an option used by this module. 41 + environment.etc."nsswitch.conf".text = 42 + '' 43 + passwd: files ldap 44 + group: files ldap 45 + shadow: files ldap 46 + hosts: files ${optionalString nssmdns "mdns_minimal [NOTFOUND=return]"} dns ${optionalString nssmdns "mdns"} ${optionalString nsswins "wins"} myhostname mymachines 47 + networks: files dns 48 + ethers: files 49 + services: files 50 + protocols: files 51 + ''; 56 52 57 - # Use nss-myhostname to ensure that our hostname always resolves to 58 - # a valid IP address. It returns all locally configured IP 59 - # addresses, or ::1 and 127.0.0.2 as fallbacks. 60 - system.nssModules = [ pkgs.systemd ]; 53 + # Systemd provides nss-myhostname to ensure that our hostname 54 + # always resolves to a valid IP address. It returns all locally 55 + # configured IP addresses, or ::1 and 127.0.0.2 as 56 + # fallbacks. Systemd also provides nss-mymachines to return IP 57 + # addresses of local containers. 58 + system.nssModules = [ config.systemd.package ]; 61 59 62 60 }; 63 61 }
+1 -1
nixos/modules/services/system/nscd.nix
··· 62 62 mkdir -m 0755 -p /var/db/nscd 63 63 ''; 64 64 65 - restartTriggers = [ config.environment.etc.hosts.source ]; 65 + restartTriggers = [ config.environment.etc.hosts.source config.environment.etc."nsswitch.conf".source ]; 66 66 67 67 serviceConfig = 68 68 { ExecStart = "@${pkgs.glibc}/sbin/nscd nscd -f ${cfgFile}";
+1
nixos/modules/system/boot/systemd.nix
··· 81 81 "systemd-journal-flush.service" 82 82 "systemd-journal-gatewayd.socket" 83 83 "systemd-journal-gatewayd.service" 84 + "systemd-journald-dev-log.socket" 84 85 "syslog.socket" 85 86 86 87 # SysV init compatibility.
+4 -1
nixos/modules/virtualisation/containers.nix
··· 277 277 278 278 NotifyAccess = "all"; 279 279 280 - # Note that on reboot, systemd-nspawn returns 10, so this 280 + # Note that on reboot, systemd-nspawn returns 133, so this 281 281 # unit will be restarted. On poweroff, it returns 0, so the 282 282 # unit won't be restarted. 283 + RestartForceExitStatus = "133"; 284 + SuccessExitStatus = "133"; 285 + 283 286 Restart = "on-failure"; 284 287 285 288 # Hack: we don't want to kill systemd-nspawn, since we call
+2 -2
pkgs/development/libraries/polkit/default.nix
··· 1 1 { stdenv, fetchurl, pkgconfig, glib, expat, pam, intltool, spidermonkey 2 - , gobjectIntrospection, libxslt, docbook_xsl 2 + , gobjectIntrospection, libxslt, docbook_xsl, docbook_xml_dtd_412 3 3 , useSystemd ? stdenv.isLinux, systemd }: 4 4 5 5 let ··· 24 24 25 25 buildInputs = 26 26 [ pkgconfig glib expat pam intltool spidermonkey gobjectIntrospection ] 27 - ++ [ libxslt docbook_xsl ] # man pages 27 + ++ [ libxslt docbook_xsl docbook_xml_dtd_412 ] # man pages 28 28 ++ stdenv.lib.optional useSystemd systemd; 29 29 30 30 # Ugly hack to overwrite hardcoded directories
+28 -9
pkgs/os-specific/linux/systemd/default.nix
··· 1 1 { stdenv, fetchurl, pkgconfig, intltool, gperf, libcap, dbus, kmod 2 2 , xz, pam, acl, cryptsetup, libuuid, m4, utillinux 3 - , glib, kbd, libxslt, coreutils, libgcrypt, sysvtools, docbook_xsl 3 + , glib, kbd, libxslt, coreutils, libgcrypt, sysvtools 4 4 , kexectools, libmicrohttpd, linuxHeaders 5 5 , pythonPackages ? null, pythonSupport ? false 6 - , autoreconfHook 7 6 }: 8 7 9 8 assert stdenv.isLinux; ··· 11 10 assert pythonSupport -> pythonPackages != null; 12 11 13 12 stdenv.mkDerivation rec { 14 - version = "212"; 13 + version = "216"; 15 14 name = "systemd-${version}"; 16 15 17 16 src = fetchurl { 18 17 url = "http://www.freedesktop.org/software/systemd/${name}.tar.xz"; 19 - sha256 = "1hpjcc42svrs06q3isjm3m5aphgkpfdylmvpnif71zh46ys0cab5"; 18 + sha256 = "1wr8jxhp2rmbzabm743rmrhp2c8kir1990x6iblzzmj0v2vkspcl"; 20 19 }; 21 20 22 21 patches = 23 22 [ # These are all changes between upstream and 24 - # https://github.com/edolstra/systemd/tree/nixos-v212. 23 + # https://github.com/edolstra/systemd/tree/nixos-v216. 25 24 ./fixes.patch 26 25 ]; 27 26 28 27 buildInputs = 29 28 [ pkgconfig intltool gperf libcap kmod xz pam acl 30 - /* cryptsetup */ libuuid m4 glib libxslt libgcrypt docbook_xsl 29 + /* cryptsetup */ libuuid m4 glib libxslt libgcrypt 31 30 libmicrohttpd linuxHeaders 32 - autoreconfHook 33 31 ] ++ stdenv.lib.optionals pythonSupport [pythonPackages.python pythonPackages.lxml]; 34 32 35 33 configureFlags = ··· 45 43 "--with-dbussessionservicedir=$(out)/share/dbus-1/services" 46 44 "--with-firmware-path=/root/test-firmware:/run/current-system/firmware" 47 45 "--with-tty-gid=3" # tty in NixOS has gid 3 48 - "--disable-networkd" # enable/use eventually 49 46 "--enable-compat-libs" # get rid of this eventually 50 47 "--disable-tests" 48 + 49 + "--disable-hostnamed" 50 + "--disable-networkd" # enable/use eventually 51 + "--disable-sysusers" 52 + "--disable-timedated" 53 + "--disable-timesyncd" 54 + "--disable-readahead" 55 + "--disable-firstboot" 56 + "--disable-localed" 57 + "--disable-resolved" 58 + "--disable-split-usr" 59 + 60 + "--with-sysvinit-path=" 61 + "--with-sysvrcnd-path=" 62 + "--with-rc-local-script-path-stop=/etc/halt.local" 51 63 ]; 52 64 53 65 preConfigure = ··· 88 100 # currently running systemd (/run/current-system/systemd) so 89 101 # that we don't use an obsolete/garbage-collected release agent. 90 102 "-USYSTEMD_CGROUP_AGENT_PATH" "-DSYSTEMD_CGROUP_AGENT_PATH=\"/run/current-system/systemd/lib/systemd/systemd-cgroups-agent\"" 103 + 104 + "-USYSTEMD_BINARY_PATH" "-DSYSTEMD_BINARY_PATH=\"/run/current-system/systemd/lib/systemd/systemd\"" 91 105 ]; 92 106 93 107 # Use /var/lib/udev rather than /etc/udev for the generated hardware ··· 104 118 "pamconfdir=$(out)/etc/pam.d" 105 119 ]; 106 120 107 - # Get rid of configuration-specific data. 108 121 postInstall = 109 122 '' 123 + # sysinit.target: Don't depend on 124 + # systemd-tmpfiles-setup.service. This interferes with NixOps's 125 + # send-keys feature (since sshd.service depends indirectly on 126 + # sysinit.target). 127 + mv $out/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup-dev.service $out/lib/systemd/system/multi-user.target.wants/ 128 + 110 129 mkdir -p $out/example/systemd 111 130 mv $out/lib/{modules-load.d,binfmt.d,sysctl.d,tmpfiles.d} $out/example 112 131 mv $out/lib/systemd/{system,user} $out/example/systemd
+37 -2609
pkgs/os-specific/linux/systemd/fixes.patch
··· 1 - diff --git a/Makefile.am b/Makefile.am 2 - index 3d9e5c1..46487f6 100644 3 - --- a/Makefile.am 4 - +++ b/Makefile.am 5 - @@ -1095,7 +1095,7 @@ BUILT_SOURCES += \ 6 - 7 - src/shared/errno-list.txt: 8 - $(AM_V_at)$(MKDIR_P) $(dir $@) 9 - - $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - < /dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+[0-9]/ { print $$2; }' > $@ 10 - + $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - < /dev/null | $(AWK) '/^#define[ \t]+E[^ _]+[ \t]+/ { print $$2; }' > $@ 11 - 12 - src/shared/errno-from-name.gperf: src/shared/errno-list.txt 13 - $(AM_V_at)$(MKDIR_P) $(dir $@) 14 - @@ -1107,7 +1107,7 @@ src/shared/errno-from-name.h: src/shared/errno-from-name.gperf 15 - 16 - src/shared/errno-to-name.h: src/shared/errno-list.txt 17 - $(AM_V_at)$(MKDIR_P) $(dir $@) 18 - - $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' < $< > $@ 19 - + $(AM_V_GEN)$(AWK) 'BEGIN{ print "static const char* const errno_names[] = { "} !/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ { printf "[%s] = \"%s\",\n", $$1, $$1 } END{print "};"}' < $< > $@ 20 - 21 - src/shared/af-list.txt: 22 - $(AM_V_at)$(MKDIR_P) $(dir $@) 23 - @@ -1707,7 +1707,9 @@ dist_tmpfiles_DATA += \ 24 - endif 25 - 26 - SYSINIT_TARGET_WANTS += \ 27 - - systemd-tmpfiles-setup-dev.service \ 28 - + systemd-tmpfiles-setup-dev.service 29 - + 30 - +MULTI_USER_TARGET_WANTS += \ 31 - systemd-tmpfiles-setup.service 32 - 33 - dist_zshcompletion_DATA += \ 34 - @@ -1961,6 +1963,7 @@ systemd_cgls_SOURCES = \ 35 - src/cgls/cgls.c 36 - 37 - systemd_cgls_LDADD = \ 38 - + libsystemd-internal.la \ 39 - libsystemd-shared.la 40 - 41 - # ------------------------------------------------------------------------------ 42 - diff --git a/TODO b/TODO 43 - index e2ca1e6..d7efdd5 100644 44 - --- a/TODO 45 - +++ b/TODO 46 - @@ -1,4 +1,6 @@ 47 - Bugfixes: 48 - +* Should systemctl status \* work on all unit types, not just .service? 49 - + 50 - * enabling an instance unit creates a pointless link, and 51 - the unit will be started with getty@getty.service: 52 - $ systemctl enable getty@.service 53 - diff --git a/rules/42-usb-hid-pm.rules b/rules/42-usb-hid-pm.rules 54 - index c675b5b..4c300da 100644 55 - --- a/rules/42-usb-hid-pm.rules 56 - +++ b/rules/42-usb-hid-pm.rules 57 - @@ -12,10 +12,6 @@ ACTION=="add", SUBSYSTEM=="usb", ATTR{product}=="QEMU USB Mouse", ATTR{serial}!= 58 - ACTION=="add", SUBSYSTEM=="usb", ATTR{product}=="QEMU USB Tablet", ATTR{serial}!="1", TEST=="power/control", ATTR{power/control}="auto" 59 - ACTION=="add", SUBSYSTEM=="usb", ATTR{product}=="QEMU USB Keyboard", ATTR{serial}!="1", TEST=="power/control", ATTR{power/control}="auto" 60 - 61 - -# Catch-all for Avocent HID devices. Keyed off interface in order to only 62 - -# trigger on HID class devices. 63 - -ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0624", ATTR{bInterfaceClass}=="03", TEST=="../power/control", ATTR{../power/control}="auto" 64 - - 65 - # Dell DRAC 4 66 - ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="413c", ATTR{idProduct}=="2500", TEST=="power/control", ATTR{power/control}="auto" 67 - 68 1 diff --git a/rules/99-systemd.rules.in b/rules/99-systemd.rules.in 69 - index db72373..2875958 100644 2 + index aa435c4..46a2cd4 100644 70 3 --- a/rules/99-systemd.rules.in 71 4 +++ b/rules/99-systemd.rules.in 72 5 @@ -14,10 +14,6 @@ KERNEL=="vport*", TAG+="systemd" ··· 80 13 # Ignore raid devices that are not yet assembled and started 81 14 SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="md*", TEST!="md/array_state", ENV{SYSTEMD_READY}="0" 82 15 SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="md*", ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0" 83 - @@ -43,7 +39,7 @@ SUBSYSTEM=="net", KERNEL!="lo", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsys 84 - SUBSYSTEM=="bluetooth", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsystem/bluetooth/devices/%k" 85 - 86 - SUBSYSTEM=="bluetooth", TAG+="systemd", ENV{SYSTEMD_WANTS}+="bluetooth.target" 87 - -ENV{ID_SMARTCARD_READER}=="*?", TAG+="systemd", ENV{SYSTEMD_WANTS}+="smartcard.target" 88 - +ENV{ID_SMARTCARD_READER}=="?*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="smartcard.target" 89 - SUBSYSTEM=="sound", KERNEL=="card*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="sound.target" 90 - 91 - SUBSYSTEM=="printer", TAG+="systemd", ENV{SYSTEMD_WANTS}+="printer.target" 92 - diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c 93 - index b8e275d..1840594 100644 94 - --- a/src/cgls/cgls.c 95 - +++ b/src/cgls/cgls.c 96 - @@ -35,6 +35,10 @@ 97 - #include "build.h" 98 - #include "output-mode.h" 99 - #include "fileio.h" 100 - +#include "sd-bus.h" 101 - +#include "bus-util.h" 102 - +#include "bus-error.h" 103 - +#include "unit-name.h" 104 - 105 - static bool arg_no_pager = false; 106 - static bool arg_kernel_threads = false; 107 - @@ -127,6 +131,7 @@ int main(int argc, char *argv[]) { 108 - int r = 0, retval = EXIT_FAILURE; 109 - int output_flags; 110 - char _cleanup_free_ *root = NULL; 111 - + _cleanup_bus_unref_ sd_bus *bus = NULL; 112 - 113 - log_parse_environment(); 114 - log_open(); 115 - @@ -151,6 +156,12 @@ int main(int argc, char *argv[]) { 116 - arg_all * OUTPUT_SHOW_ALL | 117 - (arg_full > 0) * OUTPUT_FULL_WIDTH; 118 - 119 - + r = bus_open_transport(BUS_TRANSPORT_LOCAL, NULL, false, &bus); 120 - + if (r < 0) { 121 - + log_error("Failed to create bus connection: %s", strerror(-r)); 122 - + goto finish; 123 - + } 124 - + 125 - if (optind < argc) { 126 - int i; 127 - 128 - @@ -189,8 +200,52 @@ int main(int argc, char *argv[]) { 129 - } else { 130 - if (arg_machine) { 131 - char *m; 132 - + const char *cgroup; 133 - + _cleanup_free_ char *scope = NULL; 134 - + _cleanup_free_ char *path = NULL; 135 - + _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; 136 - + _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; 137 - + 138 - m = strappenda("/run/systemd/machines/", arg_machine); 139 - - r = parse_env_file(m, NEWLINE, "CGROUP", &root, NULL); 140 - + r = parse_env_file(m, NEWLINE, "SCOPE", &scope, NULL); 141 - + if (r < 0) { 142 - + log_error("Failed to get machine path: %s", strerror(-r)); 143 - + goto finish; 144 - + } 145 - + 146 - + path = unit_dbus_path_from_name(scope); 147 - + if (!path) { 148 - + r = log_oom(); 149 - + goto finish; 150 - + } 151 - + 152 - + r = sd_bus_get_property( 153 - + bus, 154 - + "org.freedesktop.systemd1", 155 - + path, 156 - + "org.freedesktop.systemd1.Scope", 157 - + "ControlGroup", 158 - + &error, 159 - + &reply, 160 - + "s"); 161 - + 162 - + if (r < 0) { 163 - + log_error("Failed to query ControlGroup: %s", bus_error_message(&error, -r)); 164 - + goto finish; 165 - + } 166 - + 167 - + r = sd_bus_message_read(reply, "s", &cgroup); 168 - + if (r < 0) { 169 - + bus_log_parse_error(r); 170 - + goto finish; 171 - + } 172 - + 173 - + root = strdup(cgroup); 174 - + if (!root) { 175 - + r = log_oom(); 176 - + goto finish; 177 - + } 178 - + 179 - } else 180 - r = cg_get_root_path(&root); 181 - if (r < 0) { 182 - diff --git a/src/core/cgroup.c b/src/core/cgroup.c 183 - index 3dd4c91..4201e1e 100644 184 - --- a/src/core/cgroup.c 185 - +++ b/src/core/cgroup.c 186 - @@ -871,7 +871,7 @@ int manager_setup_cgroup(Manager *m) { 187 - safe_close(m->pin_cgroupfs_fd); 188 - 189 - m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK); 190 - - if (r < 0) { 191 - + if (m->pin_cgroupfs_fd < 0) { 192 - log_error("Failed to open pin file: %m"); 193 - return -errno; 194 - } 195 - diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c 196 - index 775825b..5b1c4e3 100644 197 - --- a/src/core/dbus-cgroup.c 198 - +++ b/src/core/dbus-cgroup.c 199 - @@ -173,6 +173,7 @@ int bus_cgroup_set_property( 200 - 201 - if (mode != UNIT_CHECK) { 202 - c->cpu_accounting = b; 203 - + u->cgroup_realized_mask &= ~CGROUP_CPUACCT; 204 - unit_write_drop_in_private(u, mode, name, b ? "CPUAccounting=yes" : "CPUAccounting=no"); 205 - } 206 - 207 - @@ -192,6 +193,7 @@ int bus_cgroup_set_property( 208 - 209 - if (mode != UNIT_CHECK) { 210 - c->cpu_shares = ul; 211 - + u->cgroup_realized_mask &= ~CGROUP_CPU; 212 - unit_write_drop_in_private_format(u, mode, name, "CPUShares=%lu", ul); 213 - } 214 - 215 - @@ -206,6 +208,7 @@ int bus_cgroup_set_property( 216 - 217 - if (mode != UNIT_CHECK) { 218 - c->blockio_accounting = b; 219 - + u->cgroup_realized_mask &= ~CGROUP_BLKIO; 220 - unit_write_drop_in_private(u, mode, name, b ? "BlockIOAccounting=yes" : "BlockIOAccounting=no"); 221 - } 222 - 223 - @@ -225,6 +228,7 @@ int bus_cgroup_set_property( 224 - 225 - if (mode != UNIT_CHECK) { 226 - c->blockio_weight = ul; 227 - + u->cgroup_realized_mask &= ~CGROUP_BLKIO; 228 - unit_write_drop_in_private_format(u, mode, name, "BlockIOWeight=%lu", ul); 229 - } 230 - 231 - @@ -294,6 +298,8 @@ int bus_cgroup_set_property( 232 - cgroup_context_free_blockio_device_bandwidth(c, a); 233 - } 234 - 235 - + u->cgroup_realized_mask &= ~CGROUP_BLKIO; 236 - + 237 - f = open_memstream(&buf, &size); 238 - if (!f) 239 - return -ENOMEM; 240 - @@ -375,6 +381,8 @@ int bus_cgroup_set_property( 241 - cgroup_context_free_blockio_device_weight(c, c->blockio_device_weights); 242 - } 243 - 244 - + u->cgroup_realized_mask &= ~CGROUP_BLKIO; 245 - + 246 - f = open_memstream(&buf, &size); 247 - if (!f) 248 - return -ENOMEM; 249 - @@ -398,6 +406,7 @@ int bus_cgroup_set_property( 250 - 251 - if (mode != UNIT_CHECK) { 252 - c->memory_accounting = b; 253 - + u->cgroup_realized_mask &= ~CGROUP_MEMORY; 254 - unit_write_drop_in_private(u, mode, name, b ? "MemoryAccounting=yes" : "MemoryAccounting=no"); 255 - } 256 - 257 - @@ -412,6 +421,7 @@ int bus_cgroup_set_property( 258 - 259 - if (mode != UNIT_CHECK) { 260 - c->memory_limit = limit; 261 - + u->cgroup_realized_mask &= ~CGROUP_MEMORY; 262 - unit_write_drop_in_private_format(u, mode, name, "%s=%" PRIu64, name, limit); 263 - } 264 - 265 - @@ -433,6 +443,7 @@ int bus_cgroup_set_property( 266 - char *buf; 267 - 268 - c->device_policy = p; 269 - + u->cgroup_realized_mask &= ~CGROUP_DEVICE; 270 - 271 - buf = strappenda("DevicePolicy=", policy); 272 - unit_write_drop_in_private(u, mode, name, buf); 273 - @@ -511,6 +522,8 @@ int bus_cgroup_set_property( 274 - cgroup_context_free_device_allow(c, c->device_allow); 275 - } 276 - 277 - + u->cgroup_realized_mask &= ~CGROUP_DEVICE; 278 - + 279 - f = open_memstream(&buf, &size); 280 - if (!f) 281 - return -ENOMEM; 282 - diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c 283 - index 13b3d0d..37d4154 100644 284 - --- a/src/core/dbus-execute.c 285 - +++ b/src/core/dbus-execute.c 286 - @@ -842,7 +842,7 @@ int bus_exec_context_set_transient_property( 287 - strv_free(c->environment); 288 - c->environment = e; 289 - 290 - - joined = strv_join(c->environment, " "); 291 - + joined = strv_join_quoted(c->environment); 292 - if (!joined) 293 - return -ENOMEM; 294 - 295 - diff --git a/src/core/job.c b/src/core/job.c 296 - index 35a9de6..dc4f441 100644 297 - --- a/src/core/job.c 298 - +++ b/src/core/job.c 299 - @@ -1060,6 +1060,9 @@ int job_coldplug(Job *j) { 300 - if (r < 0) 301 - return r; 302 - 303 - + if (j->state == JOB_WAITING) 304 - + job_add_to_run_queue(j); 305 - + 306 - if (j->begin_usec == 0 || j->unit->job_timeout == 0) 307 - return 0; 308 - 309 - diff --git a/src/core/killall.c b/src/core/killall.c 310 - index 57ed41c..eab48f7 100644 311 - --- a/src/core/killall.c 312 - +++ b/src/core/killall.c 313 - @@ -168,7 +168,7 @@ static int killall(int sig, Set *pids, bool send_sighup) { 314 - continue; 315 - 316 - if (sig == SIGKILL) { 317 - - _cleanup_free_ char *s; 318 - + _cleanup_free_ char *s = NULL; 319 - 320 - get_process_comm(pid, &s); 321 - log_notice("Sending SIGKILL to PID "PID_FMT" (%s).", pid, strna(s)); 322 - diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c 323 - index d459afe..2a58e48 100644 324 - --- a/src/core/machine-id-setup.c 325 - +++ b/src/core/machine-id-setup.c 326 - @@ -93,32 +93,9 @@ static int generate(char id[34], const char *root) { 327 - } 328 - } 329 - 330 - - /* If that didn't work, see if we are running in qemu/kvm and a 331 - - * machine ID was passed in via -uuid on the qemu/kvm command 332 - - * line */ 333 - - 334 - - r = detect_vm(&vm_id); 335 - - if (r > 0 && streq(vm_id, "kvm")) { 336 - - char uuid[37]; 337 - - 338 - - fd = open("/sys/class/dmi/id/product_uuid", O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW); 339 - - if (fd >= 0) { 340 - - k = loop_read(fd, uuid, 36, false); 341 - - safe_close(fd); 342 - - 343 - - if (k >= 36) { 344 - - r = shorten_uuid(id, uuid); 345 - - if (r >= 0) { 346 - - log_info("Initializing machine ID from KVM UUID."); 347 - - return 0; 348 - - } 349 - - } 350 - - } 351 - - } 352 - - 353 - - /* If that didn't work either, see if we are running in a 354 - - * container, and a machine ID was passed in via 355 - - * $container_uuid the way libvirt/LXC does it */ 356 - + /* If that didn't work, see if we are running in a container, 357 - + * and a machine ID was passed in via $container_uuid the way 358 - + * libvirt/LXC does it */ 359 - r = detect_container(NULL); 360 - if (r > 0) { 361 - _cleanup_free_ char *e = NULL; 362 - @@ -133,6 +110,30 @@ static int generate(char id[34], const char *root) { 363 - } 364 - } 365 - } 366 - + 367 - + } else { 368 - + /* If we are not running in a container, see if we are 369 - + * running in qemu/kvm and a machine ID was passed in 370 - + * via -uuid on the qemu/kvm command line */ 371 - + 372 - + r = detect_vm(&vm_id); 373 - + if (r > 0 && streq(vm_id, "kvm")) { 374 - + char uuid[37]; 375 - + 376 - + fd = open("/sys/class/dmi/id/product_uuid", O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW); 377 - + if (fd >= 0) { 378 - + k = loop_read(fd, uuid, 36, false); 379 - + safe_close(fd); 380 - + 381 - + if (k >= 36) { 382 - + r = shorten_uuid(id, uuid); 383 - + if (r >= 0) { 384 - + log_info("Initializing machine ID from KVM UUID."); 385 - + return 0; 386 - + } 387 - + } 388 - + } 389 - + } 390 - } 391 - 392 - /* If that didn't work, generate a random machine id */ 393 - diff --git a/src/core/main.c b/src/core/main.c 394 - index 41605ee..c65701d 100644 395 - --- a/src/core/main.c 396 - +++ b/src/core/main.c 397 - @@ -1840,6 +1840,7 @@ finish: 398 - if (reexecute) { 399 - const char **args; 400 - unsigned i, args_size; 401 - + sigset_t ss; 402 - 403 - /* Close and disarm the watchdog, so that the new 404 - * instance can reinitialize it, but doesn't get 405 - @@ -1883,7 +1884,7 @@ finish: 406 - char_array_0(sfd); 407 - 408 - i = 0; 409 - - args[i++] = SYSTEMD_BINARY_PATH; 410 - + args[i++] = "/run/current-system/systemd/lib/systemd/systemd"; 411 - if (switch_root_dir) 412 - args[i++] = "--switched-root"; 413 - args[i++] = arg_running_as == SYSTEMD_SYSTEM ? "--system" : "--user"; 414 - @@ -1923,6 +1924,13 @@ finish: 415 - args[i++] = NULL; 416 - assert(i <= args_size); 417 - 418 - + /* reenable any blocked signals, especially important 419 - + * if we switch from initial ramdisk to init=... */ 420 - + reset_all_signal_handlers(); 421 - + 422 - + assert_se(sigemptyset(&ss) == 0); 423 - + assert_se(sigprocmask(SIG_SETMASK, &ss, NULL) == 0); 424 - + 425 - if (switch_root_init) { 426 - args[0] = switch_root_init; 427 - execv(args[0], (char* const*) args); 428 - diff --git a/src/core/manager.c b/src/core/manager.c 429 - index 224106c..7342095 100644 430 - --- a/src/core/manager.c 431 - +++ b/src/core/manager.c 432 - @@ -422,7 +422,7 @@ int manager_new(SystemdRunningAs running_as, Manager **_m) { 433 - return -ENOMEM; 434 - 435 - #ifdef ENABLE_EFI 436 - - if (detect_container(NULL) <= 0) 437 - + if (running_as == SYSTEMD_SYSTEM && detect_container(NULL) <= 0) 438 - boot_timestamps(&m->userspace_timestamp, &m->firmware_timestamp, &m->loader_timestamp); 439 - #endif 440 - 441 - @@ -2129,9 +2129,6 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root) { 442 - if (u->id != t) 443 - continue; 444 - 445 - - if (!unit_can_serialize(u)) 446 - - continue; 447 - - 448 - /* Start marker */ 449 - fputs(u->id, f); 450 - fputc('\n', f); 451 - diff --git a/src/core/namespace.c b/src/core/namespace.c 452 - index 9f15211..e41cf5b 100644 453 - --- a/src/core/namespace.c 454 - +++ b/src/core/namespace.c 455 - @@ -42,6 +42,7 @@ 456 - #include "mkdir.h" 457 - #include "dev-setup.h" 458 - #include "def.h" 459 - +#include "label.h" 460 - 461 - typedef enum MountMode { 462 - /* This is ordered by priority! */ 463 - @@ -68,6 +69,7 @@ static int append_mounts(BindMount **p, char **strv, MountMode mode) { 464 - STRV_FOREACH(i, strv) { 465 - 466 - (*p)->ignore = false; 467 - + (*p)->done = false; 468 - 469 - if ((mode == INACCESSIBLE || mode == READONLY || mode == READWRITE) && (*i)[0] == '-') { 470 - (*p)->ignore = true; 471 - @@ -217,7 +219,10 @@ static int mount_dev(BindMount *m) { 472 - goto fail; 473 - } 474 - 475 - + label_context_set(d, st.st_mode); 476 - r = mknod(dn, st.st_mode, st.st_rdev); 477 - + label_context_clear(); 478 - + 479 - if (r < 0) { 480 - r = -errno; 481 - goto fail; 482 - @@ -350,7 +355,7 @@ int setup_namespace( 483 - private_dev; 484 - 485 - if (n > 0) { 486 - - m = mounts = (BindMount *) alloca(n * sizeof(BindMount)); 487 - + m = mounts = (BindMount *) alloca0(n * sizeof(BindMount)); 488 - r = append_mounts(&m, read_write_dirs, READWRITE); 489 - if (r < 0) 490 - return r; 491 - diff --git a/src/core/service.c b/src/core/service.c 492 - index ae3695a..6b3aa45 100644 493 - --- a/src/core/service.c 494 - +++ b/src/core/service.c 495 - @@ -1096,11 +1096,6 @@ static int service_verify(Service *s) { 496 - return -EINVAL; 497 - } 498 - 499 - - if (s->type == SERVICE_ONESHOT && s->restart != SERVICE_RESTART_NO) { 500 - - log_error_unit(UNIT(s)->id, "%s has Restart setting other than no, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id); 501 - - return -EINVAL; 502 - - } 503 - - 504 - if (s->type == SERVICE_DBUS && !s->bus_name) { 505 - log_error_unit(UNIT(s)->id, "%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", UNIT(s)->id); 506 - return -EINVAL; 507 - diff --git a/src/core/socket.c b/src/core/socket.c 508 - index 7c18a2b..1a560a6 100644 509 - --- a/src/core/socket.c 510 - +++ b/src/core/socket.c 511 - @@ -663,16 +663,25 @@ static int instance_from_socket(int fd, unsigned nr, char **instance) { 512 - int k; 513 - 514 - k = getpeercred(fd, &ucred); 515 - - if (k < 0) 516 - + if (k == -ENODATA) { 517 - + /* This handles the case where somebody is 518 - + * connecting from another pid/uid namespace 519 - + * (e.g. from outside of our container). */ 520 - + if (asprintf(&r, 521 - + "%u-unknown", 522 - + nr) < 0) 523 - + return -ENOMEM; 524 - + } 525 - + else if (k < 0) 526 - return k; 527 - - 528 - - if (asprintf(&r, 529 - - "%u-%lu-%lu", 530 - - nr, 531 - - (unsigned long) ucred.pid, 532 - - (unsigned long) ucred.uid) < 0) 533 - - return -ENOMEM; 534 - - 535 - + else { 536 - + if (asprintf(&r, 537 - + "%u-%lu-%lu", 538 - + nr, 539 - + (unsigned long) ucred.pid, 540 - + (unsigned long) ucred.uid) < 0) 541 - + return -ENOMEM; 542 - + } 543 - break; 544 - } 545 - 546 - @@ -1242,6 +1251,8 @@ static int socket_spawn(Socket *s, ExecCommand *c, pid_t *_pid) { 547 - NULL, 548 - s->exec_runtime, 549 - &pid); 550 - + if (r < 0) 551 - + goto fail; 552 - 553 - strv_free(argv); 554 - if (r < 0) 555 - @@ -1497,6 +1508,12 @@ static void socket_enter_running(Socket *s, int cfd) { 556 - } 557 - 558 - if (!pending) { 559 - + if (!UNIT_ISSET(s->service)) { 560 - + log_error_unit(UNIT(s)->id, "%s: service to activate vanished, refusing activation.", UNIT(s)->id); 561 - + r = -ENOENT; 562 - + goto fail; 563 - + } 564 - + 565 - r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT_DEREF(s->service), JOB_REPLACE, true, &error, NULL); 566 - if (r < 0) 567 - goto fail; 568 - diff --git a/src/core/timer.c b/src/core/timer.c 569 - index 6c85304..720b8af 100644 570 - --- a/src/core/timer.c 571 - +++ b/src/core/timer.c 572 - @@ -111,6 +111,23 @@ static int timer_add_default_dependencies(Timer *t) { 573 - return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true); 574 - } 575 - 576 - +static void update_stampfile(Timer *t, usec_t timestamp) { 577 - + _cleanup_close_ int fd = -1; 578 - + 579 - + mkdir_parents_label(t->stamp_path, 0755); 580 - + 581 - + /* Update the file atime + mtime, if we can */ 582 - + fd = open(t->stamp_path, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0644); 583 - + if (fd >= 0) { 584 - + struct timespec ts[2]; 585 - + 586 - + timespec_store(&ts[0], timestamp); 587 - + ts[1] = ts[0]; 588 - + 589 - + futimens(fd, ts); 590 - + } 591 - +} 592 - + 593 - static int timer_setup_persistent(Timer *t) { 594 - int r; 595 - 596 - @@ -131,7 +148,7 @@ static int timer_setup_persistent(Timer *t) { 597 - 598 - e = getenv("XDG_DATA_HOME"); 599 - if (e) 600 - - t->stamp_path = strjoin(e, "/systemd/timers/", UNIT(t)->id, NULL); 601 - + t->stamp_path = strjoin(e, "/systemd/timers/stamp-", UNIT(t)->id, NULL); 602 - else { 603 - 604 - _cleanup_free_ char *h = NULL; 605 - @@ -496,22 +513,8 @@ static void timer_enter_running(Timer *t) { 606 - 607 - dual_timestamp_get(&t->last_trigger); 608 - 609 - - if (t->stamp_path) { 610 - - _cleanup_close_ int fd = -1; 611 - - 612 - - mkdir_parents_label(t->stamp_path, 0755); 613 - - 614 - - /* Update the file atime + mtime, if we can */ 615 - - fd = open(t->stamp_path, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0644); 616 - - if (fd >= 0) { 617 - - struct timespec ts[2]; 618 - - 619 - - timespec_store(&ts[0], t->last_trigger.realtime); 620 - - ts[1] = ts[0]; 621 - - 622 - - futimens(fd, ts); 623 - - } 624 - - } 625 - + if (t->stamp_path) 626 - + update_stampfile(t, t->last_trigger.realtime); 627 - 628 - timer_set_state(t, TIMER_RUNNING); 629 - return; 630 - @@ -539,6 +542,11 @@ static int timer_start(Unit *u) { 631 - 632 - if (stat(t->stamp_path, &st) >= 0) 633 - t->last_trigger.realtime = timespec_load(&st.st_atim); 634 - + else if (errno == ENOENT) 635 - + /* The timer has never run before, 636 - + * make sure a stamp file exists. 637 - + */ 638 - + update_stampfile(t, now(CLOCK_REALTIME)); 639 - } 640 - 641 - t->result = TIMER_SUCCESS; 642 - diff --git a/src/core/transaction.c b/src/core/transaction.c 643 - index d00f427..2befc32 100644 644 - --- a/src/core/transaction.c 645 - +++ b/src/core/transaction.c 646 - @@ -378,7 +378,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi 647 - "Found dependency on %s/%s", 648 - k->unit->id, job_type_to_string(k->type)); 649 - 650 - - if (!delete && 651 - + if (!delete && hashmap_get(tr->jobs, k->unit) && 652 - !unit_matters_to_anchor(k->unit, k)) { 653 - /* Ok, we can drop this one, so let's 654 - * do so. */ 655 16 diff --git a/src/core/umount.c b/src/core/umount.c 656 - index d1258f0..0311812 100644 17 + index cffa453..4d1a9ff 100644 657 18 --- a/src/core/umount.c 658 19 +++ b/src/core/umount.c 659 - @@ -404,6 +404,8 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, bool log_e 20 + @@ -385,6 +385,8 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, bool log_e 660 21 * anyway, since we are running from it. They have 661 22 * already been remounted ro. */ 662 23 if (path_equal(m->path, "/") ··· 665 26 #ifndef HAVE_SPLIT_USR 666 27 || path_equal(m->path, "/usr") 667 28 #endif 668 - diff --git a/src/core/unit.c b/src/core/unit.c 669 - index 153b79b..ed52694 100644 670 - --- a/src/core/unit.c 671 - +++ b/src/core/unit.c 672 - @@ -2287,25 +2287,25 @@ bool unit_can_serialize(Unit *u) { 673 - } 674 - 675 - int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) { 676 - - ExecRuntime *rt; 677 - int r; 678 - 679 - assert(u); 680 - assert(f); 681 - assert(fds); 682 - 683 - - if (!unit_can_serialize(u)) 684 - - return 0; 685 - - 686 - - r = UNIT_VTABLE(u)->serialize(u, f, fds); 687 - - if (r < 0) 688 - - return r; 689 - + if (unit_can_serialize(u)) { 690 - + ExecRuntime *rt; 691 - 692 - - rt = unit_get_exec_runtime(u); 693 - - if (rt) { 694 - - r = exec_runtime_serialize(rt, u, f, fds); 695 - + r = UNIT_VTABLE(u)->serialize(u, f, fds); 696 - if (r < 0) 697 - return r; 698 - + 699 - + rt = unit_get_exec_runtime(u); 700 - + if (rt) { 701 - + r = exec_runtime_serialize(rt, u, f, fds); 702 - + if (r < 0) 703 - + return r; 704 - + } 705 - } 706 - 707 - dual_timestamp_serialize(f, "inactive-exit-timestamp", &u->inactive_exit_timestamp); 708 - @@ -2367,17 +2367,14 @@ void unit_serialize_item(Unit *u, FILE *f, const char *key, const char *value) { 709 - } 710 - 711 - int unit_deserialize(Unit *u, FILE *f, FDSet *fds) { 712 - - size_t offset; 713 - ExecRuntime **rt = NULL; 714 - + size_t offset; 715 - int r; 716 - 717 - assert(u); 718 - assert(f); 719 - assert(fds); 720 - 721 - - if (!unit_can_serialize(u)) 722 - - return 0; 723 - - 724 - offset = UNIT_VTABLE(u)->exec_runtime_offset; 725 - if (offset > 0) 726 - rt = (ExecRuntime**) ((uint8_t*) u + offset); 727 - @@ -2487,24 +2484,34 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) { 728 - if (!s) 729 - return -ENOMEM; 730 - 731 - - free(u->cgroup_path); 732 - - u->cgroup_path = s; 733 - + if (u->cgroup_path) { 734 - + void *p; 735 - 736 - + p = hashmap_remove(u->manager->cgroup_unit, u->cgroup_path); 737 - + log_info("Removing cgroup_path %s from hashmap (%p)", 738 - + u->cgroup_path, p); 739 - + free(u->cgroup_path); 740 - + } 741 - + 742 - + u->cgroup_path = s; 743 - assert(hashmap_put(u->manager->cgroup_unit, s, u) == 1); 744 - + 745 - continue; 746 - } 747 - 748 - - if (rt) { 749 - - r = exec_runtime_deserialize_item(rt, u, l, v, fds); 750 - + if (unit_can_serialize(u)) { 751 - + if (rt) { 752 - + r = exec_runtime_deserialize_item(rt, u, l, v, fds); 753 - + if (r < 0) 754 - + return r; 755 - + if (r > 0) 756 - + continue; 757 - + } 758 - + 759 - + r = UNIT_VTABLE(u)->deserialize_item(u, l, v, fds); 760 - if (r < 0) 761 - return r; 762 - - if (r > 0) 763 - - continue; 764 - } 765 - - 766 - - r = UNIT_VTABLE(u)->deserialize_item(u, l, v, fds); 767 - - if (r < 0) 768 - - return r; 769 - } 770 - } 771 - 772 - diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c 773 - index 75d56dd..be8fb2f 100644 774 - --- a/src/cryptsetup/cryptsetup-generator.c 775 - +++ b/src/cryptsetup/cryptsetup-generator.c 776 - @@ -29,6 +29,7 @@ 777 - #include "mkdir.h" 778 - #include "strv.h" 779 - #include "fileio.h" 780 - +#include "path-util.h" 781 - 782 - static const char *arg_dest = "/tmp"; 783 - static bool arg_enabled = true; 784 - @@ -144,16 +145,19 @@ static int create_disk( 785 - if (!uu) 786 - return log_oom(); 787 - 788 - - if (is_device_path(uu)) { 789 - - _cleanup_free_ char *dd; 790 - + if (!path_equal(uu, "/dev/null")) { 791 - 792 - - dd = unit_name_from_path(uu, ".device"); 793 - - if (!dd) 794 - - return log_oom(); 795 - + if (is_device_path(uu)) { 796 - + _cleanup_free_ char *dd; 797 - 798 - - fprintf(f, "After=%1$s\nRequires=%1$s\n", dd); 799 - - } else 800 - - fprintf(f, "RequiresMountsFor=%s\n", password); 801 - + dd = unit_name_from_path(uu, ".device"); 802 - + if (!dd) 803 - + return log_oom(); 804 - + 805 - + fprintf(f, "After=%1$s\nRequires=%1$s\n", dd); 806 - + } else 807 - + fprintf(f, "RequiresMountsFor=%s\n", password); 808 - + } 809 - } 810 - } 811 - 812 - @@ -287,7 +291,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { 813 - } else if (STR_IN_SET(key, "luks.key", "rd.luks.key") && value) { 814 - 815 - free(arg_keyfile); 816 - - arg_keyfile = strdup(key); 817 - + arg_keyfile = strdup(value); 818 - if (!arg_keyfile) 819 - return log_oom(); 820 - 821 - diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c 822 - index 9b9074c..ad6c76c 100644 823 - --- a/src/cryptsetup/cryptsetup.c 824 - +++ b/src/cryptsetup/cryptsetup.c 825 - @@ -88,6 +88,13 @@ static int parse_one_option(const char *option) { 826 - return 0; 827 - } 828 - 829 - + if (arg_key_size % 8) { 830 - + log_error("size= not a multiple of 8, ignoring."); 831 - + return 0; 832 - + } 833 - + 834 - + arg_key_size /= 8; 835 - + 836 - } else if (startswith(option, "key-slot=")) { 837 - 838 - arg_type = CRYPT_LUKS1; 839 - @@ -404,7 +411,7 @@ static int attach_luks_or_plain(struct crypt_device *cd, 840 - /* for CRYPT_PLAIN limit reads 841 - * from keyfile to key length, and 842 - * ignore keyfile-size */ 843 - - arg_keyfile_size = arg_key_size / 8; 844 - + arg_keyfile_size = arg_key_size; 845 - 846 - /* In contrast to what the name 847 - * crypt_setup() might suggest this 848 - @@ -567,7 +574,7 @@ int main(int argc, char *argv[]) { 849 - else 850 - until = 0; 851 - 852 - - arg_key_size = (arg_key_size > 0 ? arg_key_size : 256); 853 - + arg_key_size = (arg_key_size > 0 ? arg_key_size : (256 / 8)); 854 - 855 - if (key_file) { 856 - struct stat st; 857 29 diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c 858 - index 18f2aca..2a2b1ea 100644 30 + index dfe97bc..71cd8f4 100644 859 31 --- a/src/fsck/fsck.c 860 32 +++ b/src/fsck/fsck.c 861 - @@ -285,7 +285,7 @@ int main(int argc, char *argv[]) { 862 - 863 - type = udev_device_get_property_value(udev_device, "ID_FS_TYPE"); 864 - if (type) { 865 - - const char *checker = strappenda("/sbin/fsck.", type); 866 - + const char *checker = strappenda("/run/current-system/sw/sbin/fsck.", type); 867 - r = access(checker, X_OK); 868 - if (r < 0) { 869 - if (errno == ENOENT) { 870 - @@ -302,7 +302,7 @@ int main(int argc, char *argv[]) { 33 + @@ -315,8 +315,7 @@ int main(int argc, char *argv[]) { 871 34 return EXIT_FAILURE; 872 35 } 873 36 874 37 - cmdline[i++] = "/sbin/fsck"; 38 + - cmdline[i++] = arg_repair; 875 39 + cmdline[i++] = "/run/current-system/sw/sbin/fsck"; 876 - cmdline[i++] = "-a"; 877 40 cmdline[i++] = "-T"; 878 - cmdline[i++] = "-l"; 879 - diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c 880 - index 6a4aa2c..700e90a 100644 881 - --- a/src/getty-generator/getty-generator.c 882 - +++ b/src/getty-generator/getty-generator.c 883 - @@ -72,7 +72,7 @@ static int add_serial_getty(const char *tty) { 884 41 885 - log_debug("Automatically adding serial getty for /dev/%s.", tty); 886 - 887 - - n = unit_name_replace_instance("serial-getty@.service", tty); 888 - + n = unit_name_from_path_instance("serial-getty", tty, ".service"); 889 - if (!n) 890 - return log_oom(); 891 - 892 - @@ -86,7 +86,7 @@ static int add_container_getty(const char *tty) { 893 - 894 - log_debug("Automatically adding container getty for /dev/pts/%s.", tty); 895 - 896 - - n = unit_name_replace_instance("container-getty@.service", tty); 897 - + n = unit_name_from_path_instance("container-getty", tty, ".service"); 898 - if (!n) 899 - return log_oom(); 900 - 901 - diff --git a/src/journal/catalog.c b/src/journal/catalog.c 902 - index 3ed0b7e..02dedc4 100644 903 - --- a/src/journal/catalog.c 904 - +++ b/src/journal/catalog.c 905 - @@ -103,7 +103,7 @@ static int finish_item( 906 - const char *payload) { 907 - 908 - ssize_t offset; 909 - - CatalogItem *i; 910 - + _cleanup_free_ CatalogItem *i = NULL; 911 - int r; 912 - 913 - assert(h); 914 - @@ -126,13 +126,14 @@ static int finish_item( 915 - i->offset = htole64((uint64_t) offset); 916 - 917 - r = hashmap_put(h, i, i); 918 - - if (r == EEXIST) { 919 - + if (r == -EEXIST) { 920 - log_warning("Duplicate entry for " SD_ID128_FORMAT_STR ".%s, ignoring.", 921 - SD_ID128_FORMAT_VAL(id), language ? language : "C"); 922 - - free(i); 923 - return 0; 924 - - } 925 - + } else if (r < 0) 926 - + return r; 927 - 928 - + i = NULL; 929 - return 0; 930 - } 931 - 932 - @@ -383,8 +384,8 @@ error: 933 - int catalog_update(const char* database, const char* root, const char* const* dirs) { 934 - _cleanup_strv_free_ char **files = NULL; 935 - char **f; 936 - - Hashmap *h; 937 - struct strbuf *sb = NULL; 938 - + _cleanup_hashmap_free_free_ Hashmap *h = NULL; 939 - _cleanup_free_ CatalogItem *items = NULL; 940 - CatalogItem *i; 941 - Iterator j; 942 - @@ -406,13 +407,17 @@ int catalog_update(const char* database, const char* root, const char* const* di 943 - } 944 - 945 - STRV_FOREACH(f, files) { 946 - - log_debug("reading file '%s'", *f); 947 - - catalog_import_file(h, sb, *f); 948 - + log_debug("Reading file '%s'", *f); 949 - + r = catalog_import_file(h, sb, *f); 950 - + if (r < 0) { 951 - + log_error("Failed to import file '%s': %s.", 952 - + *f, strerror(-r)); 953 - + goto finish; 954 - + } 955 - } 956 - 957 - if (hashmap_size(h) <= 0) { 958 - log_info("No items in catalog."); 959 - - r = 0; 960 - goto finish; 961 - } else 962 - log_debug("Found %u items in catalog.", hashmap_size(h)); 963 - @@ -443,11 +448,7 @@ int catalog_update(const char* database, const char* root, const char* const* di 964 - log_debug("%s: wrote %u items, with %zu bytes of strings, %ld total size.", 965 - database, n, sb->len, r); 966 - 967 - - r = 0; 968 - - 969 - finish: 970 - - if (h) 971 - - hashmap_free_free(h); 972 - if (sb) 973 - strbuf_cleanup(sb); 974 - 975 - diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c 976 - index f2f1f35..fd9d2a8 100644 977 - --- a/src/journal/journal-file.c 978 - +++ b/src/journal/journal-file.c 979 - @@ -274,12 +274,6 @@ static int journal_file_verify_header(JournalFile *f) { 980 - !VALID64(le64toh(f->header->entry_array_offset))) 981 - return -ENODATA; 982 - 983 - - if (le64toh(f->header->data_hash_table_offset) < le64toh(f->header->header_size) || 984 - - le64toh(f->header->field_hash_table_offset) < le64toh(f->header->header_size) || 985 - - le64toh(f->header->tail_object_offset) < le64toh(f->header->header_size) || 986 - - le64toh(f->header->entry_array_offset) < le64toh(f->header->header_size)) 987 - - return -ENODATA; 988 - - 989 - if (f->writable) { 990 - uint8_t state; 991 - sd_id128_t machine_id; 992 - diff --git a/src/journal/journal-remote-parse.c b/src/journal/journal-remote-parse.c 993 - index 142de0e..239ff38 100644 994 - --- a/src/journal/journal-remote-parse.c 995 - +++ b/src/journal/journal-remote-parse.c 996 - @@ -40,7 +40,7 @@ void source_free(RemoteSource *source) { 997 - 998 - static int get_line(RemoteSource *source, char **line, size_t *size) { 999 - ssize_t n, remain; 1000 - - char *c; 1001 - + char *c = NULL; 1002 - char *newbuf = NULL; 1003 - size_t newsize = 0; 1004 - 1005 - @@ -49,7 +49,9 @@ static int get_line(RemoteSource *source, char **line, size_t *size) { 1006 - assert(source->filled <= source->size); 1007 - assert(source->buf == NULL || source->size > 0); 1008 - 1009 - - c = memchr(source->buf, '\n', source->filled); 1010 - + if (source->buf) 1011 - + c = memchr(source->buf, '\n', source->filled); 1012 - + 1013 - if (c != NULL) 1014 - goto docopy; 1015 - 1016 - diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c 1017 - index 35948ea..48725e4 100644 1018 - --- a/src/journal/journald-kmsg.c 1019 - +++ b/src/journal/journald-kmsg.c 1020 - @@ -152,7 +152,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) { 1021 - /* Did we lose any? */ 1022 - if (serial > *s->kernel_seqnum) 1023 - server_driver_message(s, SD_MESSAGE_JOURNAL_MISSED, "Missed %"PRIu64" kernel messages", 1024 - - serial - *s->kernel_seqnum - 1); 1025 - + serial - *s->kernel_seqnum); 1026 - 1027 - /* Make sure we never read this one again. Note that 1028 - * we always store the next message serial we expect 1029 - diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c 1030 - index 6da81e7..b6f8e7e 100644 1031 - --- a/src/journal/journald-server.c 1032 - +++ b/src/journal/journald-server.c 1033 - @@ -67,6 +67,7 @@ 1034 - #define DEFAULT_SYNC_INTERVAL_USEC (5*USEC_PER_MINUTE) 1035 - #define DEFAULT_RATE_LIMIT_INTERVAL (30*USEC_PER_SEC) 1036 - #define DEFAULT_RATE_LIMIT_BURST 1000 1037 - +#define DEFAULT_MAX_FILE_USEC USEC_PER_MONTH 1038 - 1039 - #define RECHECK_AVAILABLE_SPACE_USEC (30*USEC_PER_SEC) 1040 - 1041 - @@ -1473,6 +1474,8 @@ int server_init(Server *s) { 1042 - s->forward_to_syslog = true; 1043 - s->forward_to_wall = true; 1044 - 1045 - + s->max_file_usec = DEFAULT_MAX_FILE_USEC; 1046 - + 1047 - s->max_level_store = LOG_DEBUG; 1048 - s->max_level_syslog = LOG_DEBUG; 1049 - s->max_level_kmsg = LOG_NOTICE; 1050 - diff --git a/src/journal/microhttpd-util.c b/src/journal/microhttpd-util.c 1051 - index f693e0f..9a8d5c6 100644 1052 - --- a/src/journal/microhttpd-util.c 1053 - +++ b/src/journal/microhttpd-util.c 1054 - @@ -129,7 +129,7 @@ void log_func_gnutls(int level, const char *message) { 1055 - if (0 <= level && level < (int) ELEMENTSOF(log_level_map)) 1056 - ourlevel = log_level_map[level]; 1057 - else 1058 - - level = LOG_DEBUG; 1059 - + ourlevel = LOG_DEBUG; 1060 - 1061 - log_meta(ourlevel, NULL, 0, NULL, "gnutls: %s", message); 1062 - } 1063 - diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c 1064 - index b087a8b..967ab67 100644 1065 - --- a/src/journal/test-catalog.c 1066 - +++ b/src/journal/test-catalog.c 1067 - @@ -157,7 +157,8 @@ int main(int argc, char *argv[]) { 1068 - 1069 - setlocale(LC_ALL, "de_DE.UTF-8"); 1070 - 1071 - - log_set_max_level(LOG_DEBUG); 1072 - + log_parse_environment(); 1073 - + log_open(); 1074 - 1075 - test_catalog_file_lang(); 1076 - 1077 - diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c 1078 - index 84a8ffa..e79b318 100644 1079 - --- a/src/libsystemd/sd-rtnl/rtnl-message.c 1080 - +++ b/src/libsystemd/sd-rtnl/rtnl-message.c 1081 - @@ -335,24 +335,28 @@ int sd_rtnl_message_link_get_flags(sd_rtnl_message *m, unsigned *flags) { 1082 - /* If successful the updated message will be correctly aligned, if 1083 - unsuccessful the old message is untouched. */ 1084 - static int add_rtattr(sd_rtnl_message *m, unsigned short type, const void *data, size_t data_length) { 1085 - - uint32_t rta_length, message_length; 1086 - + uint32_t rta_length; 1087 - + size_t message_length, padding_length; 1088 - struct nlmsghdr *new_hdr; 1089 - struct rtattr *rta; 1090 - char *padding; 1091 - unsigned i; 1092 - + int offset; 1093 - 1094 - assert(m); 1095 - assert(m->hdr); 1096 - assert(!m->sealed); 1097 - assert(NLMSG_ALIGN(m->hdr->nlmsg_len) == m->hdr->nlmsg_len); 1098 - - assert(!data || data_length > 0); 1099 - - assert(data || m->n_containers < RTNL_CONTAINER_DEPTH); 1100 - + assert(!data || data_length); 1101 - + 1102 - + /* get offset of the new attribute */ 1103 - + offset = m->hdr->nlmsg_len; 1104 - 1105 - /* get the size of the new rta attribute (with padding at the end) */ 1106 - rta_length = RTA_LENGTH(data_length); 1107 - 1108 - /* get the new message size (with padding at the end) */ 1109 - - message_length = m->hdr->nlmsg_len + RTA_ALIGN(rta_length); 1110 - + message_length = offset + RTA_ALIGN(rta_length); 1111 - 1112 - /* realloc to fit the new attribute */ 1113 - new_hdr = realloc(m->hdr, message_length); 1114 - @@ -361,32 +365,35 @@ static int add_rtattr(sd_rtnl_message *m, unsigned short type, const void *data, 1115 - m->hdr = new_hdr; 1116 - 1117 - /* get pointer to the attribute we are about to add */ 1118 - - rta = (struct rtattr *) ((uint8_t *) m->hdr + m->hdr->nlmsg_len); 1119 - + rta = (struct rtattr *) ((uint8_t *) m->hdr + offset); 1120 - 1121 - /* if we are inside containers, extend them */ 1122 - for (i = 0; i < m->n_containers; i++) 1123 - - GET_CONTAINER(m, i)->rta_len += message_length - m->hdr->nlmsg_len; 1124 - + GET_CONTAINER(m, i)->rta_len += message_length - offset; 1125 - 1126 - /* fill in the attribute */ 1127 - rta->rta_type = type; 1128 - rta->rta_len = rta_length; 1129 - - if (!data) { 1130 - - /* this is the start of a new container */ 1131 - - m->container_offsets[m->n_containers ++] = m->hdr->nlmsg_len; 1132 - - } else { 1133 - + if (data) 1134 - /* we don't deal with the case where the user lies about the type 1135 - * and gives us too little data (so don't do that) 1136 - - */ 1137 - + */ 1138 - padding = mempcpy(RTA_DATA(rta), data, data_length); 1139 - - /* make sure also the padding at the end of the message is initialized */ 1140 - - memzero(padding, 1141 - - (uint8_t *) m->hdr + message_length - (uint8_t *) padding); 1142 - + else { 1143 - + /* if no data was passed, make sure we still initialize the padding 1144 - + note that we can have data_length > 0 (used by some containers) */ 1145 - + padding = RTA_DATA(rta); 1146 - + data_length = 0; 1147 - } 1148 - 1149 - + /* make sure also the padding at the end of the message is initialized */ 1150 - + padding_length = (uint8_t*)m->hdr + message_length - (uint8_t*)padding; 1151 - + memzero(padding, padding_length); 1152 - + 1153 - /* update message size */ 1154 - m->hdr->nlmsg_len = message_length; 1155 - 1156 - - return 0; 1157 - + return offset; 1158 - } 1159 - 1160 - int sd_rtnl_message_append_string(sd_rtnl_message *m, unsigned short type, const char *data) { 1161 - @@ -761,22 +768,29 @@ int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type) { 1162 - 1163 - assert_return(m, -EINVAL); 1164 - assert_return(!m->sealed, -EPERM); 1165 - + assert_return(m->n_containers < RTNL_CONTAINER_DEPTH, -ERANGE); 1166 - 1167 - sd_rtnl_message_get_type(m, &rtm_type); 1168 - 1169 - + int r = -ENOTSUP; 1170 - + 1171 - if (rtnl_message_type_is_link(rtm_type)) { 1172 - 1173 - if ((type == IFLA_LINKINFO && m->n_containers == 0) || 1174 - (type == IFLA_INFO_DATA && m->n_containers == 1 && 1175 - GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO)) 1176 - - return add_rtattr(m, type, NULL, 0); 1177 - + r = add_rtattr(m, type, NULL, 0); 1178 - else if (type == VETH_INFO_PEER && m->n_containers == 2 && 1179 - GET_CONTAINER(m, 1)->rta_type == IFLA_INFO_DATA && 1180 - GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO) 1181 - - return add_rtattr(m, type, NULL, sizeof(struct ifinfomsg)); 1182 - + r= add_rtattr(m, type, NULL, sizeof(struct ifinfomsg)); 1183 - } 1184 - 1185 - - return -ENOTSUP; 1186 - + if (r < 0) return r; 1187 - + 1188 - + m->container_offsets[m->n_containers ++] = r; 1189 - + 1190 - + return 0; 1191 - } 1192 - 1193 - int sd_rtnl_message_close_container(sd_rtnl_message *m) { 1194 - diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c 1195 - index ba1b04d..85b1e40 100644 1196 - --- a/src/libudev/libudev-monitor.c 1197 - +++ b/src/libudev/libudev-monitor.c 1198 - @@ -108,15 +108,13 @@ static struct udev_monitor *udev_monitor_new(struct udev *udev) 1199 - 1200 - /* we consider udev running when /dev is on devtmpfs */ 1201 - static bool udev_has_devtmpfs(struct udev *udev) { 1202 - - struct file_handle *h; 1203 - + union file_handle_union h = { .handle.handle_bytes = MAX_HANDLE_SZ, }; 1204 - int mount_id; 1205 - _cleanup_fclose_ FILE *f = NULL; 1206 - char line[LINE_MAX], *e; 1207 - int r; 1208 - 1209 - - h = alloca(MAX_HANDLE_SZ); 1210 - - h->handle_bytes = MAX_HANDLE_SZ; 1211 - - r = name_to_handle_at(AT_FDCWD, "/dev", h, &mount_id, 0); 1212 - + r = name_to_handle_at(AT_FDCWD, "/dev", &h.handle, &mount_id, 0); 1213 - if (r < 0) 1214 - return false; 1215 - 1216 - diff --git a/src/login/70-uaccess.rules b/src/login/70-uaccess.rules 1217 - index e1cf897..57f619d 100644 1218 - --- a/src/login/70-uaccess.rules 1219 - +++ b/src/login/70-uaccess.rules 1220 - @@ -12,7 +12,7 @@ ENV{MAJOR}=="", GOTO="uaccess_end" 1221 - SUBSYSTEM=="usb", ENV{ID_USB_INTERFACES}=="*:060101:*", TAG+="uaccess" 1222 - 1223 - # Digicams with proprietary protocol 1224 - -ENV{ID_GPHOTO2}=="*?", TAG+="uaccess" 1225 - +ENV{ID_GPHOTO2}=="?*", TAG+="uaccess" 1226 - 1227 - # SCSI and USB scanners 1228 - ENV{libsane_matched}=="yes", TAG+="uaccess" 1229 - @@ -49,13 +49,13 @@ SUBSYSTEM=="drm", KERNEL=="card*|renderD*", TAG+="uaccess" 1230 - SUBSYSTEM=="misc", KERNEL=="kvm", TAG+="uaccess" 1231 - 1232 - # smart-card readers 1233 - -ENV{ID_SMARTCARD_READER}=="*?", TAG+="uaccess" 1234 - +ENV{ID_SMARTCARD_READER}=="?*", TAG+="uaccess" 1235 - 1236 - # (USB) authentication devices 1237 - -ENV{ID_SECURITY_TOKEN}=="*?", TAG+="uaccess" 1238 - +ENV{ID_SECURITY_TOKEN}=="?*", TAG+="uaccess" 1239 - 1240 - # PDA devices 1241 - -ENV{ID_PDA}=="*?", TAG+="uaccess" 1242 - +ENV{ID_PDA}=="?*", TAG+="uaccess" 1243 - 1244 - # Programmable remote control 1245 - ENV{ID_REMOTE_CONTROL}=="1", TAG+="uaccess" 1246 - @@ -64,10 +64,10 @@ ENV{ID_REMOTE_CONTROL}=="1", TAG+="uaccess" 1247 - SUBSYSTEM=="input", ENV{ID_INPUT_JOYSTICK}=="?*", TAG+="uaccess" 1248 - 1249 - # color measurement devices 1250 - -ENV{COLOR_MEASUREMENT_DEVICE}=="*?", TAG+="uaccess" 1251 - +ENV{COLOR_MEASUREMENT_DEVICE}=="?*", TAG+="uaccess" 1252 - 1253 - # DDC/CI device, usually high-end monitors such as the DreamColor 1254 - -ENV{DDC_DEVICE}=="*?", TAG+="uaccess" 1255 - +ENV{DDC_DEVICE}=="?*", TAG+="uaccess" 1256 - 1257 - # media player raw devices (for user-mode drivers, Android SDK, etc.) 1258 - SUBSYSTEM=="usb", ENV{ID_MEDIA_PLAYER}=="?*", TAG+="uaccess" 1259 - diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c 1260 - index dc86f0f..4bbeb64 100644 1261 - --- a/src/login/logind-acl.c 1262 - +++ b/src/login/logind-acl.c 1263 - @@ -279,7 +279,9 @@ int devnode_acl_all(struct udev *udev, 1264 - 1265 - log_debug("Fixing up ACLs at %s for seat %s", n, seat); 1266 - k = devnode_acl(n, flush, del, old_uid, add, new_uid); 1267 - - if (k < 0) 1268 - + if (k == -ENOENT) 1269 - + log_debug("Device %s disappeared while setting ACLs", n); 1270 - + else if (k < 0) 1271 - r = k; 1272 - } 1273 - 1274 - diff --git a/src/login/logind-action.c b/src/login/logind-action.c 1275 - index 1928f43..d69c7ad 100644 1276 - --- a/src/login/logind-action.c 1277 - +++ b/src/login/logind-action.c 1278 - @@ -79,14 +79,12 @@ int manager_handle_action( 1279 - return 0; 1280 - } 1281 - 1282 - - /* If we have more than one or no displays connected, 1283 - - * don't react to lid closing. The no display case we 1284 - - * treat like this under the assumption that there is 1285 - - * no modern drm driver available. */ 1286 - + /* If we have more than one display connected, 1287 - + * don't react to lid closing. */ 1288 - n = manager_count_displays(m); 1289 - if (n < 0) 1290 - log_warning("Display counting failed: %s", strerror(-n)); 1291 - - else if (n != 1) { 1292 - + else if (n > 1) { 1293 - log_debug("Ignoring lid switch request, %i displays connected.", n); 1294 - return 0; 1295 - } 1296 - diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c 1297 - index 3f5efdc..1ee6ced 100644 1298 - --- a/src/login/logind-seat.c 1299 - +++ b/src/login/logind-seat.c 1300 - @@ -275,8 +275,13 @@ int seat_switch_to(Seat *s, unsigned int num) { 1301 - if (!num) 1302 - return -EINVAL; 1303 - 1304 - - if (num >= s->position_count || !s->positions[num]) 1305 - + if (num >= s->position_count || !s->positions[num]) { 1306 - + /* allow switching to unused VTs to trigger auto-activate */ 1307 - + if (seat_has_vts(s) && num < 64) 1308 - + return chvt(num); 1309 - + 1310 - return -EINVAL; 1311 - + } 1312 - 1313 - return session_activate(s->positions[num]); 1314 - } 1315 - diff --git a/src/login/logind-session.c b/src/login/logind-session.c 1316 - index 4ca6b5d..02a780d 100644 1317 - --- a/src/login/logind-session.c 1318 - +++ b/src/login/logind-session.c 1319 - @@ -213,7 +213,6 @@ int session_save(Session *s) { 1320 - 1321 - if (s->scope) 1322 - fprintf(f, "SCOPE=%s\n", s->scope); 1323 - - 1324 - if (s->scope_job) 1325 - fprintf(f, "SCOPE_JOB=%s\n", s->scope_job); 1326 - 1327 - @@ -229,17 +228,54 @@ int session_save(Session *s) { 1328 - if (s->display) 1329 - fprintf(f, "DISPLAY=%s\n", s->display); 1330 - 1331 - - if (s->remote_host) 1332 - - fprintf(f, "REMOTE_HOST=%s\n", s->remote_host); 1333 - + if (s->remote_host) { 1334 - + _cleanup_free_ char *escaped; 1335 - + 1336 - + escaped = cescape(s->remote_host); 1337 - + if (!escaped) { 1338 - + r = -ENOMEM; 1339 - + goto finish; 1340 - + } 1341 - + 1342 - + fprintf(f, "REMOTE_HOST=%s\n", escaped); 1343 - + } 1344 - + 1345 - + if (s->remote_user) { 1346 - + _cleanup_free_ char *escaped; 1347 - + 1348 - + escaped = cescape(s->remote_user); 1349 - + if (!escaped) { 1350 - + r = -ENOMEM; 1351 - + goto finish; 1352 - + } 1353 - + 1354 - + fprintf(f, "REMOTE_USER=%s\n", escaped); 1355 - + } 1356 - + 1357 - + if (s->service) { 1358 - + _cleanup_free_ char *escaped; 1359 - 1360 - - if (s->remote_user) 1361 - - fprintf(f, "REMOTE_USER=%s\n", s->remote_user); 1362 - + escaped = cescape(s->service); 1363 - + if (!escaped) { 1364 - + r = -ENOMEM; 1365 - + goto finish; 1366 - + } 1367 - + 1368 - + fprintf(f, "SERVICE=%s\n", escaped); 1369 - + } 1370 - 1371 - - if (s->service) 1372 - - fprintf(f, "SERVICE=%s\n", s->service); 1373 - + if (s->desktop) { 1374 - + _cleanup_free_ char *escaped; 1375 - 1376 - - if (s->desktop) 1377 - - fprintf(f, "DESKTOP=%s\n", s->desktop); 1378 - + 1379 - + escaped = cescape(s->desktop); 1380 - + if (!escaped) { 1381 - + r = -ENOMEM; 1382 - + goto finish; 1383 - + } 1384 - + 1385 - + fprintf(f, "DESKTOP=%s\n", escaped); 1386 - + } 1387 - 1388 - if (s->seat && seat_has_vts(s->seat)) 1389 - fprintf(f, "VTNR=%u\n", s->vtnr); 1390 - @@ -972,6 +1008,10 @@ void session_mute_vt(Session *s) { 1391 - if (vt < 0) 1392 - return; 1393 - 1394 - + r = fchown(vt, s->user->uid, -1); 1395 - + if (r < 0) 1396 - + goto error; 1397 - + 1398 - r = ioctl(vt, KDSKBMODE, K_OFF); 1399 - if (r < 0) 1400 - goto error; 1401 - @@ -1026,6 +1066,8 @@ void session_restore_vt(Session *s) { 1402 - mode.mode = VT_AUTO; 1403 - ioctl(vt, VT_SETMODE, &mode); 1404 - 1405 - + fchown(vt, 0, -1); 1406 - + 1407 - s->vtfd = safe_close(s->vtfd); 1408 - } 1409 - 1410 - diff --git a/src/login/org.freedesktop.login1.policy.in b/src/login/org.freedesktop.login1.policy.in 1411 - index b96d32d..b8e90f1 100644 1412 - --- a/src/login/org.freedesktop.login1.policy.in 1413 - +++ b/src/login/org.freedesktop.login1.policy.in 1414 - @@ -254,7 +254,7 @@ 1415 - <defaults> 1416 - <allow_any>auth_admin_keep</allow_any> 1417 - <allow_inactive>auth_admin_keep</allow_inactive> 1418 - - <allow_active>auth_admin_keep</allow_active> 1419 - + <allow_active>yes</allow_active> 1420 - </defaults> 1421 - <annotate key="org.freedesktop.policykit.imply">org.freedesktop.login1.hibernate</annotate> 1422 - </action> 1423 - diff --git a/src/login/pam-module.c b/src/login/pam-module.c 1424 - index 9873dd5..1259457 100644 1425 - --- a/src/login/pam-module.c 1426 - +++ b/src/login/pam-module.c 1427 - @@ -475,7 +475,7 @@ _public_ PAM_EXTERN int pam_sm_open_session( 1428 - } 1429 - 1430 - if (session_fd >= 0) { 1431 - - session_fd = dup(session_fd); 1432 - + session_fd = fcntl(session_fd, F_DUPFD_CLOEXEC, 3); 1433 - if (session_fd < 0) { 1434 - pam_syslog(handle, LOG_ERR, "Failed to dup session fd: %m"); 1435 - return PAM_SESSION_ERR; 1436 - diff --git a/src/machine/machine.c b/src/machine/machine.c 1437 - index 9a5cc9a..de701ad 100644 1438 - --- a/src/machine/machine.c 1439 - +++ b/src/machine/machine.c 1440 - @@ -123,17 +123,42 @@ int machine_save(Machine *m) { 1441 - "NAME=%s\n", 1442 - m->name); 1443 - 1444 - - if (m->unit) 1445 - - fprintf(f, "SCOPE=%s\n", m->unit); /* We continue to call this "SCOPE=" because it is internal only, and we want to stay compatible with old files */ 1446 - + if (m->unit) { 1447 - + _cleanup_free_ char *escaped; 1448 - + 1449 - + escaped = cescape(m->unit); 1450 - + if (!escaped) { 1451 - + r = -ENOMEM; 1452 - + goto finish; 1453 - + } 1454 - + 1455 - + fprintf(f, "SCOPE=%s\n", escaped); /* We continue to call this "SCOPE=" because it is internal only, and we want to stay compatible with old files */ 1456 - + } 1457 - 1458 - if (m->scope_job) 1459 - fprintf(f, "SCOPE_JOB=%s\n", m->scope_job); 1460 - 1461 - - if (m->service) 1462 - - fprintf(f, "SERVICE=%s\n", m->service); 1463 - + if (m->service) { 1464 - + _cleanup_free_ char *escaped; 1465 - 1466 - - if (m->root_directory) 1467 - - fprintf(f, "ROOT=%s\n", m->root_directory); 1468 - + escaped = cescape(m->service); 1469 - + if (!escaped) { 1470 - + r = -ENOMEM; 1471 - + goto finish; 1472 - + } 1473 - + fprintf(f, "SERVICE=%s\n", escaped); 1474 - + } 1475 - + 1476 - + if (m->root_directory) { 1477 - + _cleanup_free_ char *escaped; 1478 - + 1479 - + escaped = cescape(m->root_directory); 1480 - + if (!escaped) { 1481 - + r = -ENOMEM; 1482 - + goto finish; 1483 - + } 1484 - + fprintf(f, "ROOT=%s\n", escaped); 1485 - + } 1486 - 1487 - if (!sd_id128_equal(m->id, SD_ID128_NULL)) 1488 - fprintf(f, "ID=" SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(m->id)); 1489 - @@ -330,16 +355,18 @@ static int machine_stop_scope(Machine *m) { 1490 - if (!m->unit) 1491 - return 0; 1492 - 1493 - - r = manager_stop_unit(m->manager, m->unit, &error, &job); 1494 - - if (r < 0) { 1495 - - log_error("Failed to stop machine scope: %s", bus_error_message(&error, r)); 1496 - - return r; 1497 - + if (!m->registered) { 1498 - + r = manager_stop_unit(m->manager, m->unit, &error, &job); 1499 - + if (r < 0) { 1500 - + log_error("Failed to stop machine scope: %s", bus_error_message(&error, r)); 1501 - + return r; 1502 - + } 1503 - } 1504 - 1505 - free(m->scope_job); 1506 - m->scope_job = job; 1507 - 1508 - - return r; 1509 - + return 0; 1510 - } 1511 - 1512 - int machine_stop(Machine *m) { 1513 - @@ -415,6 +442,8 @@ int machine_kill(Machine *m, KillWho who, int signo) { 1514 - 1515 - if (kill(m->leader, signo) < 0) 1516 - return -errno; 1517 - + 1518 - + return 0; 1519 - } 1520 - 1521 - /* Otherwise make PID 1 do it for us, for the entire cgroup */ 1522 - diff --git a/src/machine/machine.h b/src/machine/machine.h 1523 - index f4aefc5..de3536d 100644 1524 - --- a/src/machine/machine.h 1525 - +++ b/src/machine/machine.h 1526 - @@ -72,6 +72,7 @@ struct Machine { 1527 - 1528 - bool in_gc_queue:1; 1529 - bool started:1; 1530 - + bool registered:1; 1531 - 1532 - sd_bus_message *create_message; 1533 - 1534 - diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c 1535 - index 9473105..154a335 100644 1536 - --- a/src/machine/machined-dbus.c 1537 - +++ b/src/machine/machined-dbus.c 1538 - @@ -241,6 +241,7 @@ static int method_create_or_register_machine(Manager *manager, sd_bus_message *m 1539 - m->leader = leader; 1540 - m->class = c; 1541 - m->id = id; 1542 - + m->registered = true; 1543 - 1544 - if (!isempty(service)) { 1545 - m->service = strdup(service); 42 + /* 1546 43 diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c 1547 - index 9a9ed9d..c3e6d23 100644 44 + index d01da45..4976f9a 100644 1548 45 --- a/src/nspawn/nspawn.c 1549 46 +++ b/src/nspawn/nspawn.c 1550 - @@ -769,6 +769,15 @@ static int setup_resolv_conf(const char *dest) { 1551 - return 0; 1552 - } 1553 - 1554 - +static char* id128_format_as_uuid(sd_id128_t id, char s[37]) { 1555 - + 1556 - + snprintf(s, 37, 1557 - + "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", 1558 - + SD_ID128_FORMAT_VAL(id)); 1559 - + 1560 - + return s; 1561 - +} 1562 - + 1563 - static int setup_boot_id(const char *dest) { 1564 - _cleanup_free_ char *from = NULL, *to = NULL; 1565 - sd_id128_t rnd = {}; 1566 - @@ -794,10 +803,7 @@ static int setup_boot_id(const char *dest) { 1567 - return r; 1568 - } 1569 - 1570 - - snprintf(as_uuid, sizeof(as_uuid), 1571 - - "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", 1572 - - SD_ID128_FORMAT_VAL(rnd)); 1573 - - char_array_0(as_uuid); 1574 - + id128_format_as_uuid(rnd, as_uuid); 1575 - 1576 - r = write_string_file(from, as_uuid); 1577 - if (r < 0) { 1578 - @@ -2378,7 +2384,7 @@ static int change_uid_gid(char **_home) { 1579 - _cleanup_fclose_ FILE *f = NULL; 1580 - _cleanup_close_ int fd = -1; 1581 - unsigned n_uids = 0; 1582 - - size_t sz, l; 1583 - + size_t sz = 0, l; 1584 - uid_t uid; 1585 - gid_t gid; 1586 - pid_t pid; 1587 - @@ -2667,6 +2673,7 @@ int main(int argc, char *argv[]) { 47 + @@ -2985,6 +2985,7 @@ int main(int argc, char *argv[]) { 1588 48 goto finish; 1589 49 } 1590 50 } else { ··· 1592 52 const char *p; 1593 53 1594 54 p = strappenda(arg_directory, 1595 - @@ -2676,6 +2683,7 @@ int main(int argc, char *argv[]) { 55 + @@ -2994,6 +2995,7 @@ int main(int argc, char *argv[]) { 1596 56 goto finish; 1597 57 1598 58 } ··· 1600 60 } 1601 61 } else { 1602 62 char template[] = "/tmp/nspawn-root-XXXXXX"; 1603 - @@ -2748,8 +2756,6 @@ int main(int argc, char *argv[]) { 1604 - goto finish; 1605 - } 1606 - 1607 - - sd_notify(0, "READY=1"); 1608 - - 1609 - assert_se(sigemptyset(&mask) == 0); 1610 - sigset_add_many(&mask, SIGCHLD, SIGWINCH, SIGTERM, SIGINT, -1); 1611 - assert_se(sigprocmask(SIG_BLOCK, &mask, NULL) == 0); 1612 - @@ -2966,7 +2972,9 @@ int main(int argc, char *argv[]) { 1613 - } 1614 - 1615 - if (!sd_id128_equal(arg_uuid, SD_ID128_NULL)) { 1616 - - if (asprintf((char**)(envp + n_env++), "container_uuid=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(arg_uuid)) < 0) { 1617 - + char as_uuid[37]; 1618 - + 1619 - + if (asprintf((char**)(envp + n_env++), "container_uuid=%s", id128_format_as_uuid(arg_uuid, as_uuid)) < 0) { 1620 - log_oom(); 1621 - goto child_fail; 1622 - } 1623 - @@ -3086,6 +3094,8 @@ int main(int argc, char *argv[]) { 1624 - if (r < 0) 1625 - goto finish; 1626 - 1627 - + sd_notify(0, "READY=1"); 1628 - + 1629 - /* Notify the child that the parent is ready with all 1630 - * its setup, and thtat the child can now hand over 1631 - * control to the code to run inside the container. */ 1632 - @@ -3136,6 +3146,10 @@ int main(int argc, char *argv[]) { 1633 - 1634 - if (!arg_quiet) 1635 - log_info("Container %s is being rebooted.", arg_machine); 1636 - + if (getenv("EXIT_ON_REBOOT") != 0) { 1637 - + r = 10; 1638 - + break; 1639 - + } 1640 - continue; 1641 - } else if (status.si_code == CLD_KILLED || 1642 - status.si_code == CLD_DUMPED) { 1643 - diff --git a/src/nss-myhostname/netlink.c b/src/nss-myhostname/netlink.c 1644 - index d61ecdf..228a3a4 100644 1645 - --- a/src/nss-myhostname/netlink.c 1646 - +++ b/src/nss-myhostname/netlink.c 1647 - @@ -112,6 +112,10 @@ static int read_reply(int fd, struct address **list, unsigned *n_list) { 1648 - ifaddrmsg->ifa_scope == RT_SCOPE_NOWHERE) 1649 - continue; 1650 - 1651 - + if (ifaddrmsg->ifa_family == AF_INET6 && 1652 - + ifaddrmsg->ifa_scope == RT_SCOPE_LINK) 1653 - + continue; 1654 - + 1655 - if (ifaddrmsg->ifa_flags & IFA_F_DEPRECATED) 1656 - continue; 1657 - 1658 - diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c 1659 - index 059b904..9a19a10 100644 1660 - --- a/src/python-systemd/_reader.c 1661 - +++ b/src/python-systemd/_reader.c 1662 - @@ -902,7 +902,6 @@ static PyObject* get_catalog(PyObject *self, PyObject *args) { 1663 - sd_id128_t id; 1664 - _cleanup_free_ char *msg = NULL; 1665 - 1666 - - assert(!self); 1667 - assert(args); 1668 - 1669 - if (!PyArg_ParseTuple(args, "z:get_catalog", &id_)) 1670 - diff --git a/src/python-systemd/journal.py b/src/python-systemd/journal.py 1671 - index 9c7e004..dd1f229 100644 1672 - --- a/src/python-systemd/journal.py 1673 - +++ b/src/python-systemd/journal.py 1674 - @@ -293,7 +293,7 @@ class Reader(_Reader): 1675 - monotonic = monotonic.totalseconds() 1676 - monotonic = int(monotonic * 1000000) 1677 - if isinstance(bootid, _uuid.UUID): 1678 - - bootid = bootid.get_hex() 1679 - + bootid = bootid.hex 1680 - return super(Reader, self).seek_monotonic(monotonic, bootid) 1681 - 1682 - def log_level(self, level): 1683 - @@ -314,7 +314,7 @@ class Reader(_Reader): 1684 - Equivalent to add_match(MESSAGE_ID=`messageid`). 1685 - """ 1686 - if isinstance(messageid, _uuid.UUID): 1687 - - messageid = messageid.get_hex() 1688 - + messageid = messageid.hex 1689 - self.add_match(MESSAGE_ID=messageid) 1690 - 1691 - def this_boot(self, bootid=None): 1692 - @@ -346,7 +346,7 @@ class Reader(_Reader): 1693 - 1694 - def get_catalog(mid): 1695 - if isinstance(mid, _uuid.UUID): 1696 - - mid = mid.get_hex() 1697 - + mid = mid.hex 1698 - return _get_catalog(mid) 1699 - 1700 - def _make_line(field, value): 1701 - diff --git a/src/readahead/readahead-common.c b/src/readahead/readahead-common.c 1702 - index 5ffa88b..49679fc 100644 1703 - --- a/src/readahead/readahead-common.c 1704 - +++ b/src/readahead/readahead-common.c 1705 - @@ -75,7 +75,7 @@ int fs_on_ssd(const char *p) { 1706 - if (major(st.st_dev) == 0) { 1707 - _cleanup_fclose_ FILE *f = NULL; 1708 - int mount_id; 1709 - - struct file_handle *h; 1710 - + union file_handle_union h = { .handle.handle_bytes = MAX_HANDLE_SZ, }; 1711 - 1712 - /* Might be btrfs, which exposes "ssd" as mount flag if it is on ssd. 1713 - * 1714 - @@ -83,9 +83,7 @@ int fs_on_ssd(const char *p) { 1715 - * and then lookup the mount ID in mountinfo to find 1716 - * the mount options. */ 1717 - 1718 - - h = alloca(MAX_HANDLE_SZ); 1719 - - h->handle_bytes = MAX_HANDLE_SZ; 1720 - - r = name_to_handle_at(AT_FDCWD, p, h, &mount_id, AT_SYMLINK_FOLLOW); 1721 - + r = name_to_handle_at(AT_FDCWD, p, &h.handle, &mount_id, AT_SYMLINK_FOLLOW); 1722 - if (r < 0) 1723 - return false; 1724 - 1725 - diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c 1726 - index d27b1b7..905a2e1 100644 1727 - --- a/src/shared/conf-parser.c 1728 - +++ b/src/shared/conf-parser.c 1729 - @@ -336,8 +336,8 @@ int config_parse(const char *unit, 1730 - if (!f) { 1731 - f = ours = fopen(filename, "re"); 1732 - if (!f) { 1733 - - log_error("Failed to open configuration file '%s': %m", filename); 1734 - - return -errno; 1735 - + log_full(errno == ENOENT ? LOG_DEBUG : LOG_ERR, "Failed to open configuration file '%s': %m", filename); 1736 - + return errno == ENOENT ? 0 : -errno; 1737 - } 1738 - } 1739 - 1740 - diff --git a/src/shared/generator.c b/src/shared/generator.c 1741 - index 6110303..e679cb1 100644 1742 - --- a/src/shared/generator.c 1743 - +++ b/src/shared/generator.c 1744 - @@ -48,7 +48,7 @@ int generator_write_fsck_deps( 1745 - const char *checker; 1746 - int r; 1747 - 1748 - - checker = strappenda("/sbin/fsck.", fstype); 1749 - + checker = strappenda("/run/current-system/sw/sbin/fsck.", fstype); 1750 - r = access(checker, X_OK); 1751 - if (r < 0) { 1752 - log_warning("Checking was requested for %s, but %s cannot be used: %m", what, checker); 1753 - diff --git a/src/shared/install.c b/src/shared/install.c 1754 - index 7409046..4517c9c 100644 1755 - --- a/src/shared/install.c 1756 - +++ b/src/shared/install.c 1757 - @@ -560,7 +560,7 @@ int unit_file_mask( 1758 - unsigned *n_changes) { 1759 - 1760 - char **i; 1761 - - _cleanup_free_ char *prefix; 1762 - + _cleanup_free_ char *prefix = NULL; 1763 - int r; 1764 - 1765 - assert(scope >= 0); 1766 - diff --git a/src/shared/log.c b/src/shared/log.c 1767 - index a4b3b68..890a9fa 100644 1768 - --- a/src/shared/log.c 1769 - +++ b/src/shared/log.c 1770 - @@ -878,6 +878,9 @@ void log_parse_environment(void) { 1771 - if (l == 5 && startswith(w, "debug")) { 1772 - log_set_max_level(LOG_DEBUG); 1773 - break; 1774 - + } else if (l == 5 && startswith(w, "quiet")) { 1775 - + log_set_max_level(LOG_WARNING); 1776 - + break; 1777 - } 1778 - } 1779 - } 1780 - diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c 1781 - index 9d14933..b0b66f6 100644 1782 - --- a/src/shared/logs-show.c 1783 - +++ b/src/shared/logs-show.c 1784 - @@ -547,7 +547,9 @@ static int output_export( 1785 - startswith(data, "_BOOT_ID=")) 1786 - continue; 1787 - 1788 - - if (!utf8_is_printable(data, length)) { 1789 - + if (utf8_is_printable_newline(data, length, false)) 1790 - + fwrite(data, length, 1, f); 1791 - + else { 1792 - const char *c; 1793 - uint64_t le64; 1794 - 1795 - @@ -562,8 +564,7 @@ static int output_export( 1796 - le64 = htole64(length - (c - (const char*) data) - 1); 1797 - fwrite(&le64, sizeof(le64), 1, f); 1798 - fwrite(c + 1, length - (c - (const char*) data) - 1, 1, f); 1799 - - } else 1800 - - fwrite(data, length, 1, f); 1801 - + } 1802 - 1803 - fputc('\n', f); 1804 - } 1805 - diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c 1806 - index 6c167b4..d0e71f2 100644 1807 - --- a/src/shared/unit-name.c 1808 - +++ b/src/shared/unit-name.c 1809 - @@ -332,7 +332,7 @@ char *unit_name_path_unescape(const char *f) { 1810 - } 1811 - 1812 - bool unit_name_is_template(const char *n) { 1813 - - const char *p; 1814 - + const char *p, *e; 1815 - 1816 - assert(n); 1817 - 1818 - @@ -340,11 +340,15 @@ bool unit_name_is_template(const char *n) { 1819 - if (!p) 1820 - return false; 1821 - 1822 - - return p[1] == '.'; 1823 - + e = strrchr(p+1, '.'); 1824 - + if (!e) 1825 - + return false; 1826 - + 1827 - + return e == p + 1; 1828 - } 1829 - 1830 - bool unit_name_is_instance(const char *n) { 1831 - - const char *p; 1832 - + const char *p, *e; 1833 - 1834 - assert(n); 1835 - 1836 - @@ -352,7 +356,11 @@ bool unit_name_is_instance(const char *n) { 1837 - if (!p) 1838 - return false; 1839 - 1840 - - return p[1] != '.'; 1841 - + e = strrchr(p+1, '.'); 1842 - + if (!e) 1843 - + return false; 1844 - + 1845 - + return e > p + 1; 1846 - } 1847 - 1848 - char *unit_name_replace_instance(const char *f, const char *i) { 1849 - diff --git a/src/shared/utf8.c b/src/shared/utf8.c 1850 - index 0b524d8..c559c13 100644 1851 - --- a/src/shared/utf8.c 1852 - +++ b/src/shared/utf8.c 1853 - @@ -136,7 +136,7 @@ int utf8_encoded_to_unichar(const char *str) { 1854 - return unichar; 1855 - } 1856 - 1857 - -bool utf8_is_printable(const char* str, size_t length) { 1858 - +bool utf8_is_printable_newline(const char* str, size_t length, bool newline) { 1859 - const uint8_t *p; 1860 - 1861 - assert(str); 1862 - @@ -145,7 +145,8 @@ bool utf8_is_printable(const char* str, size_t length) { 1863 - int encoded_len = utf8_encoded_valid_unichar((const char *)p); 1864 - int val = utf8_encoded_to_unichar((const char*)p); 1865 - 1866 - - if (encoded_len < 0 || val < 0 || is_unicode_control(val)) 1867 - + if (encoded_len < 0 || val < 0 || is_unicode_control(val) || 1868 - + (!newline && val == '\n')) 1869 - return false; 1870 - 1871 - length -= encoded_len; 1872 - diff --git a/src/shared/utf8.h b/src/shared/utf8.h 1873 - index c0eb73a..c087995 100644 1874 - --- a/src/shared/utf8.h 1875 - +++ b/src/shared/utf8.h 1876 - @@ -31,7 +31,10 @@ const char *utf8_is_valid(const char *s) _pure_; 1877 - char *ascii_is_valid(const char *s) _pure_; 1878 - char *utf8_escape_invalid(const char *s); 1879 - 1880 - -bool utf8_is_printable(const char* str, size_t length) _pure_; 1881 - +bool utf8_is_printable_newline(const char* str, size_t length, bool newline) _pure_; 1882 - +_pure_ static inline bool utf8_is_printable(const char* str, size_t length) { 1883 - + return utf8_is_printable_newline(str, length, true); 1884 - +} 1885 - 1886 - char *utf16_to_utf8(const void *s, size_t length); 1887 - 1888 - diff --git a/src/shared/util.c b/src/shared/util.c 1889 - index ffe6624..2a2b2b2 100644 1890 - --- a/src/shared/util.c 1891 - +++ b/src/shared/util.c 1892 - @@ -166,19 +166,19 @@ int close_nointr(int fd) { 1893 - 1894 - assert(fd >= 0); 1895 - r = close(fd); 1896 - - 1897 - - /* Just ignore EINTR; a retry loop is the wrong 1898 - - * thing to do on Linux. 1899 - - * 1900 - - * http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html 1901 - - * https://bugzilla.gnome.org/show_bug.cgi?id=682819 1902 - - * http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR 1903 - - * https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain 1904 - - */ 1905 - - if (_unlikely_(r < 0 && errno == EINTR)) 1906 - - return 0; 1907 - - else if (r >= 0) 1908 - + if (r >= 0) 1909 - return r; 1910 - + else if (errno == EINTR) 1911 - + /* 1912 - + * Just ignore EINTR; a retry loop is the wrong 1913 - + * thing to do on Linux. 1914 - + * 1915 - + * http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html 1916 - + * https://bugzilla.gnome.org/show_bug.cgi?id=682819 1917 - + * http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR 1918 - + * https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain 1919 - + */ 1920 - + return 0; 1921 - else 1922 - return -errno; 1923 - } 1924 - @@ -195,7 +195,13 @@ int safe_close(int fd) { 1925 - 1926 - if (fd >= 0) { 1927 - PROTECT_ERRNO; 1928 - - assert_se(close_nointr(fd) == 0); 1929 - + 1930 - + /* The kernel might return pretty much any error code 1931 - + * via close(), but the fd will be closed anyway. The 1932 - + * only condition we want to check for here is whether 1933 - + * the fd was invalid at all... */ 1934 - + 1935 - + assert_se(close_nointr(fd) != -EBADF); 1936 - } 1937 - 1938 - return -1; 1939 - @@ -1365,7 +1371,7 @@ bool ignore_file(const char *filename) { 1940 - assert(filename); 1941 - 1942 - if (endswith(filename, "~")) 1943 - - return false; 1944 - + return true; 1945 - 1946 - return ignore_file_allow_backup(filename); 1947 - } 1948 - @@ -1495,6 +1501,7 @@ bool fstype_is_network(const char *fstype) { 1949 - static const char table[] = 1950 - "cifs\0" 1951 - "smbfs\0" 1952 - + "sshfs\0" 1953 - "ncpfs\0" 1954 - "ncp\0" 1955 - "nfs\0" 1956 - @@ -1581,8 +1588,9 @@ int read_one_char(FILE *f, char *ret, usec_t t, bool *need_nl) { 1957 - if (fd_wait_for_event(fileno(f), POLLIN, t) <= 0) 1958 - return -ETIMEDOUT; 1959 - 1960 - + errno = 0; 1961 - if (!fgets(line, sizeof(line), f)) 1962 - - return -EIO; 1963 - + return errno ? -errno : -EIO; 1964 - 1965 - truncate_nl(line); 1966 - 1967 - @@ -5327,6 +5335,9 @@ bool string_is_safe(const char *p) { 1968 - if (*t > 0 && *t < ' ') 1969 - return false; 1970 - 1971 - + if (*t == 127) 1972 - + return false; 1973 - + 1974 - if (strchr("\\\"\'", *t)) 1975 - return false; 1976 - } 1977 - @@ -5343,10 +5354,14 @@ bool string_has_cc(const char *p) { 1978 - 1979 - assert(p); 1980 - 1981 - - for (t = p; *t; t++) 1982 - + for (t = p; *t; t++) { 1983 - if (*t > 0 && *t < ' ' && *t != '\t') 1984 - return true; 1985 - 1986 - + if (*t == 127) 1987 - + return true; 1988 - + } 1989 - + 1990 - return false; 1991 - } 1992 - 1993 - @@ -6391,3 +6406,19 @@ void hexdump(FILE *f, const void *p, size_t s) { 1994 - s -= 16; 1995 - } 1996 - } 1997 - + 1998 - +int update_reboot_param_file(const char *param) 1999 - +{ 2000 - + int r = 0; 2001 - + 2002 - + if (param) { 2003 - + 2004 - + r = write_string_file(REBOOT_PARAM_FILE, param); 2005 - + if (r < 0) 2006 - + log_error("Failed to write reboot param to " 2007 - + REBOOT_PARAM_FILE": %s", strerror(-r)); 2008 - + } else 2009 - + unlink(REBOOT_PARAM_FILE); 2010 - + 2011 - + return r; 2012 - +} 2013 - diff --git a/src/shared/util.h b/src/shared/util.h 2014 - index 90464c9..122ac91 100644 2015 - --- a/src/shared/util.h 2016 - +++ b/src/shared/util.h 2017 - @@ -22,6 +22,7 @@ 2018 - ***/ 2019 - 2020 - #include <alloca.h> 2021 - +#include <fcntl.h> 2022 - #include <inttypes.h> 2023 - #include <time.h> 2024 - #include <sys/time.h> 2025 - @@ -922,3 +923,10 @@ uint64_t physical_memory(void); 2026 - char* mount_test_option(const char *haystack, const char *needle); 2027 - 2028 - void hexdump(FILE *f, const void *p, size_t s); 2029 - + 2030 - +union file_handle_union { 2031 - + struct file_handle handle; 2032 - + char padding[sizeof(struct file_handle) + MAX_HANDLE_SZ]; 2033 - +}; 2034 - + 2035 - +int update_reboot_param_file(const char *param); 2036 - diff --git a/src/shared/virt.c b/src/shared/virt.c 2037 - index ec2ddcf..f03e790 100644 2038 - --- a/src/shared/virt.c 2039 - +++ b/src/shared/virt.c 2040 - @@ -149,7 +149,7 @@ static int detect_vm_dmi(const char **_id) { 2041 - 2042 - /* Returns a short identifier for the various VM implementations */ 2043 - int detect_vm(const char **id) { 2044 - - _cleanup_free_ char *hvtype = NULL, *cpuinfo_contents = NULL; 2045 - + _cleanup_free_ char *domcap = NULL, *cpuinfo_contents = NULL; 2046 - static thread_local int cached_found = -1; 2047 - static thread_local const char *cached_id = NULL; 2048 - const char *_id = NULL; 2049 - @@ -163,17 +163,37 @@ int detect_vm(const char **id) { 2050 - return cached_found; 2051 - } 2052 - 2053 - - /* Try high-level hypervisor sysfs file first: 2054 - + /* Try xen capabilities file first, if not found try high-level hypervisor sysfs file: 2055 - * 2056 - - * https://bugs.freedesktop.org/show_bug.cgi?id=61491 */ 2057 - - r = read_one_line_file("/sys/hypervisor/type", &hvtype); 2058 - + * https://bugs.freedesktop.org/show_bug.cgi?id=77271 */ 2059 - + r = read_one_line_file("/proc/xen/capabilities", &domcap); 2060 - if (r >= 0) { 2061 - - if (streq(hvtype, "xen")) { 2062 - + char *cap, *i = domcap; 2063 - + 2064 - + while ((cap = strsep(&i, ","))) 2065 - + if (streq(cap, "control_d")) 2066 - + break; 2067 - + 2068 - + if (!i) { 2069 - _id = "xen"; 2070 - r = 1; 2071 - - goto finish; 2072 - } 2073 - - } else if (r != -ENOENT) 2074 - + 2075 - + goto finish; 2076 - + 2077 - + } else if (r == -ENOENT) { 2078 - + _cleanup_free_ char *hvtype = NULL; 2079 - + 2080 - + r = read_one_line_file("/sys/hypervisor/type", &hvtype); 2081 - + if (r >= 0) { 2082 - + if (streq(hvtype, "xen")) { 2083 - + _id = "xen"; 2084 - + r = 1; 2085 - + goto finish; 2086 - + } 2087 - + } else if (r != -ENOENT) 2088 - + return r; 2089 - + } else 2090 - return r; 2091 - 2092 - /* this will set _id to "other" and return 0 for unknown hypervisors */ 2093 63 diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c 2094 - index 0887bc3..d02ee2b 100644 64 + index 36db652..b1ba6e9 100644 2095 65 --- a/src/systemctl/systemctl.c 2096 66 +++ b/src/systemctl/systemctl.c 2097 - @@ -461,7 +461,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { 2098 - } 2099 - 2100 - if (circle_len > 0) 2101 - - printf("%s%s%s", on_circle, circle ? draw_special_char(DRAW_BLACK_CIRCLE) : " ", off_circle); 2102 - + printf("%s%s%s ", on_circle, circle ? draw_special_char(DRAW_BLACK_CIRCLE) : " ", off_circle); 2103 - 2104 - printf("%s%-*s%s %s%-*s%s %s%-*s %-*s%s %-*s", 2105 - on_active, id_len, id, off_active, 2106 - @@ -2561,7 +2561,7 @@ static int start_unit_one( 67 + @@ -2607,7 +2607,7 @@ static int start_unit_one( 2107 68 2108 69 log_debug("Adding %s to the set", p); 2109 70 r = set_consume(s, p); ··· 2112 73 return log_oom(); 2113 74 } 2114 75 2115 - @@ -4240,7 +4240,7 @@ static int show_all( 2116 - _cleanup_free_ UnitInfo *unit_infos = NULL; 2117 - const UnitInfo *u; 2118 - unsigned c; 2119 - - int r; 2120 - + int r, ret = 0; 2121 - 2122 - r = get_unit_list(bus, NULL, NULL, &unit_infos, 0, &reply); 2123 - if (r < 0) 2124 - @@ -4262,9 +4262,11 @@ static int show_all( 2125 - r = show_one(verb, bus, p, show_properties, new_line, ellipsized); 2126 - if (r < 0) 2127 - return r; 2128 - + else if (r > 0 && ret == 0) 2129 - + ret = r; 2130 - } 2131 - 2132 - - return 0; 2133 - + return ret; 2134 - } 2135 - 2136 - static int show_system_status(sd_bus *bus) { 2137 - @@ -4386,7 +4388,12 @@ static int show(sd_bus *bus, char **args) { 2138 - } 2139 - } 2140 - 2141 - - show_one(args[0], bus, unit, show_properties, &new_line, &ellipsized); 2142 - + r = show_one(args[0], bus, unit, show_properties, 2143 - + &new_line, &ellipsized); 2144 - + if (r < 0) 2145 - + return r; 2146 - + else if (r > 0 && ret == 0) 2147 - + ret = r; 2148 - } 2149 - 2150 - if (!strv_isempty(patterns)) { 2151 - @@ -4403,7 +4410,12 @@ static int show(sd_bus *bus, char **args) { 2152 - if (!unit) 2153 - return log_oom(); 2154 - 2155 - - show_one(args[0], bus, unit, show_properties, &new_line, &ellipsized); 2156 - + r = show_one(args[0], bus, unit, show_properties, 2157 - + &new_line, &ellipsized); 2158 - + if (r < 0) 2159 - + return r; 2160 - + else if (r > 0 && ret == 0) 2161 - + ret = r; 2162 - } 2163 - } 2164 - } 2165 - @@ -5403,15 +5415,15 @@ static int systemctl_help(void) { 2166 - " otherwise restart if active\n" 2167 - " isolate NAME Start one unit and stop all others\n" 2168 - " kill NAME... Send signal to processes of a unit\n" 2169 - - " is-active NAME... Check whether units are active\n" 2170 - - " is-failed NAME... Check whether units are failed\n" 2171 - - " status [NAME...|PID...] Show runtime status of one or more units\n" 2172 - - " show [NAME...|JOB...] Show properties of one or more\n" 2173 - + " is-active PATTERN... Check whether units are active\n" 2174 - + " is-failed PATTERN... Check whether units are failed\n" 2175 - + " status [PATTERN...|PID...] Show runtime status of one or more units\n" 2176 - + " show [PATTERN...|JOB...] Show properties of one or more\n" 2177 - " units/jobs or the manager\n" 2178 - - " cat NAME... Show files and drop-ins of one or more units\n" 2179 - + " cat PATTERN... Show files and drop-ins of one or more units\n" 2180 - " set-property NAME ASSIGNMENT... Sets one or more properties of a unit\n" 2181 - - " help NAME...|PID... Show manual for one or more units\n" 2182 - - " reset-failed [NAME...] Reset failed state for all, one, or more\n" 2183 - + " help PATTERN...|PID... Show manual for one or more units\n" 2184 - + " reset-failed [PATTERN...] Reset failed state for all, one, or more\n" 2185 - " units\n" 2186 - " list-dependencies [NAME] Recursively show units which are required\n" 2187 - " or wanted by this unit or by which this\n" 2188 - @@ -5973,13 +5985,10 @@ static int halt_parse_argv(int argc, char *argv[]) { 2189 - } 2190 - } 2191 - 2192 - - if (arg_action == ACTION_REBOOT && argc == optind + 1) { 2193 - - r = write_string_file(REBOOT_PARAM_FILE, argv[optind]); 2194 - - if (r < 0) { 2195 - - log_error("Failed to write reboot param to " 2196 - - REBOOT_PARAM_FILE": %s", strerror(-r)); 2197 - + if (arg_action == ACTION_REBOOT && (argc == optind || argc == optind + 1)) { 2198 - + r = update_reboot_param_file(argc == optind + 1 ? argv[optind] : NULL); 2199 - + if (r < 0) 2200 - return r; 2201 - - } 2202 - } else if (optind < argc) { 2203 - log_error("Too many arguments."); 2204 - return -EINVAL; 2205 - diff --git a/src/test/test-udev.c b/src/test/test-udev.c 2206 - index b064744..b057cc8 100644 2207 - --- a/src/test/test-udev.c 2208 - +++ b/src/test/test-udev.c 2209 - @@ -155,9 +155,8 @@ int main(int argc, char *argv[]) { 2210 - } 2211 - } 2212 - 2213 - - err = udev_event_execute_rules(event, rules, &sigmask_orig); 2214 - - if (err == 0) 2215 - - udev_event_execute_run(event, NULL); 2216 - + udev_event_execute_rules(event, rules, &sigmask_orig); 2217 - + udev_event_execute_run(event, NULL); 2218 - out: 2219 - if (event != NULL && event->fd_signal >= 0) 2220 - close(event->fd_signal); 2221 - diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c 2222 - index 33e7cbc..04b472d 100644 2223 - --- a/src/tmpfiles/tmpfiles.c 2224 - +++ b/src/tmpfiles/tmpfiles.c 2225 - @@ -217,19 +217,16 @@ static bool unix_socket_alive(const char *fn) { 2226 - } 2227 - 2228 - static int dir_is_mount_point(DIR *d, const char *subdir) { 2229 - - struct file_handle *h; 2230 - + union file_handle_union h = { .handle.handle_bytes = MAX_HANDLE_SZ }; 2231 - int mount_id_parent, mount_id; 2232 - int r_p, r; 2233 - 2234 - - h = alloca(MAX_HANDLE_SZ); 2235 - - 2236 - - h->handle_bytes = MAX_HANDLE_SZ; 2237 - - r_p = name_to_handle_at(dirfd(d), ".", h, &mount_id_parent, 0); 2238 - + r_p = name_to_handle_at(dirfd(d), ".", &h.handle, &mount_id_parent, 0); 2239 - if (r_p < 0) 2240 - r_p = -errno; 2241 - 2242 - - h->handle_bytes = MAX_HANDLE_SZ; 2243 - - r = name_to_handle_at(dirfd(d), subdir, h, &mount_id, 0); 2244 - + h.handle.handle_bytes = MAX_HANDLE_SZ; 2245 - + r = name_to_handle_at(dirfd(d), subdir, &h.handle, &mount_id, 0); 2246 - if (r < 0) 2247 - r = -errno; 2248 - 2249 - diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c 2250 - index 1d067af..3203474 100644 2251 - --- a/src/tty-ask-password-agent/tty-ask-password-agent.c 2252 - +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c 2253 - @@ -432,7 +432,7 @@ static int wall_tty_block(void) { 2254 - 2255 - r = get_ctty_devnr(0, &devnr); 2256 - if (r < 0) 2257 - - return -r; 2258 - + return r; 2259 - 2260 - if (asprintf(&p, "/run/systemd/ask-password-block/%u:%u", major(devnr), minor(devnr)) < 0) 2261 - return -ENOMEM; 2262 - diff --git a/src/udev/accelerometer/accelerometer.c b/src/udev/accelerometer/accelerometer.c 2263 - index 925d38d..32adf27 100644 2264 - --- a/src/udev/accelerometer/accelerometer.c 2265 - +++ b/src/udev/accelerometer/accelerometer.c 2266 - @@ -180,7 +180,7 @@ get_prev_orientation(struct udev_device *dev) 2267 - return string_to_orientation(value); 2268 - } 2269 - 2270 - -#define SET_AXIS(axis, code_) if (ev[i].code == code_) { if (got_##axis == 0) { axis = ev[i].value; got_##axis = true; } } 2271 - +#define READ_AXIS(axis, var) { memzero(&abs_info, sizeof(abs_info)); r = ioctl(fd, EVIOCGABS(axis), &abs_info); if (r < 0) return; var = abs_info.value; } 2272 - 2273 - /* accelerometers */ 2274 - static void test_orientation(struct udev *udev, 2275 - @@ -189,10 +189,9 @@ static void test_orientation(struct udev *udev, 2276 - { 2277 - OrientationUp old, new; 2278 - _cleanup_close_ int fd = -1; 2279 - - struct input_event ev[64]; 2280 - - bool got_syn = false; 2281 - - bool got_x = false, got_y = false, got_z = false; 2282 - + struct input_absinfo abs_info; 2283 - int x = 0, y = 0, z = 0; 2284 - + int r; 2285 - char text[64]; 2286 - 2287 - old = get_prev_orientation(dev); 2288 - @@ -201,30 +200,10 @@ static void test_orientation(struct udev *udev, 2289 - if (fd < 0) 2290 - return; 2291 - 2292 - - while (1) { 2293 - - int i, r; 2294 - - 2295 - - r = read(fd, ev, sizeof(struct input_event) * 64); 2296 - - 2297 - - if (r < (int) sizeof(struct input_event)) 2298 - - return; 2299 - - 2300 - - for (i = 0; i < r / (int) sizeof(struct input_event); i++) { 2301 - - if (got_syn) { 2302 - - if (ev[i].type == EV_ABS) { 2303 - - SET_AXIS(x, ABS_X); 2304 - - SET_AXIS(y, ABS_Y); 2305 - - SET_AXIS(z, ABS_Z); 2306 - - } 2307 - - } 2308 - - if (ev[i].type == EV_SYN && ev[i].code == SYN_REPORT) 2309 - - got_syn = true; 2310 - - if (got_x && got_y && got_z) 2311 - - goto read_dev; 2312 - - } 2313 - - } 2314 - + READ_AXIS(ABS_X, x); 2315 - + READ_AXIS(ABS_Y, y); 2316 - + READ_AXIS(ABS_Z, z); 2317 - 2318 - -read_dev: 2319 - new = orientation_calc(old, x, y, z); 2320 - snprintf(text, sizeof(text), 2321 - "ID_INPUT_ACCELEROMETER_ORIENTATION=%s", orientation_to_string(new)); 2322 - diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c 2323 - index 5bb6b02..b31ad80 100644 2324 - --- a/src/udev/net/link-config.c 2325 - +++ b/src/udev/net/link-config.c 2326 - @@ -184,7 +184,7 @@ failure: 2327 - } 2328 - 2329 - static bool enable_name_policy(void) { 2330 - - _cleanup_free_ char *line; 2331 - + _cleanup_free_ char *line = NULL; 2332 - char *w, *state; 2333 - int r; 2334 - size_t l; 2335 - @@ -391,7 +391,9 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev 2336 - case MACPOLICY_PERSISTENT: 2337 - if (!mac_is_permanent(device)) { 2338 - r = get_mac(device, false, &generated_mac); 2339 - - if (r < 0) 2340 - + if (r == -ENOENT) 2341 - + break; 2342 - + else if (r < 0) 2343 - return r; 2344 - mac = &generated_mac; 2345 - } 2346 - @@ -399,7 +401,9 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev 2347 - case MACPOLICY_RANDOM: 2348 - if (!mac_is_random(device)) { 2349 - r = get_mac(device, true, &generated_mac); 2350 - - if (r < 0) 2351 - + if (r == -ENOENT) 2352 - + break; 2353 - + else if (r < 0) 2354 - return r; 2355 - mac = &generated_mac; 2356 - } 2357 - diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c 2358 - index 5998be2..5213a4a 100644 2359 - --- a/src/udev/udev-event.c 2360 - +++ b/src/udev/udev-event.c 2361 - @@ -771,18 +771,17 @@ static int rename_netif(struct udev_event *event) 2362 - log_error("error changing net interface name %s to %s: %s", 2363 - oldname, name, strerror(-r)); 2364 - else 2365 - - print_kmsg("renamed network interface %s to %s", oldname, name); 2366 - + print_kmsg("renamed network interface %s to %s\n", oldname, name); 2367 - 2368 - return r; 2369 - } 2370 - 2371 - -int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigmask) 2372 - +void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigmask) 2373 - { 2374 - struct udev_device *dev = event->dev; 2375 - - int err = 0; 2376 - 2377 - if (udev_device_get_subsystem(dev) == NULL) 2378 - - return -1; 2379 - + return; 2380 - 2381 - if (streq(udev_device_get_action(dev), "remove")) { 2382 - udev_device_read_db(dev, NULL); 2383 - @@ -816,9 +815,10 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, 2384 - event->name != NULL && !streq(event->name, udev_device_get_sysname(dev))) { 2385 - char syspath[UTIL_PATH_SIZE]; 2386 - char *pos; 2387 - + int r; 2388 - 2389 - - err = rename_netif(event); 2390 - - if (err == 0) { 2391 - + r = rename_netif(event); 2392 - + if (r >= 0) { 2393 - log_debug("renamed netif to '%s'", event->name); 2394 - 2395 - /* remember old name */ 2396 - @@ -881,7 +881,6 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, 2397 - udev_device_unref(event->dev_db); 2398 - event->dev_db = NULL; 2399 - } 2400 - - return err; 2401 - } 2402 - 2403 - void udev_event_execute_run(struct udev_event *event, const sigset_t *sigmask) 2404 - diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c 2405 - index 2630264..17f47f2 100644 2406 - --- a/src/udev/udev-rules.c 2407 - +++ b/src/udev/udev-rules.c 2408 - @@ -2555,10 +2555,15 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) 2409 - struct stat stats; 2410 - 2411 - /* we assure, that the permissions tokens are sorted before the static token */ 2412 - + 2413 - if (mode == 0 && uid == 0 && gid == 0 && tags == NULL) 2414 - goto next; 2415 - 2416 - strscpyl(device_node, sizeof(device_node), "/dev/", rules_str(rules, cur->key.value_off), NULL); 2417 - + if (stat(device_node, &stats) != 0) 2418 - + break; 2419 - + if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode)) 2420 - + break; 2421 - 2422 - /* export the tags to a directory as symlinks, allowing otherwise dead nodes to be tagged */ 2423 - if (tags) { 2424 - @@ -2588,11 +2593,6 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) 2425 - if (mode == 0 && uid == 0 && gid == 0) 2426 - break; 2427 - 2428 - - if (stat(device_node, &stats) != 0) 2429 - - break; 2430 - - if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode)) 2431 - - break; 2432 - - 2433 - if (mode == 0) { 2434 - if (gid > 0) 2435 - mode = 0660; 2436 - diff --git a/src/udev/udev.h b/src/udev/udev.h 2437 - index 936adfb..62538bc 100644 2438 - --- a/src/udev/udev.h 2439 - +++ b/src/udev/udev.h 2440 - @@ -84,7 +84,7 @@ int udev_event_apply_subsys_kernel(struct udev_event *event, const char *string, 2441 - int udev_event_spawn(struct udev_event *event, 2442 - const char *cmd, char **envp, const sigset_t *sigmask, 2443 - char *result, size_t ressize); 2444 - -int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigset); 2445 - +void udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules, const sigset_t *sigset); 2446 - void udev_event_execute_run(struct udev_event *event, const sigset_t *sigset); 2447 - int udev_build_argv(struct udev *udev, char *cmd, int *argc, char *argv[]); 2448 - 2449 - diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c 2450 - index 6cd311b..6a2f548 100644 2451 - --- a/src/udev/udevadm-test.c 2452 - +++ b/src/udev/udevadm-test.c 2453 - @@ -43,7 +43,6 @@ static int adm_test(struct udev *udev, int argc, char *argv[]) 2454 - _cleanup_udev_device_unref_ struct udev_device *dev = NULL; 2455 - _cleanup_udev_event_unref_ struct udev_event *event = NULL; 2456 - sigset_t mask, sigmask_orig; 2457 - - int err; 2458 - int rc = 0, c; 2459 - 2460 - static const struct option options[] = { 2461 - @@ -139,18 +138,16 @@ static int adm_test(struct udev *udev, int argc, char *argv[]) 2462 - goto out; 2463 - } 2464 - 2465 - - err = udev_event_execute_rules(event, rules, &sigmask_orig); 2466 - + udev_event_execute_rules(event, rules, &sigmask_orig); 2467 - 2468 - udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev)) 2469 - printf("%s=%s\n", udev_list_entry_get_name(entry), udev_list_entry_get_value(entry)); 2470 - 2471 - - if (err == 0) { 2472 - - udev_list_entry_foreach(entry, udev_list_get_entry(&event->run_list)) { 2473 - - char program[UTIL_PATH_SIZE]; 2474 - + udev_list_entry_foreach(entry, udev_list_get_entry(&event->run_list)) { 2475 - + char program[UTIL_PATH_SIZE]; 2476 - 2477 - - udev_event_apply_format(event, udev_list_entry_get_name(entry), program, sizeof(program)); 2478 - - printf("run: '%s'\n", program); 2479 - - } 2480 - + udev_event_apply_format(event, udev_list_entry_get_name(entry), program, sizeof(program)); 2481 - + printf("run: '%s'\n", program); 2482 - } 2483 - out: 2484 - if (event != NULL && event->fd_signal >= 0) 2485 - diff --git a/src/udev/udevd.c b/src/udev/udevd.c 2486 - index f21c227..93afca1 100644 2487 - --- a/src/udev/udevd.c 2488 - +++ b/src/udev/udevd.c 2489 - @@ -288,10 +288,9 @@ static void worker_new(struct event *event) 2490 - udev_event->exec_delay = exec_delay; 2491 - 2492 - /* apply rules, create node, symlinks */ 2493 - - err = udev_event_execute_rules(udev_event, rules, &sigmask_orig); 2494 - + udev_event_execute_rules(udev_event, rules, &sigmask_orig); 2495 - 2496 - - if (err == 0) 2497 - - udev_event_execute_run(udev_event, &sigmask_orig); 2498 - + udev_event_execute_run(udev_event, &sigmask_orig); 2499 - 2500 - /* apply/restore inotify watch */ 2501 - if (err == 0 && udev_event->inotify_watch) { 2502 - diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c 2503 - index 0f2b706..645b1e6 100644 2504 - --- a/src/vconsole/vconsole-setup.c 2505 - +++ b/src/vconsole/vconsole-setup.c 2506 - @@ -180,6 +180,10 @@ static int font_load(const char *vc, const char *font, const char *map, const ch 2507 - */ 2508 - static void font_copy_to_all_vcs(int fd) { 2509 - struct vt_stat vcs = {}; 2510 - + unsigned char map8[E_TABSZ]; 2511 - + unsigned short map16[E_TABSZ]; 2512 - + struct unimapdesc unimapd; 2513 - + struct unipair unipairs[USHRT_MAX]; 2514 - int i, r; 2515 - 2516 - /* get active, and 16 bit mask of used VT numbers */ 2517 - @@ -209,17 +213,35 @@ static void font_copy_to_all_vcs(int fd) { 2518 - cfo.op = KD_FONT_OP_COPY; 2519 - cfo.height = vcs.v_active-1; /* tty1 == index 0 */ 2520 - ioctl(vcfd, KDFONTOP, &cfo); 2521 - + 2522 - + /* copy map of 8bit chars */ 2523 - + if (ioctl(fd, GIO_SCRNMAP, map8) >= 0) 2524 - + ioctl(vcfd, PIO_SCRNMAP, map8); 2525 - + 2526 - + /* copy map of 8bit chars -> 16bit Unicode values */ 2527 - + if (ioctl(fd, GIO_UNISCRNMAP, map16) >= 0) 2528 - + ioctl(vcfd, PIO_UNISCRNMAP, map16); 2529 - + 2530 - + /* copy unicode translation table */ 2531 - + /* unimapd is a ushort count and a pointer to an 2532 - + array of struct unipair { ushort, ushort } */ 2533 - + unimapd.entries = unipairs; 2534 - + unimapd.entry_ct = USHRT_MAX; 2535 - + if (ioctl(fd, GIO_UNIMAP, &unimapd) >= 0) { 2536 - + struct unimapinit adv = { 0, 0, 0 }; 2537 - + 2538 - + ioctl(vcfd, PIO_UNIMAPCLR, &adv); 2539 - + ioctl(vcfd, PIO_UNIMAP, &unimapd); 2540 - + } 2541 - } 2542 - } 2543 - 2544 - int main(int argc, char **argv) { 2545 - const char *vc; 2546 - - char *vc_keymap = NULL; 2547 - - char *vc_keymap_toggle = NULL; 2548 - - char *vc_font = NULL; 2549 - - char *vc_font_map = NULL; 2550 - - char *vc_font_unimap = NULL; 2551 - - int fd = -1; 2552 - + _cleanup_free_ char 2553 - + *vc_keymap = NULL, *vc_keymap_toggle = NULL, 2554 - + *vc_font = NULL, *vc_font_map = NULL, *vc_font_unimap = NULL; 2555 - + _cleanup_close_ int fd = -1; 2556 - bool utf8; 2557 - pid_t font_pid = 0, keymap_pid = 0; 2558 - bool font_copy = false; 2559 - @@ -241,12 +263,12 @@ int main(int argc, char **argv) { 2560 - fd = open_terminal(vc, O_RDWR|O_CLOEXEC); 2561 - if (fd < 0) { 2562 - log_error("Failed to open %s: %m", vc); 2563 - - goto finish; 2564 - + return EXIT_FAILURE; 2565 - } 2566 - 2567 - if (!is_vconsole(fd)) { 2568 - log_error("Device %s is not a virtual console.", vc); 2569 - - goto finish; 2570 - + return EXIT_FAILURE; 2571 - } 2572 - 2573 - utf8 = is_locale_utf8(); 2574 - @@ -281,27 +303,27 @@ int main(int argc, char **argv) { 2575 - else 2576 - disable_utf8(fd); 2577 - 2578 - - r = EXIT_FAILURE; 2579 - - if (keymap_load(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid) >= 0 && 2580 - - font_load(vc, vc_font, vc_font_map, vc_font_unimap, &font_pid) >= 0) 2581 - - r = EXIT_SUCCESS; 2582 - - 2583 - -finish: 2584 - - if (keymap_pid > 0) 2585 - - wait_for_terminate_and_warn(KBD_LOADKEYS, keymap_pid); 2586 - + r = font_load(vc, vc_font, vc_font_map, vc_font_unimap, &font_pid); 2587 - + if (r < 0) { 2588 - + log_error("Failed to start " KBD_SETFONT ": %s", strerror(-r)); 2589 - + return EXIT_FAILURE; 2590 - + } 2591 - 2592 - - if (font_pid > 0) { 2593 - + if (font_pid > 0) 2594 - wait_for_terminate_and_warn(KBD_SETFONT, font_pid); 2595 - - if (font_copy) 2596 - - font_copy_to_all_vcs(fd); 2597 - + 2598 - + r = keymap_load(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid); 2599 - + if (r < 0) { 2600 - + log_error("Failed to start " KBD_LOADKEYS ": %s", strerror(-r)); 2601 - + return EXIT_FAILURE; 2602 - } 2603 - 2604 - - free(vc_keymap); 2605 - - free(vc_font); 2606 - - free(vc_font_map); 2607 - - free(vc_font_unimap); 2608 - + if (keymap_pid > 0) 2609 - + wait_for_terminate_and_warn(KBD_LOADKEYS, keymap_pid); 2610 - 2611 - - safe_close(fd); 2612 - + /* Only copy the font when we started setfont successfully */ 2613 - + if (font_copy && font_pid > 0) 2614 - + font_copy_to_all_vcs(fd); 2615 - 2616 - - return r; 2617 - + return EXIT_SUCCESS; 2618 - } 2619 - diff --git a/tmpfiles.d/systemd.conf b/tmpfiles.d/systemd.conf 2620 - index 7c6d6b9..c470045 100644 2621 - --- a/tmpfiles.d/systemd.conf 2622 - +++ b/tmpfiles.d/systemd.conf 2623 - @@ -23,6 +23,6 @@ d /run/systemd/machines 0755 root root - 2624 - d /run/systemd/shutdown 0755 root root - 2625 - 2626 - m /var/log/journal 2755 root systemd-journal - - 2627 - -m /var/log/journal/%m 2755 root systemd-journal - - 2628 - +Z /var/log/journal/%m 2755 root systemd-journal - - 2629 - m /run/log/journal 2755 root systemd-journal - - 2630 - -m /run/log/journal/%m 2755 root systemd-journal - - 2631 - +Z /run/log/journal/%m 2755 root systemd-journal - - 2632 76 diff --git a/units/console-getty.service.m4.in b/units/console-getty.service.m4.in 2633 77 index 8ac51a4..cae9fb5 100644 2634 78 --- a/units/console-getty.service.m4.in ··· 2654 98 Restart=always 2655 99 RestartSec=0 2656 100 diff --git a/units/emergency.service.in b/units/emergency.service.in 2657 - index 94c090f..0d20640 100644 101 + index 91fc1bb..6a37434 100644 2658 102 --- a/units/emergency.service.in 2659 103 +++ b/units/emergency.service.in 2660 104 @@ -15,7 +15,6 @@ Before=shutdown.target ··· 2663 107 WorkingDirectory=/root 2664 108 -ExecStartPre=-/bin/plymouth quit 2665 109 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.' 2666 - ExecStart=-/sbin/sulogin 2667 - ExecStopPost=@SYSTEMCTL@ --fail --no-block default 110 + ExecStart=-/bin/sh -c "/sbin/sulogin; @SYSTEMCTL@ --fail --no-block default" 111 + Type=idle 2668 112 diff --git a/units/getty@.service.m4 b/units/getty@.service.m4 2669 - index aa853b8..8bcc647 100644 113 + index 46164ab..f194a31 100644 2670 114 --- a/units/getty@.service.m4 2671 115 +++ b/units/getty@.service.m4 2672 116 @@ -23,11 +23,12 @@ IgnoreOnIsolate=yes ··· 2685 129 Restart=always 2686 130 RestartSec=0 2687 131 diff --git a/units/kmod-static-nodes.service.in b/units/kmod-static-nodes.service.in 2688 - index 368f980..d0c1bd2 100644 132 + index 0934a87..7e30c9e 100644 2689 133 --- a/units/kmod-static-nodes.service.in 2690 134 +++ b/units/kmod-static-nodes.service.in 2691 135 @@ -10,7 +10,6 @@ Description=Create list of required static device nodes for the current kernel 2692 136 DefaultDependencies=no 2693 137 Before=sysinit.target systemd-tmpfiles-setup-dev.service 2694 - ConditionCapability=CAP_MKNOD 138 + ConditionCapability=CAP_SYS_MODULE 2695 139 -ConditionPathExists=/lib/modules/%v/modules.devname 2696 140 2697 141 [Service] 2698 142 Type=oneshot 2699 143 diff --git a/units/local-fs.target b/units/local-fs.target 2700 - index ae3cedc..0e36840 100644 144 + index d2e5429..d26984b 100644 2701 145 --- a/units/local-fs.target 2702 146 +++ b/units/local-fs.target 2703 - @@ -13,3 +13,5 @@ DefaultDependencies=no 2704 - Conflicts=shutdown.target 147 + @@ -13,3 +13,5 @@ Conflicts=shutdown.target 148 + After=local-fs-pre.target 2705 149 OnFailure=emergency.target 2706 150 OnFailureJobMode=replace-irreversibly 2707 151 + ··· 2719 163 [Install] 2720 164 WantedBy=multi-user.target 2721 165 diff --git a/units/rescue.service.m4.in b/units/rescue.service.m4.in 2722 - index 552ef89..af3915f 100644 166 + index ef54369..0c841b3 100644 2723 167 --- a/units/rescue.service.m4.in 2724 168 +++ b/units/rescue.service.m4.in 2725 169 @@ -16,7 +16,6 @@ Before=shutdown.target ··· 2728 172 WorkingDirectory=/root 2729 173 -ExecStartPre=-/bin/plymouth quit 2730 174 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.' 2731 - ExecStart=-/sbin/sulogin 2732 - ExecStopPost=-@SYSTEMCTL@ --fail --no-block default 175 + ExecStart=-/bin/sh -c "/sbin/sulogin; @SYSTEMCTL@ --fail --no-block default" 176 + Type=idle 2733 177 diff --git a/units/serial-getty@.service.m4 b/units/serial-getty@.service.m4 2734 - index 4ac51e7..96daa5c 100644 178 + index 4522d0d..96daa5c 100644 2735 179 --- a/units/serial-getty@.service.m4 2736 180 +++ b/units/serial-getty@.service.m4 2737 - @@ -22,10 +22,8 @@ Before=getty.target 181 + @@ -22,7 +22,6 @@ Before=getty.target 2738 182 IgnoreOnIsolate=yes 2739 183 2740 184 [Service] 2741 185 -ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM 2742 186 Type=idle 2743 187 Restart=always 2744 - -RestartSec=0 2745 188 UtmpIdentifier=%I 2746 - TTYPath=/dev/%I 2747 - TTYReset=yes 2748 189 diff --git a/units/sysinit.target b/units/sysinit.target 2749 - index 8f4fb8f..e0f0147 100644 190 + index ec33503..4ac47b9 100644 2750 191 --- a/units/sysinit.target 2751 192 +++ b/units/sysinit.target 2752 - @@ -9,6 +9,5 @@ 193 + @@ -9,5 +9,4 @@ 2753 194 Description=System Initialization 2754 195 Documentation=man:systemd.special(7) 2755 196 Conflicts=emergency.service emergency.target 2756 197 -Wants=local-fs.target swap.target 2757 198 -After=local-fs.target swap.target emergency.service emergency.target 2758 199 +After=emergency.service emergency.target 2759 - RefuseManualStart=yes 2760 200 diff --git a/units/systemd-backlight@.service.in b/units/systemd-backlight@.service.in 2761 201 index e945d87..77728f2 100644 2762 202 --- a/units/systemd-backlight@.service.in ··· 2782 222 [Service] 2783 223 ExecStart=@rootbindir@/systemctl kill --kill-who=main --signal=SIGUSR1 systemd-journald.service 2784 224 diff --git a/units/systemd-journald.service.in b/units/systemd-journald.service.in 2785 - index de93879..c9a49f3 100644 225 + index 7013979..5241d08 100644 2786 226 --- a/units/systemd-journald.service.in 2787 227 +++ b/units/systemd-journald.service.in 2788 - @@ -25,3 +25,8 @@ WatchdogSec=1min 228 + @@ -26,3 +26,8 @@ WatchdogSec=1min 2789 229 # Increase the default a bit in order to allow many simultaneous 2790 230 # services being run since we keep one fd open per service. 2791 231 LimitNOFILE=16384 ··· 2794 234 +# journald to stop logging (see 2795 235 +# https://bugs.freedesktop.org/show_bug.cgi?id=56043). 2796 236 +X-RestartIfChanged=no 2797 - diff --git a/units/systemd-nspawn@.service.in b/units/systemd-nspawn@.service.in 2798 - index ff36e90..e373628 100644 2799 - --- a/units/systemd-nspawn@.service.in 2800 - +++ b/units/systemd-nspawn@.service.in 2801 - @@ -11,6 +11,7 @@ Documentation=man:systemd-nspawn(1) 2802 - 2803 - [Service] 2804 - ExecStart=@bindir@/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i 2805 - +KillMode=mixed 2806 - Type=notify 2807 - 2808 - [Install] 2809 237 diff --git a/units/systemd-random-seed.service.in b/units/systemd-random-seed.service.in 2810 238 index 1879b2f..9b895b9 100644 2811 239 --- a/units/systemd-random-seed.service.in ··· 2825 253 ExecStop=@rootlibexecdir@/systemd-rfkill save %I 2826 254 +X-RestartIfChanged=false 2827 255 diff --git a/units/systemd-tmpfiles-setup.service.in b/units/systemd-tmpfiles-setup.service.in 2828 - index 01043b7..507f820 100644 256 + index 72ab083..4f77e8f 100644 2829 257 --- a/units/systemd-tmpfiles-setup.service.in 2830 258 +++ b/units/systemd-tmpfiles-setup.service.in 2831 - @@ -12,7 +12,7 @@ DefaultDependencies=no 2832 - Wants=local-fs.target 259 + @@ -11,7 +11,7 @@ Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8) 260 + DefaultDependencies=no 2833 261 Conflicts=shutdown.target 2834 - After=systemd-readahead-collect.service systemd-readahead-replay.service local-fs.target 262 + After=systemd-readahead-collect.service systemd-readahead-replay.service local-fs.target systemd-sysusers.service 2835 263 -Before=sysinit.target shutdown.target 2836 264 +Before=shutdown.target 2837 - ConditionDirectoryNotEmpty=|/usr/lib/tmpfiles.d 2838 - ConditionDirectoryNotEmpty=|/lib/tmpfiles.d 2839 - ConditionDirectoryNotEmpty=|/usr/local/lib/tmpfiles.d 265 + RefuseManualStop=yes 266 + 267 + [Service] 2840 268 diff --git a/units/systemd-update-utmp.service.in b/units/systemd-update-utmp.service.in 2841 269 index da7dda7..e638145 100644 2842 270 --- a/units/systemd-update-utmp.service.in