]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #13936 from keszybz/format-table-uninhibited
authorAnita Zhang <the.anitazha@gmail.com>
Tue, 5 Nov 2019 23:03:15 +0000 (15:03 -0800)
committerGitHub <noreply@github.com>
Tue, 5 Nov 2019 23:03:15 +0000 (15:03 -0800)
Output tables at full width if piped

261 files changed:
hwdb.d/60-keyboard.hwdb
hwdb.d/parse_hwdb.py
man/systemd.net-naming-scheme.xml
src/activate/activate.c
src/analyze/analyze.c
src/basic/blockdev-util.c
src/basic/btrfs-util.c
src/basic/bus-label.h
src/basic/capability-util.c
src/basic/cgroup-util.c
src/basic/conf-files.c
src/basic/copy.c
src/basic/efivars.c
src/basic/env-util.c
src/basic/extract-word.c
src/basic/fd-util.c
src/basic/fileio.c
src/basic/format-util.c
src/basic/fs-util.c
src/basic/gcrypt-util.c
src/basic/glob-util.c
src/basic/glob-util.h
src/basic/hashmap.c
src/basic/hostname-util.c
src/basic/io-util.c
src/basic/locale-util.c
src/basic/log.c
src/basic/login-util.c
src/basic/mkdir.c
src/basic/parse-util.c
src/basic/path-util.c
src/basic/proc-cmdline.c
src/basic/process-util.c
src/basic/process-util.h
src/basic/replace-var.c
src/basic/rm-rf.c
src/basic/signal-util.c
src/basic/smack-util.c
src/basic/socket-label.c
src/basic/socket-util.c
src/basic/stat-util.c
src/basic/static-destruct.h
src/basic/string-table.h
src/basic/string-util.c
src/basic/string-util.h
src/basic/strv.c
src/basic/syslog-util.c
src/basic/terminal-util.c
src/basic/time-util.c
src/basic/tmpfile-util.c
src/basic/unit-name.c
src/basic/user-util.c
src/basic/utf8.c
src/basic/util.c
src/basic/util.h
src/basic/virt.c
src/basic/xattr-util.c
src/binfmt/binfmt.c
src/boot/bootctl.c
src/boot/efi/boot.c
src/busctl/busctl.c
src/cgls/cgls.c
src/cgroups-agent/cgroups-agent.c
src/cgtop/cgtop.c
src/core/bpf-firewall.c
src/core/dynamic-user.c
src/core/execute.c
src/core/job.c
src/core/kmod-setup.c
src/core/load-fragment.c
src/core/locale-setup.c
src/core/main.c
src/core/manager.c
src/core/namespace.c
src/core/selinux-access.c
src/core/service.c
src/core/smack-setup.c
src/core/socket.c
src/core/swap.c
src/core/unit.c
src/coredump/coredumpctl.c
src/cryptsetup/cryptsetup.c
src/delta/delta.c
src/fsck/fsck.c
src/fstab-generator/fstab-generator.c
src/getty-generator/getty-generator.c
src/gpt-auto-generator/gpt-auto-generator.c
src/hostname/hostnamed.c
src/journal-remote/journal-remote.c
src/journal-remote/microhttpd-util.c
src/journal/audit-type.h
src/journal/catalog.c
src/journal/compress.c
src/journal/fsprg.c
src/journal/journal-send.c
src/journal/journalctl.c
src/journal/journald-rate-limit.c
src/journal/journald-stream.c
src/libsystemd-network/dhcp-network.c
src/libsystemd-network/dhcp-option.c
src/libsystemd-network/dhcp6-network.c
src/libsystemd-network/dhcp6-option.c
src/libsystemd-network/icmp6-util.c
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd-network/sd-dhcp-lease.c
src/libsystemd-network/sd-dhcp6-client.c
src/libsystemd-network/sd-ipv4acd.c
src/libsystemd-network/sd-ipv4ll.c
src/libsystemd-network/sd-radv.c
src/libsystemd-network/test-dhcp6-client.c
src/libsystemd-network/test-ipv4ll.c
src/libsystemd-network/test-lldp.c
src/libsystemd/sd-bus/bus-error.c
src/libsystemd/sd-bus/bus-internal.h
src/libsystemd/sd-daemon/sd-daemon.c
src/libsystemd/sd-device/device-enumerator.c
src/libsystemd/sd-device/device-monitor.c
src/libsystemd/sd-hwdb/sd-hwdb.c
src/libsystemd/sd-login/sd-login.c
src/libsystemd/sd-login/test-login.c
src/libsystemd/sd-netlink/generic-netlink.c
src/libsystemd/sd-netlink/sd-netlink.c
src/libsystemd/sd-network/sd-network.c
src/libsystemd/sd-resolve/test-resolve.c
src/libudev/libudev.c
src/locale/keymap-util.c
src/locale/localectl.c
src/locale/localed.c
src/login/loginctl.c
src/login/logind-acl.c
src/login/logind-button.c
src/login/logind-core.c
src/login/logind-dbus.c
src/login/logind-inhibit.c
src/login/logind-seat-dbus.c
src/login/logind-seat.c
src/login/logind-session-dbus.c
src/login/logind-session-device.c
src/login/logind-session.c
src/login/logind-user-dbus.c
src/login/logind-user.c
src/login/logind-utmp.c
src/login/logind.c
src/login/sysfs-show.c
src/machine/machine-dbus.c
src/machine/machine.c
src/machine/machinectl.c
src/machine/machined-dbus.c
src/modules-load/modules-load.c
src/network/networkctl.c
src/network/networkd-link.h
src/network/networkd-lldp-tx.c
src/network/networkd-network.c
src/network/networkd-network.h
src/network/networkd-radv.c
src/network/networkd-radv.h
src/nspawn/nspawn-patch-uid.c
src/nspawn/nspawn-setuid.c
src/nspawn/nspawn.c
src/nss-myhostname/nss-myhostname.c
src/nss-resolve/nss-resolve.c
src/partition/growfs.c
src/partition/makefs.c
src/random-seed/random-seed.c
src/remount-fs/remount-fs.c
src/reply-password/reply-password.c
src/resolve/resolved-dns-dnssec.c
src/resolve/test-dns-packet.c
src/shared/ask-password-api.c
src/shared/bus-util.c
src/shared/calendarspec.c
src/shared/cgroup-setup.c
src/shared/cgroup-show.c
src/shared/clean-ipc.c
src/shared/condition.c
src/shared/conf-parser.c
src/shared/dm-util.c
src/shared/dns-domain.c
src/shared/efi-loader.c
src/shared/ethtool-util.c
src/shared/ethtool-util.h
src/shared/fdset.c
src/shared/firewall-util.c
src/shared/fstab-util.c
src/shared/import-util.c
src/shared/install-printf.c
src/shared/install.c
src/shared/json.c
src/shared/logs-show.c
src/shared/loop-util.c
src/shared/machine-image.c
src/shared/machine-pool.c
src/shared/mount-util.c
src/shared/pager.c
src/shared/path-lookup.c
src/shared/serialize.c
src/shared/sleep-config.c
src/shared/specifier.c
src/shared/switch-root.c
src/shared/sysctl-util.c
src/shared/utmp-wtmp.c
src/shared/verbs.c
src/shared/xml.c
src/shutdown/shutdown.c
src/shutdown/umount.c
src/sleep/sleep.c
src/socket-proxy/socket-proxyd.c
src/sysctl/sysctl.c
src/systemctl/systemctl.c
src/test/test-af-list.c
src/test/test-calendarspec.c
src/test/test-capability.c
src/test/test-cgroup.c
src/test/test-date.c
src/test/test-engine.c
src/test/test-env-util.c
src/test/test-exec-util.c
src/test/test-execute.c
src/test/test-extract-word.c
src/test/test-glob-util.c
src/test/test-id128.c
src/test/test-libudev.c
src/test/test-load-fragment.c
src/test/test-netlink-manual.c
src/test/test-process-util.c
src/test/test-seccomp.c
src/test/test-signal-util.c
src/test/test-strbuf.c
src/test/test-strv.c
src/test/test-strxcpyx.c
src/test/test-unit-file.c
src/test/test-unit-name.c
src/test/test-user-util.c
src/test/test-util.c
src/time-wait-sync/time-wait-sync.c
src/timedate/timedated.c
src/timesync/timesyncd-manager.c
src/tmpfiles/tmpfiles.c
src/tty-ask-password-agent/tty-ask-password-agent.c
src/udev/scsi_id/scsi_id.c
src/udev/scsi_id/scsi_serial.c
src/udev/udev-builtin-blkid.c
src/udev/udev-builtin-input_id.c
src/udev/udev-builtin-keyboard.c
src/udev/udev-builtin-kmod.c
src/udev/udev-builtin-net_id.c
src/udev/udev-builtin-path_id.c
src/udev/udev-builtin-usb_id.c
src/udev/udev-builtin.c
src/udev/udev-ctrl.c
src/udev/udev-event.c
src/udev/udev-node.c
src/udev/udevadm-info.c
src/udev/udevadm-monitor.c
src/udev/udevadm-settle.c
src/udev/udevd.c
src/update-utmp/update-utmp.c
src/vconsole/vconsole-setup.c
test/TEST-04-JOURNAL/test-journal.sh
test/fuzz/fuzz-network-parser/github-13938 [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

index 15f0a970b6c751ab6abfa946f08594e72cca4cf1..9227bee7ff55ae0c1b360ffd7183a249b63da3fb 100644 (file)
 #   XKB_FIXED_VARIANT=""
 # Examples of such devices: the Yubikey or other key-code generating
 # devices.
-#
+
+# A device where the scan code to key code mapping is insufficient and
+# requires a special key code to symbol configuration may specify that with:
+#   XKB_FIXED_MODEL="xkbmodel"
+# Examples of such devices: Chromebooks where the top row is used for both
+# media and F1-F10 keys.
+
 # To update this file, create a new file
 #   /etc/udev/hwdb.d/70-keyboard.hwdb
 # and add your rules there. To load the new rules execute (as root):
@@ -569,21 +575,6 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnHDX9494NR:pvr*
  KEYBOARD_KEY_d8=!f23                                   # touchpad off
  KEYBOARD_KEY_d9=!f22                                   # touchpad on
 
-# Chromebook 14
-# Top row keys (between ESC and power button)
-evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnFalco:pvr*
- KEYBOARD_KEY_3b=back
- KEYBOARD_KEY_3c=forward
- KEYBOARD_KEY_3d=refresh
- KEYBOARD_KEY_3f=switchvideomode
- KEYBOARD_KEY_40=brightnessdown
- KEYBOARD_KEY_41=brightnessup
- KEYBOARD_KEY_42=mute
- KEYBOARD_KEY_43=volumedown
- KEYBOARD_KEY_44=volumeup
- KEYBOARD_KEY_db=search # Same position as caps lock key on most keyboards
- # KEYBOARD_KEY_3e=fullscreen, no defined key sym
-
 # HP EliteBook 725 G2
 evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnHPLicrice:pvr*
 # HP ProBook 440 G2
@@ -1733,3 +1724,13 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnLENOVO:pn*:pvrThinkPadT560s
 # Lenovo ThinkPad X1 Carbon 3rd Gen
 evdev:atkbd:dmi:bvn*:bvr*:bd*:svnLENOVO:pn*:pvrThinkPadX1Carbon3rd
  KEYBOARD_LED_CAPSLOCK=0
+
+######################### FIXED MODEL DEVICES #############################
+# This section lists devices which require special handling in their key
+# code to keysym mapping by setting the xkb model.
+# The model must be an xkb compatible model (defined with XKB_FIXED_MODEL).
+
+# Chromebooks
+evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnFalco:pvr*
+evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnPeppy:pvr*
+ XKB_FIXED_MODEL="chromebook"
index c558687edc2839fc2109f141dd4f00c509216e67..9a933b82b290869d564f2e98630c77b253df723c 100755 (executable)
@@ -123,6 +123,7 @@ def property_grammar():
              ('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))),
              ('XKB_FIXED_LAYOUT', STRING),
              ('XKB_FIXED_VARIANT', STRING),
+             ('XKB_FIXED_MODEL', STRING),
              ('KEYBOARD_LED_NUMLOCK', Literal('0')),
              ('KEYBOARD_LED_CAPSLOCK', Literal('0')),
              ('ACCEL_MOUNT_MATRIX', mount_matrix),
index 91ad57df03fbd76a360f72defd51e25bdc873c53..419fed62ea435901872b03d0ef1ba61f19c7dfbc 100644 (file)
@@ -42,7 +42,7 @@
     <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
     Available naming schemes are described below.</para>
 
-    <para>After the udev proprties have been generated, appropriate udev rules may be used to actually rename
+    <para>After the udev properties have been generated, appropriate udev rules may be used to actually rename
     devices based on those properties. See the description of <varname>NamePolicy=</varname> and
     <varname>MACAddressPolicy=</varname> in
     <citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
index 2fe312f5a038cabb863ceee29878a7bec46cae6d..9948520c1f6855b9bb909f26b9f3c42046945b64 100644 (file)
@@ -3,7 +3,6 @@
 #include <getopt.h>
 #include <sys/epoll.h>
 #include <sys/prctl.h>
-#include <sys/socket.h>
 #include <sys/wait.h>
 #include <unistd.h>
 
index 2d541fe701711ea15b8560489073636c9ff49ec6..99729415207a9be0fcdd71b9d65f844d77cddb3d 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <getopt.h>
 #include <inttypes.h>
-#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
index cff18fc62d69a8fb6c50428c0ec4278f5c3aedfa..5372c26be688988341d1b442cd03d743d60b6dff 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <sys/stat.h>
-#include <sys/statfs.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index 540a1990ce0dea067aa89670f9f7ed709c0b898f..18a7217757936f3b4bce9893d9b878254f30fc10 100644 (file)
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
 #include <sys/sysmacros.h>
 #include <unistd.h>
 
index 664cfaf67f5d1f92aef20a30a579e9c45d9c72cc..4a1b097a52b8406c5add186981b66777abb58846 100644 (file)
@@ -3,7 +3,6 @@
 
 #include <stddef.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "string-util.h"
 
index d62bb62de4773501f767b7d449bbc6111f27a652..d084ad5cf559aaba9075989d79deded991cf8ba1 100644 (file)
@@ -1,10 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <grp.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/capability.h>
 #include <sys/prctl.h>
 #include <unistd.h>
 
index bdf3b9febda98930df2ea7306af57da269fefb0a..5b94b02a27e7e9ce581dc59f4b9fb628da2390a0 100644 (file)
@@ -1,15 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <dirent.h>
 #include <errno.h>
 #include <ftw.h>
 #include <limits.h>
 #include <signal.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
 #include <sys/types.h>
 #include <sys/utsname.h>
 #include <sys/xattr.h>
index 4bc6931b584c3100a05c37a7c8a76e8b80df0dae..58eb62fb7a55d3592c788f59ffa128755ec567f0 100644 (file)
@@ -1,11 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <dirent.h>
 #include <errno.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "conf-files.h"
 #include "def.h"
index e07f548fef9db35c1914c944158fa825e50c7311..bac321fe6831270421cdcddce070f9454d7f90f9 100644 (file)
@@ -1,16 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/sendfile.h>
-#include <sys/stat.h>
 #include <sys/xattr.h>
-#include <time.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index 53875de5a0a4eda44e51bd3190c571d1778b777a..daa66ac2d9d5951ceda85035ff776c72ab71d4f9 100644 (file)
@@ -4,9 +4,7 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <linux/fs.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
index a6503cf2b65175ff7e9da9fd746fefaeb363eebe..b8dc98915f8185f7ffcfd103b2e4a5c3ccd8337d 100644 (file)
@@ -4,7 +4,6 @@
 #include <limits.h>
 #include <stdarg.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index 34cfb36a4a806ce0ffa646de28c73340af5f684f..d7c215cb48e7a267e4bc5f3e2f28d19d62aaeec9 100644 (file)
@@ -6,7 +6,6 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
 #include <syslog.h>
 
 #include "alloc-util.h"
index 1024490f23bc4b60a9466bb359605ad97617494f..5d78fab8347986469ff3dcb4a27b373c98400097 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/resource.h>
-#include <sys/socket.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
index 82d27a5ba33ff421054bce680aa7401b3dedec63..714a00cd9ae77dcbda971e51ba3bce3b74bb1f0e 100644 (file)
@@ -8,7 +8,6 @@
 #include <stdint.h>
 #include <stdio_ext.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
index 9fea2e0690e5f4e344695212398dbd778ea78fc0..b4144e03521498f0adda6fe99b6d7aa667993a93 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <stdio.h>
-
 #include "format-util.h"
 #include "memory-util.h"
 #include "stdio-util.h"
index 9d2cff0d2499788447e09243be8d567094aeaa79..8b05d2402d7679c1c3a0b715faf8afc7b8d40bb0 100644 (file)
@@ -2,13 +2,9 @@
 
 #include <errno.h>
 #include <stddef.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
 #include <linux/falloc.h>
 #include <linux/magic.h>
-#include <time.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
@@ -662,15 +658,12 @@ int inotify_add_watch_fd(int fd, int what, uint32_t mask) {
 }
 
 int inotify_add_watch_and_warn(int fd, const char *pathname, uint32_t mask) {
-        if (inotify_add_watch(fd, pathname, mask) < 0) {
-                const char *reason;
 
+        if (inotify_add_watch(fd, pathname, mask) < 0) {
                 if (errno == ENOSPC)
-                        reason = "inotify watch limit reached";
-                else
-                        reason = strerror_safe(errno);
+                        return log_error_errno(errno, "Failed to add a watch for %s: inotify watch limit reached", pathname);
 
-                return log_error_errno(errno, "Failed to add a watch for %s: %s", pathname, reason);
+                return log_error_errno(errno, "Failed to add a watch for %s: %m", pathname);
         }
 
         return 0;
index 9bab47dd8a02613d8f089e4879ecca3837fa1236..a82be979dedd26ba2b489792fd2055767f7e13c3 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #if HAVE_GCRYPT
-#include <gcrypt.h>
 
 #include "gcrypt-util.h"
 #include "hexdecoct.h"
index b335af8d971ca7e84584847ea1739c8ceadfd8f8..e3aa6c2e152b4f9d7ecbb583770b02145188a838 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <dirent.h>
 #include <errno.h>
-#include <glob.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
index 8e226c1ee296edcb30c6a7d7f319d51e5167a926..8b1bb02be138471ef399b6a2442f9ff177b671aa 100644 (file)
@@ -3,7 +3,6 @@
 
 #include <glob.h>
 #include <stdbool.h>
-#include <string.h>
 
 #include "macro.h"
 #include "string-util.h"
index 2c4620abf09680c6a6d2b4b4f0d681b770de1580..4853514c96a6e66a608d03b3ad76271c456d1ac9 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "fileio.h"
index 5bfa028b39306b48a2482fd51d6217a77eafe063..7bc2e3f370fb650f5f2f0093f58afb8e1f46f54a 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <limits.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/utsname.h>
 #include <unistd.h>
 
index 4acd17df84178d80fcaf8a11b8e6ab891cd01b98..c906fc074171921fa3ff7ad6db0e05aab3db2595 100644 (file)
@@ -4,7 +4,6 @@
 #include <limits.h>
 #include <poll.h>
 #include <stdio.h>
-#include <time.h>
 #include <unistd.h>
 
 #include "io-util.h"
index e94c29939c7e6f810a67f07605c329777eff7325..b3c58057841aaa7828acc32df0e97fbe7dd739ba 100644 (file)
@@ -1,16 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <ftw.h>
 #include <langinfo.h>
 #include <libintl.h>
-#include <locale.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 
index 61faf00102264db796d514811946e67177c80b8d..17557e1844b2a0e9fecf94d9b8ebd06257b4d843 100644 (file)
@@ -6,14 +6,10 @@
 #include <limits.h>
 #include <stdarg.h>
 #include <stddef.h>
-#include <stdio.h>
-#include <string.h>
 #include <sys/signalfd.h>
-#include <sys/socket.h>
 #include <sys/time.h>
 #include <sys/uio.h>
 #include <sys/un.h>
-#include <time.h>
 #include <unistd.h>
 
 #include "sd-messages.h"
index 085ccd09154a4af16d3cc0070b8caaee86392327..9313926d5a7dece21628a43c43a5806beaaa725a 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <string.h>
-
 #include "login-util.h"
 #include "string-util.h"
 
index 1f318252a98e1e0445f54431a3ff8b1e9449f7f4..fa682d4c438e0abf3040d86ec28d319c8ccf3813 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <stdbool.h>
 #include <string.h>
-#include <sys/stat.h>
 
 #include "alloc-util.h"
 #include "format-util.h"
index 1ddb64fd2832d670f81cbc8018b404943d61d62d..aec6099c9cc175c81ea5818955ba3ae86176a6a5 100644 (file)
@@ -3,11 +3,9 @@
 #include <errno.h>
 #include <inttypes.h>
 #include <linux/oom.h>
-#include <locale.h>
 #include <net/if.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/socket.h>
 
 #include "alloc-util.h"
index 9777beadd8e67b83cd1936246c2d4acdc7eb6a43..f1be8d0988630874ddf3006d71dac788cad14f61 100644 (file)
@@ -4,8 +4,6 @@
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
 #include <unistd.h>
 
 /* When we include libgen.h because we need dirname() we immediately
index 44d1e9aec40724af7d20514d71503d0982613f42..bb2be068bb9c20a8cbd4c67dd97887026ad7d6e0 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <stdbool.h>
 #include <stddef.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "efivars.h"
index 9ab6e4fff6a9defb6df037dffef5c5a8d13fa453..aaec6a6a990cba740194f59d14163d2268140d80 100644 (file)
@@ -4,11 +4,9 @@
 #include <errno.h>
 #include <limits.h>
 #include <linux/oom.h>
-#include <signal.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/mman.h>
 #include <sys/mount.h>
 #include <sys/personality.h>
index 41d4759c971368a1680526e1298536139325ec44..5f4e174f04cb180ee1a8094cbd36e441ed04bd83 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
-#include <alloca.h>
 #include <errno.h>
 #include <sched.h>
 #include <signal.h>
index fd2b5c104f4838f18a312ea9bedce5e4e6e131d1..5b4737505ca192eae6c4a1e4e956200c9fe309fb 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "macro.h"
index 796eb93c4b3db0ac9c8607647296d3f892b29d5e..23cdfa469643ab08bfbb7d51a9c150a8f0f531df 100644 (file)
@@ -4,8 +4,6 @@
 #include <fcntl.h>
 #include <stdbool.h>
 #include <stddef.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index 509a18b82a81de831401628d9447dd2c833edbd9..bfb83419c98967dfd4ccdd25964f5939f24df7db 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <stdarg.h>
-#include <stdio.h>
 
 #include "macro.h"
 #include "parse-util.h"
index 123d00e13ee58c56b919043fe02c3ff9462de492..da9a2139d31a2d3b3c6f23da5b6e7054ea69d38d 100644 (file)
@@ -7,7 +7,6 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/xattr.h>
 #include <unistd.h>
index 64b1855deb2962612ac760114e926a30fa7ba4d9..8c087268e4b26f49c0d85dbb85a67826c14c60d5 100644 (file)
@@ -5,7 +5,6 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
 
index b216c252109a3bd1b84cc9ccbcf96d308c57831a..19dd053e362df32d9e42830b4c5c027de0f927c0 100644 (file)
@@ -11,7 +11,6 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
 
index 173054f9d7cf77cf283656168e32c831bce63682..8ef90e96b7e38fdb39b78b8cd2a392b30e92205f 100644 (file)
@@ -1,11 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <linux/magic.h>
 #include <sched.h>
-#include <sys/stat.h>
 #include <sys/statvfs.h>
 #include <sys/types.h>
 #include <unistd.h>
index 443c0e8ebb3b7b280ffbd8c877169d68a151dae5..8fbc07c5876a8b67bcd80a67120462438f799d01 100644 (file)
@@ -40,8 +40,8 @@ typedef struct StaticDestructor {
 extern const struct StaticDestructor _weak_ __start_SYSTEMD_STATIC_DESTRUCT[];
 extern const struct StaticDestructor _weak_ __stop_SYSTEMD_STATIC_DESTRUCT[];
 
-/* The function to destroy everything. (Note that this must be static inline, as it's key that it remains in the same
- * linking unit as the variables we want to destroy. */
+/* The function to destroy everything. (Note that this must be static inline, as it's key that it remains in
+ * the same linking unit as the variables we want to destroy.) */
 static inline void static_destruct(void) {
         const StaticDestructor *d;
 
index 42fe4f43158678e2ee20049218a779492b69b5f9..2d3cf81435bd0e371abe6635e24b361437f49aeb 100644 (file)
@@ -5,7 +5,6 @@
 #include <errno.h>
 #include <stddef.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/types.h>
 
 #include "macro.h"
index c1828687557eaed1e38d648c73a48f71633e5a41..8e6aa63806811bc8ab4c89094ab98ed86b813b7d 100644 (file)
@@ -5,7 +5,6 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "escape.h"
index 3981129db3180d7794ca99c62ad3a9ab638fcf29..04cc82b386088a7eb8b243a48356fa10c3a5a9e0 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
-#include <alloca.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
index 88b85867bb3bb60dc8d4181b03357021753f9215..30fab6307454d0a49c37525a8c31385b1c18768b 100644 (file)
@@ -5,7 +5,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "escape.h"
index fe129482f3d8a709b41a6aa92bd117d4a4f9bc5c..29c9ec9ac45d747ed6e55ad5b9606d9bca5fc3b5 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <string.h>
 #include <syslog.h>
 
 #include "hexdecoct.h"
index c732e8021cf77779ba58f69693c980b20df92764..98c3ff04ef2bacc9d4e0c72e325918302942e4b5 100644 (file)
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/inotify.h>
 #include <sys/ioctl.h>
-#include <sys/socket.h>
 #include <sys/sysmacros.h>
 #include <sys/time.h>
 #include <sys/types.h>
index 3018e81acb883f0903672378aa44311bd36c9f08..837948c253301a39737908a1ec352bcc73dbcdd5 100644 (file)
@@ -4,9 +4,7 @@
 #include <errno.h>
 #include <limits.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/mman.h>
-#include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/timerfd.h>
 #include <sys/timex.h>
index afcf58aeac8bb9aa1a840574fb2a28a7825552de..7cdaca4e406c29d861006fe5ae427e74ed8f7d80 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <stdio.h>
 #include <sys/mman.h>
 
 #include "alloc-util.h"
index 3e37e34325ee8e20952365daf06fc9315461f093..af8dca53cd983e66e47b3bd122c0c32391b11006 100644 (file)
@@ -4,7 +4,6 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "glob-util.h"
index 7a31a69e360828843500cdd2c7c3548b2c126598..93ba4eedd2772deda7c14aa6e413e042ba8ca10f 100644 (file)
@@ -1,15 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <alloca.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <grp.h>
-#include <pwd.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <utmp.h>
@@ -409,8 +405,10 @@ char* gid_to_name(gid_t gid) {
 }
 
 int in_gid(gid_t gid) {
-        gid_t *gids;
-        int ngroups, r, i;
+        _cleanup_free_ gid_t *allocated = NULL;
+        gid_t local[16], *p = local;
+        int ngroups = ELEMENTSOF(local);
+        unsigned attempt = 0;
 
         if (getgid() == gid)
                 return 1;
@@ -421,23 +419,39 @@ int in_gid(gid_t gid) {
         if (!gid_is_valid(gid))
                 return -EINVAL;
 
-        ngroups = getgroups(0, NULL);
-        if (ngroups < 0)
-                return -errno;
-        if (ngroups == 0)
-                return 0;
-
-        gids = newa(gid_t, ngroups);
+        for (;;) {
+                ngroups = getgroups(ngroups, p);
+                if (ngroups >= 0)
+                        break;
+                if (errno != EINVAL)
+                        return -errno;
+
+                /* Give up eventually */
+                if (attempt++ > 10)
+                        return -EINVAL;
+
+                /* Get actual size needed, and size the array explicitly. Note that this is potentially racy
+                 * to use (in multi-threaded programs), hence let's call this in a loop. */
+                ngroups = getgroups(0, NULL);
+                if (ngroups < 0)
+                        return -errno;
+                if (ngroups == 0)
+                        return false;
+
+                free(allocated);
+
+                allocated = new(gid_t, ngroups);
+                if (!allocated)
+                        return -ENOMEM;
 
-        r = getgroups(ngroups, gids);
-        if (r < 0)
-                return -errno;
+                p = allocated;
+        }
 
-        for (i = 0; i < r; i++)
-                if (gids[i] == gid)
-                        return 1;
+        for (int i = 0; i < ngroups; i++)
+                if (p[i] == gid)
+                        return true;
 
-        return 0;
+        return false;
 }
 
 int in_group(const char *name) {
index afc24700dd77a786d8cf9392916dece1b3785c3a..c857185ec85af19fda2fa0c0eb319c8178355e02 100644 (file)
@@ -26,7 +26,6 @@
 #include <errno.h>
 #include <stdbool.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "gunicode.h"
index b02471c483acf3e42e43cddc96993b9f6e660222..2b3b3918a32fc5c736b702b0469f743be7b764cd 100644 (file)
@@ -1,59 +1,29 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <alloca.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <sched.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #include <sys/mman.h>
-#include <sys/prctl.h>
-#include <sys/statfs.h>
-#include <sys/sysmacros.h>
-#include <sys/types.h>
-#include <unistd.h>
 
 #include "alloc-util.h"
-#include "btrfs-util.h"
 #include "build.h"
-#include "def.h"
-#include "device-nodes.h"
 #include "dirent-util.h"
 #include "env-file.h"
 #include "env-util.h"
 #include "fd-util.h"
 #include "fileio.h"
-#include "format-util.h"
-#include "hashmap.h"
 #include "hostname-util.h"
 #include "log.h"
 #include "macro.h"
 #include "parse-util.h"
-#include "path-util.h"
-#include "process-util.h"
-#include "procfs-util.h"
-#include "set.h"
-#include "signal-util.h"
 #include "stat-util.h"
-#include "static-destruct.h"
 #include "string-util.h"
-#include "strv.h"
-#include "time-util.h"
-#include "umask-util.h"
-#include "user-util.h"
 #include "util.h"
 #include "virt.h"
 
 int saved_argc = 0;
 char **saved_argv = NULL;
-char **saved_env = NULL;
 static int saved_in_initrd = -1;
 
-STATIC_DESTRUCTOR_REGISTER(saved_env, strv_freep);
-
 bool kexec_loaded(void) {
        _cleanup_free_ char *s = NULL;
 
@@ -301,7 +271,3 @@ void disable_coredumps(void) {
         if (r < 0)
                 log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m");
 }
-
-void save_env(void) {
-        saved_env = strv_copy(environ);
-}
index 15444b2e5c576c9d524cb2258521c1a460cc0201..6fc7480fcbd7697b6101832f301a766f78dbd03d 100644 (file)
@@ -13,9 +13,6 @@ static inline void save_argc_argv(int argc, char **argv) {
         saved_argv = argv;
 }
 
-extern char **saved_env;
-void save_env(void);
-
 bool kexec_loaded(void);
 
 int prot_from_flags(int flags) _const_;
index 3be3852e35c0e0829e45284a06bce54f7b610423..fe25a1a430a08d1fc891c0e5bcf9bb853b9c9a42 100644 (file)
@@ -6,7 +6,6 @@
 #include <errno.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index 2b79ce4b3182660543fa6f3f4a41892c187efe11..f4ac2b6f7bc6a93d471b0bab0b841f00d305be10 100644 (file)
@@ -4,7 +4,6 @@
 #include <fcntl.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/time.h>
 #include <sys/xattr.h>
 
index aa9d811f2e9d2769a2786bd3903405c93bc8d48f..7ff844c78c3a87253935b5ff93dcbff944658da3 100644 (file)
@@ -6,7 +6,6 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
index dcf5687a4318d2b1d7eaab2d09652f62ffd041bc..d8e8d8ce4099384b19fadc65d0ba5f06d154a0e0 100644 (file)
@@ -1,20 +1,14 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <blkid.h>
 #include <ctype.h>
-#include <dirent.h>
 #include <errno.h>
 #include <ftw.h>
 #include <getopt.h>
 #include <limits.h>
 #include <linux/magic.h>
 #include <stdbool.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
 #include <unistd.h>
 
 #include "sd-id128.h"
@@ -33,6 +27,7 @@
 #include "fs-util.h"
 #include "locale-util.h"
 #include "main-func.h"
+#include "mkdir.h"
 #include "pager.h"
 #include "parse-util.h"
 #include "pretty-print.h"
@@ -1370,6 +1365,13 @@ static int install_random_seed(const char *esp) {
         if (r < 0)
                 return log_error_errno(r, "Failed to acquire random seed: %m");
 
+        /* Normally create_subdirs() should already have created everything we need, but in case "bootctl
+         * random-seed" is called we want to just create the minimum we need for it, and not the full
+         * list. */
+        r = mkdir_parents(path, 0755);
+        if (r < 0)
+                return log_error_errno(r, "Failed to create parent directory for %s: %m", path);
+
         r = tempfn_random(path, "bootctl", &tmp);
         if (r < 0)
                 return log_oom();
index fb7abd1f38d11bb40b8846909c4c2507b46c99c7..849c3c63b6a984a951a6ef684e5c0029b8257924 100644 (file)
@@ -1300,6 +1300,7 @@ static VOID config_entry_bump_counters(
 static VOID config_entry_add_from_file(
                 Config *config,
                 EFI_HANDLE *device,
+                EFI_FILE *root_dir,
                 CHAR16 *path,
                 CHAR16 *file,
                 CHAR8 *content,
@@ -1310,6 +1311,8 @@ static VOID config_entry_add_from_file(
         UINTN pos = 0;
         CHAR8 *key, *value;
         UINTN len;
+        EFI_STATUS err;
+        EFI_FILE_HANDLE handle;
         _cleanup_freepool_ CHAR16 *initrd = NULL;
 
         entry = AllocatePool(sizeof(ConfigEntry));
@@ -1406,6 +1409,14 @@ static VOID config_entry_add_from_file(
                 return;
         }
 
+        /* check existence */
+        err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, entry->loader, EFI_FILE_MODE_READ, 0ULL);
+        if (EFI_ERROR(err)) {
+                config_entry_free(entry);
+                return;
+        }
+        uefi_call_wrapper(handle->Close, 1, handle);
+
         /* add initrd= to options */
         if (entry->type == LOADER_LINUX && initrd) {
                 if (entry->options) {
@@ -1503,7 +1514,7 @@ static VOID config_load_entries(
 
                         err = file_read(entries_dir, f->FileName, 0, 0, &content, NULL);
                         if (!EFI_ERROR(err))
-                                config_entry_add_from_file(config, device, L"\\loader\\entries", f->FileName, content, loaded_image_path);
+                                config_entry_add_from_file(config, device, root_dir, L"\\loader\\entries", f->FileName, content, loaded_image_path);
                 }
                 uefi_call_wrapper(entries_dir->Close, 1, entries_dir);
         }
index 8475c5bfddc5e7bb5e8129aed66ccb3a26337ee0..3ed8f21c96e7ccd9efe19609e5b31541480ad59f 100644 (file)
@@ -342,8 +342,6 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
         if (r < 0)
                 return log_error_errno(r, "Failed to show table: %m");
 
-
-
         return 0;
 }
 
index 34d95c76600671a8b7e74a13693929a8ada535e8..b55d7299cabf03529f44669af5a8d6578d01c6d2 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <getopt.h>
 #include <stdio.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "sd-bus.h"
index 9721a32ed6d93449f87583bd61232d5d4c0783bc..ace7d6c5ae9c416d48daa743b764a817bdcc2648 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <stdlib.h>
-#include <sys/socket.h>
 
 #include "fd-util.h"
 #include "log.h"
index 61663b2c1cc531c5e4f17f8fbb2357a50403bd2f..2494c70238cc9a18d9372aa71d0d872e648975a7 100644 (file)
@@ -1,12 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <alloca.h>
 #include <errno.h>
 #include <getopt.h>
 #include <signal.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "sd-bus.h"
index a637437a5a6abb2d7cacc7f57e1780dcb7f9a399..424162f4458d947fa8eaae3946fb946d3fd3ce23 100644 (file)
@@ -12,7 +12,6 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index e7a2f645251650ffebda76267cf9efc97a35a1bb..75373407b4852cd7cf1739eba93a88c960845231 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <grp.h>
-#include <pwd.h>
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/types.h>
index 4401e30e65a7e41885ff25bd471f80106f2f7d51..1c22c3d80edda4ca87d686520f5a6b6f54bd3393 100644 (file)
@@ -2,20 +2,13 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <glob.h>
-#include <grp.h>
 #include <poll.h>
-#include <signal.h>
-#include <string.h>
-#include <sys/capability.h>
 #include <sys/eventfd.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <sys/personality.h>
 #include <sys/prctl.h>
 #include <sys/shm.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/un.h>
 #include <unistd.h>
index 9537366eb9aa0275651319cb985bda0f3abfe722..c5c0651304cc03955690b518ab0abe478d3b52e3 100644 (file)
@@ -418,21 +418,21 @@ JobType job_type_collapse(JobType t, Unit *u) {
 
         case JOB_TRY_RESTART:
                 s = unit_active_state(u);
-                if (UNIT_IS_INACTIVE_OR_DEACTIVATING(s))
+                if (!UNIT_IS_ACTIVE_OR_RELOADING(s))
                         return JOB_NOP;
 
                 return JOB_RESTART;
 
         case JOB_TRY_RELOAD:
                 s = unit_active_state(u);
-                if (UNIT_IS_INACTIVE_OR_DEACTIVATING(s))
+                if (!UNIT_IS_ACTIVE_OR_RELOADING(s))
                         return JOB_NOP;
 
                 return JOB_RELOAD;
 
         case JOB_RELOAD_OR_START:
                 s = unit_active_state(u);
-                if (UNIT_IS_INACTIVE_OR_DEACTIVATING(s))
+                if (!UNIT_IS_ACTIVE_OR_RELOADING(s))
                         return JOB_START;
 
                 return JOB_RELOAD;
index a91cfebc6781f77c260b43dd64768b38ab0fe4e5..128674327362e405f9d10db96d3d0b8bf3d2d4d7 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <ftw.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
@@ -13,7 +12,6 @@
 #include "string-util.h"
 
 #if HAVE_KMOD
-#include <libkmod.h>
 #include "module-util.h"
 
 static void systemd_kmod_log(
index f991b7f5e87e091f425ffaa30bc17ba54cfa8759..288de616b65a1d8929447eb561e04c6aba7e35bd 100644 (file)
@@ -11,9 +11,7 @@
 #include <seccomp.h>
 #endif
 #include <sched.h>
-#include <string.h>
 #include <sys/resource.h>
-#include <sys/stat.h>
 
 #include "af-list.h"
 #include "alloc-util.h"
index aa4a89c17abc8927da4a6f48939601c5f95745e6..33728b0ff28c1d62a2ab96bf56998406ba7b6bbd 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "env-file.h"
 #include "env-util.h"
index 7c814f3237045c311543b6e1c1f26f8acbef7cc1..bfbb9331f32f18013e0610c2d2898d4d34f2bd95 100644 (file)
@@ -3,13 +3,9 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
-#include <signal.h>
-#include <stdio.h>
-#include <string.h>
 #include <sys/mount.h>
 #include <sys/prctl.h>
 #include <sys/reboot.h>
-#include <sys/stat.h>
 #include <unistd.h>
 #if HAVE_SECCOMP
 #include <seccomp.h>
@@ -146,6 +142,9 @@ static OOMPolicy arg_default_oom_policy;
 static CPUSet arg_cpu_affinity;
 static NUMAPolicy arg_numa_policy;
 
+/* A copy of the original environment block */
+static char **saved_env = NULL;
+
 static int parse_configuration(const struct rlimit *saved_rlimit_nofile,
                                const struct rlimit *saved_rlimit_memlock);
 
@@ -2353,6 +2352,17 @@ static bool early_skip_setup_check(int argc, char *argv[]) {
         return found_deserialize; /* When we are deserializing, then we are reexecuting, hence avoid the extensive setup */
 }
 
+static int save_env(void) {
+        char **l;
+
+        l = strv_copy(environ);
+        if (!l)
+                return -ENOMEM;
+
+        strv_free_and_replace(saved_env, l);
+        return 0;
+}
+
 int main(int argc, char *argv[]) {
 
         dual_timestamp initrd_timestamp = DUAL_TIMESTAMP_NULL, userspace_timestamp = DUAL_TIMESTAMP_NULL, kernel_timestamp = DUAL_TIMESTAMP_NULL,
@@ -2391,9 +2401,13 @@ int main(int argc, char *argv[]) {
         /* Save the original command line */
         save_argc_argv(argc, argv);
 
-        /* Save the original environment as we might need to restore it if we're requested to
-         * execute another system manager later. */
-        save_env();
+        /* Save the original environment as we might need to restore it if we're requested to execute another
+         * system manager later. */
+        r = save_env();
+        if (r < 0) {
+                error_message = "Failed to copy environment block";
+                goto finish;
+        }
 
         /* Make sure that if the user says "syslog" we actually log to the journal. */
         log_set_upgrade_syslog_to_journal(true);
@@ -2681,6 +2695,8 @@ finish:
         arg_serialization = safe_fclose(arg_serialization);
         fds = fdset_free(fds);
 
+        saved_env = strv_free(saved_env);
+
 #if HAVE_VALGRIND_VALGRIND_H
         /* If we are PID 1 and running under valgrind, then let's exit
          * here explicitly. valgrind will only generate nice output on
index c9032fced8ea6720c318c30e7932123cde5ab88f..700493ee0dde0503f21ed6f288e17418916f09a0 100644 (file)
@@ -3,8 +3,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <linux/kd.h>
-#include <signal.h>
-#include <string.h>
 #include <sys/epoll.h>
 #include <sys/inotify.h>
 #include <sys/ioctl.h>
index dfc7f9fb1c996278cd9ebac82f976996e9ce7119..df0455b7ebd27da270d680a6375d325c870bc9cf 100644 (file)
@@ -3,9 +3,7 @@
 #include <errno.h>
 #include <sched.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/mount.h>
-#include <sys/stat.h>
 #include <unistd.h>
 #include <linux/fs.h>
 
index cb136322fe1f9adae5cdfa8df37d030973b322e6..9fd3099feab24f86c28aeaa2bf1fff8ae23453d0 100644 (file)
@@ -7,7 +7,6 @@
 #include <errno.h>
 #include <selinux/avc.h>
 #include <selinux/selinux.h>
-#include <stdio.h>
 #if HAVE_AUDIT
 #include <libaudit.h>
 #endif
index e0d359890a261155415cc692f88b5df946a7a775..ebbd99a3cc507a7699db2fe3dda03e00cb996efc 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <signal.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
index e2d4c0d6e1726ab3d6f73b0d2f576e98e3d0c8ca..4427397f27153f31ff8a63f2cde7951db1a10200 100644 (file)
@@ -5,12 +5,10 @@
         Nathaniel Chen <nathaniel.chen@intel.com>
 ***/
 
-#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index ee8ed3fd068a4879f570e09aca9cd6eedf904c91..fc5ee69c9c90dcba61817a372390585a77aa5a54 100644 (file)
@@ -5,7 +5,6 @@
 #include <fcntl.h>
 #include <mqueue.h>
 #include <netinet/tcp.h>
-#include <signal.h>
 #include <sys/epoll.h>
 #include <sys/stat.h>
 #include <unistd.h>
index c184afa29dff00cd6aeb85fe3b66c761a7b2bbce..e4b018616d90b417cd0ed3da41e5ed381efeedea 100644 (file)
@@ -727,7 +727,6 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) {
         if (s->result == SWAP_SUCCESS)
                 s->result = f;
 
-
         r = unit_kill_context(UNIT(s),
                               &s->kill_context,
                               state_to_kill_operation(s, state),
@@ -929,7 +928,6 @@ static int swap_stop(Unit *u) {
                 swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, SWAP_SUCCESS);
                 return 0;
 
-
         default:
                 assert_not_reached("Unexpected state.");
         }
index 3107b9b148245958c167ad7f9d5fe1eaa6f35c02..5f2ca447015a52739ecf7de1be47bff212566d5b 100644 (file)
@@ -2,9 +2,7 @@
 
 #include <errno.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/prctl.h>
-#include <sys/stat.h>
 #include <unistd.h>
 
 #include "sd-id128.h"
index 4b972481d947a2f504d1ea7feab8ebbce9eda247..d68ff1c3663106c0cbc1219ce04c91b7d2d8c6cf 100644 (file)
@@ -4,7 +4,6 @@
 #include <getopt.h>
 #include <locale.h>
 #include <stdio.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "sd-bus.h"
index ebefb4d4d27386be83e860721434a62a8192f5d5..dd8c178fcbe13e22864b0fc746453b51ae608be9 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <mntent.h>
-#include <string.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/types.h>
index cd33850b969c7772b0750e07e4ba1b10435f7fcb..2d80d3a664b3871edcb4c190fba3c5f152c8a6e8 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <getopt.h>
-#include <string.h>
 #include <sys/prctl.h>
 #include <unistd.h>
 
index 55e6544d318b4ab042ed2523e73287bf5a420d9a..80f7107b9d9758aaac1445de1487b68ffd6a924b 100644 (file)
@@ -6,7 +6,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdbool.h>
-#include <stdio.h>
 #include <sys/file.h>
 #include <sys/prctl.h>
 #include <sys/stat.h>
index 90e7237576185877652315d26bf0014f9207fefc..abe4413f929dd6374efba748ed27163053ef5033 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <mntent.h>
 #include <stdio.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index 4563daf3ad0187a14c93ae77a72b34d2eef41996..be386120603b8ec98e7d5b8f1d1b6a8e7ecaebf0 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index 5affc57b79067f586dcad3b99c7553423f8b4044..de51801d23a69c7302bd2f3462a595bbac1a98a7 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <blkid.h>
 #include <stdlib.h>
-#include <sys/statfs.h>
 #include <unistd.h>
 
 #include "sd-device.h"
index 9e4f4fb59e71be38280f98964e9872d43f5c015f..deecd9b8db30d310a7d2607ec9cbff57c5b72f68 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <sys/utsname.h>
 #include <sys/stat.h>
 #include <sys/types.h>
index 35efe7002b030dfb3987711f402413d24b75b2dd..b241d3355d6048118ac71556e13fc0beccf3f75c 100644 (file)
@@ -2,11 +2,8 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/prctl.h>
-#include <sys/socket.h>
 #include <stdint.h>
 
 #include "sd-daemon.h"
index 5f5691995da537cd13b40cd142d932c3bbf45306..939af12572be47d932b0a3bf88ae94ea26b2443a 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <stddef.h>
 #include <stdio.h>
-#include <string.h>
 
 #if HAVE_GNUTLS
 #include <gnutls/gnutls.h>
index 98e5c39420e6360e812fa5f24c6d618f95b8b34a..39d917894e0f396be695d352f24f651929a5eecd 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
-#include <alloca.h>
 #include <stdio.h>
 
 #include "alloc-util.h"
index 060193d2acab3890fd818156b17c671d3b3c6546..70b2c8b46c4e445821f87ac206d7eaaf855a424c 100644 (file)
@@ -4,7 +4,6 @@
 #include <fcntl.h>
 #include <locale.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/types.h>
index bfb75ae8c9dca8afeae36e07cf7c9765b2083d51..4e00e4fc5e721c07f922905abd03dce6b62abc02 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <inttypes.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
index d60fc50068974dba2e099c257ae6114469510cb5..1dda2149d46ffcd14fc260874bc23f58729c3171 100644 (file)
@@ -27,7 +27,6 @@
  * http://eprint.iacr.org/2013/397
  */
 
-#include <gcrypt.h>
 #include <string.h>
 
 #include "fsprg.h"
index 5ef11fa1a48820366730a5aaf7ec7b213a7f3d44..912ecef73cce0d13a5a8967e0752d1acc624fa15 100644 (file)
@@ -4,7 +4,6 @@
 #include <fcntl.h>
 #include <printf.h>
 #include <stddef.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
 
index 6d9b5cfc2fbf730d921c599e6d2b0f053f2b3d74..e5a2f6efcf47bcb9e64c2c39d355384e4fba150e 100644 (file)
@@ -5,13 +5,11 @@
 #include <fnmatch.h>
 #include <getopt.h>
 #include <linux/fs.h>
-#include <locale.h>
 #include <poll.h>
 #include <signal.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/inotify.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -2242,9 +2240,6 @@ int main(int argc, char *argv[]) {
                 HASHMAP_FOREACH(d, j->directories_by_path, i) {
                         int q;
 
-                        if (d->is_root)
-                                continue;
-
                         q = journal_directory_vacuum(d->path, arg_vacuum_size, arg_vacuum_n_files, arg_vacuum_time, NULL, !arg_quiet);
                         if (q < 0) {
                                 log_error_errno(q, "Failed to vacuum %s: %m", d->path);
index 30a3fa8720d0c761d08b91964c09099c69bc4af4..af7196c6dee35266588f72834d19a3e78d8bd371 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "hashmap.h"
index afebadeccc77f53a59ade846ede8cb9a4ae22d51..22a70ce5a69ff217098fa3b7bf20cd89730080c0 100644 (file)
@@ -487,11 +487,22 @@ static int stdout_stream_scan(StdoutStream *s, bool force_flush) {
 }
 
 static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
+        uint8_t buf[CMSG_SPACE(sizeof(struct ucred))];
         StdoutStream *s = userdata;
+        struct ucred *ucred = NULL;
+        struct cmsghdr *cmsg;
+        struct iovec iovec;
         size_t limit;
         ssize_t l;
         int r;
 
+        struct msghdr msghdr = {
+                .msg_iov = &iovec,
+                .msg_iovlen = 1,
+                .msg_control = buf,
+                .msg_controllen = sizeof(buf),
+        };
+
         assert(s);
 
         if ((revents|EPOLLIN|EPOLLHUP) != (EPOLLIN|EPOLLHUP)) {
@@ -511,20 +522,50 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
          * always leave room for a terminating NUL we might need to add. */
         limit = MIN(s->allocated - 1, s->server->line_max);
 
-        l = read(s->fd, s->buffer + s->length, limit - s->length);
+        iovec = IOVEC_MAKE(s->buffer + s->length, limit - s->length);
+
+        l = recvmsg(s->fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
         if (l < 0) {
-                if (errno == EAGAIN)
+                if (IN_SET(errno, EINTR, EAGAIN))
                         return 0;
 
                 log_warning_errno(errno, "Failed to read from stream: %m");
                 goto terminate;
         }
+        cmsg_close_all(&msghdr);
 
         if (l == 0) {
                 stdout_stream_scan(s, true);
                 goto terminate;
         }
 
+        CMSG_FOREACH(cmsg, &msghdr)
+                if (cmsg->cmsg_level == SOL_SOCKET &&
+                    cmsg->cmsg_type == SCM_CREDENTIALS &&
+                    cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred))) {
+                        ucred = (struct ucred *)CMSG_DATA(cmsg);
+                        break;
+                }
+
+        /* Invalidate the context if the pid of the sender changed.
+         * This happens when a forked process inherits stdout / stderr
+         * from a parent. In this case getpeercred returns the ucred
+         * of the parent, which can be invalid if the parent has exited
+         * in the meantime.
+         */
+        if (ucred && ucred->pid != s->ucred.pid) {
+                /* force out any previously half-written lines from a
+                 * different process, before we switch to the new ucred
+                 * structure for everything we just added */
+                r = stdout_stream_scan(s, true);
+                if (r < 0)
+                        goto terminate;
+
+                s->ucred = *ucred;
+                client_context_release(s->server, s->context);
+                s->context = NULL;
+        }
+
         s->length += l;
         r = stdout_stream_scan(s, false);
         if (r < 0)
@@ -562,6 +603,10 @@ int stdout_stream_install(Server *s, int fd, StdoutStream **ret) {
         if (r < 0)
                 return log_error_errno(r, "Failed to determine peer credentials: %m");
 
+        r = setsockopt_int(fd, SOL_SOCKET, SO_PASSCRED, true);
+        if (r < 0)
+                return log_error_errno(r, "SO_PASSCRED failed: %m");
+
         if (mac_selinux_use()) {
                 r = getpeersec(fd, &stream->label);
                 if (r < 0 && r != -EOPNOTSUPP)
index 8e7f8a65ab64014064456fa08bfa8635f2da795b..f48e7c34909291117744fbb79a8c6966a531b960 100644 (file)
@@ -9,7 +9,6 @@
 #include <net/if_arp.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/socket.h>
 #include <linux/filter.h>
 #include <linux/if_infiniband.h>
 #include <linux/if_packet.h>
index 78baeb73335c13adfb6bac8f526484aacf3f3139..061cfde2f056c3cf6d34cc7ea3cc12bdd4e01f5a 100644 (file)
@@ -6,7 +6,6 @@
 #include <errno.h>
 #include <stdint.h>
 #include <stdio.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "dhcp-internal.h"
index 580f43ba4096c614d13c9dcb29d08acb18a5c35e..f82afe6a0915258fb7fec47dc720694ee541c43d 100644 (file)
@@ -8,7 +8,6 @@
 #include <netinet/ip6.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/socket.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <linux/if_packet.h>
index ca67559e6f04b86de032afa2c4fe23438b916735..9f5352a60d7c3f4d6e55b3fcd16ce5f685d15530 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <errno.h>
 #include <netinet/in.h>
-#include <string.h>
 
 #include "sd-dhcp6-client.h"
 
index e1f193ab24c487fa11dffe692aa5d344d61cd735..dbb1e51a0e0d9567d59706d4591d551d34f4cdb6 100644 (file)
@@ -9,7 +9,6 @@
 #include <netinet/ip6.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/socket.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <net/if.h>
index 1c5de5392ca7ebed69d3e92dc5884104a508e9b0..ef330fe28ebd6bd1213b9551e01909c13a8e7693 100644 (file)
@@ -8,7 +8,6 @@
 #include <net/if_arp.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/ioctl.h>
 #include <linux/if_infiniband.h>
 
index 800caec8411a51ce1dfc7916635693a5d53723fd..48e8aad8f3da480fd247588093b97d6814f8947b 100644 (file)
@@ -5,9 +5,7 @@
 
 #include <arpa/inet.h>
 #include <errno.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
index 33420fd4c095c3c56d82e465caf775fcc3d1ddda..95b7237382c032ad6f9657c59160de9f236bfc8d 100644 (file)
@@ -4,7 +4,6 @@
 ***/
 
 #include <errno.h>
-#include <string.h>
 #include <sys/ioctl.h>
 #include <linux/if_arp.h>
 #include <linux/if_infiniband.h>
index 5a24f38ae9e340c3560dcf120fb3f5176e236fb0..5a0b6e45dc53636e592d3c576af8d281f3e8efce 100644 (file)
@@ -8,7 +8,6 @@
 #include <netinet/if_ether.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "sd-ipv4acd.h"
 
index 3104d8c5a8e5ea5e077e79ba49071d20ab2dcda7..fa9b4f60397676a0dc2aeead8ca9679361aae543 100644 (file)
@@ -7,7 +7,6 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "sd-id128.h"
 #include "sd-ipv4acd.h"
index 5c7f727faa69bff79965c05e49b74e275788bc37..873a2f40f84363182fb8ef066bd908c7455b9c5e 100644 (file)
@@ -99,6 +99,13 @@ static sd_radv *radv_free(sd_radv *ra) {
                 sd_radv_prefix_unref(p);
         }
 
+        while (ra->route_prefixes) {
+                sd_radv_route_prefix *p = ra->route_prefixes;
+
+                LIST_REMOVE(prefix, ra->route_prefixes, p);
+                sd_radv_route_prefix_unref(p);
+        }
+
         free(ra->rdnss);
         free(ra->dnssl);
 
index 0983d7b51b807d160518ac89b04e4e4eb59434d2..4b89b320b756cf67d06f4bb9aa5408b576db3aae 100644 (file)
@@ -7,7 +7,6 @@
 #include <net/if_arp.h>
 #include <stdbool.h>
 #include <stdio.h>
-#include <sys/socket.h>
 #include <sys/types.h>
 #include <unistd.h>
 
index 156718f20936677065e7610db26c6fefc28c42fb..2f319bf7d9d07b94d80953008fc21e9f0b51c23b 100644 (file)
@@ -7,7 +7,6 @@
 #include <netinet/if_ether.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/socket.h>
 #include <sys/types.h>
 #include <unistd.h>
 
index 7406f94ce06ec492da7996f2bd3b36a49eb74e3f..a2ac65095f2c6d7b065c75015a4b4c78eeb65c77 100644 (file)
@@ -4,7 +4,6 @@
 #include <errno.h>
 #include <net/ethernet.h>
 #include <stdio.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "sd-event.h"
index ac1a954546cb62f6dd4b0aee99c78ee8d9979337..f760f0fdd21caeadb80c1fa96c0f81e6efb12fc2 100644 (file)
@@ -5,7 +5,6 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "sd-bus.h"
 
index 6d2c1e84051a8ac0df1f365b69a6ca973c7957a7..352a419e25d76516d762e7a98d6e97acf1239af3 100644 (file)
@@ -2,7 +2,6 @@
 #pragma once
 
 #include <pthread.h>
-#include <sys/socket.h>
 
 #include "sd-bus.h"
 
index 9e8f0a73f57c2825c084bf54163e5f39a844fa98..ff71194331b08fa43497da23db9300ff64f9bed7 100644 (file)
@@ -8,8 +8,6 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/un.h>
 #include <unistd.h>
index 5b54641213ee180d250e939957e91bb032a5f20a..a1932f41f9b7f811085dc1e2ecff36b8d028d426 100644 (file)
@@ -506,7 +506,10 @@ static int enumerator_scan_dir_and_add_devices(sd_device_enumerator *enumerator,
 
                 initialized = sd_device_get_is_initialized(device);
                 if (initialized < 0) {
-                        r = initialized;
+                        if (initialized != -ENOENT)
+                                /* this is necessarily racey, so ignore missing devices */
+                                r = initialized;
+
                         continue;
                 }
 
@@ -639,7 +642,9 @@ static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const c
 
                 k = sd_device_get_subsystem(device, &subsystem);
                 if (k < 0) {
-                        r = k;
+                        if (k != -ENOENT)
+                                /* this is necessarily racy, so ignore missing devices */
+                                r = k;
                         continue;
                 }
 
index 52e51fdd665ee09e0c4b5c86b6d976efe1ea939e..42753abe0834aa3dbe8744c0694461de09dbe1f3 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <linux/filter.h>
 #include <linux/netlink.h>
-#include <sys/socket.h>
 #include <unistd.h>
 
 #include "sd-device.h"
index 58124abd21d0f44496a22dd686b97934195f7fff..b3febdbb313376c8bbb00c823466bc10450f598b 100644 (file)
@@ -8,7 +8,6 @@
 #include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 
index ef22e190e4fa77908d66641e127f131e5ba8e889..fbfd89b69b1d557be99d89b69884ccf0f3a26e9d 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <poll.h>
-#include <string.h>
 #include <sys/inotify.h>
 #include <unistd.h>
 
index e9df5f8bc59023b98e852d69e0ab6bf137600a73..49ed24727868db29acb1bbd045366f38070a52f7 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <poll.h>
-#include <string.h>
 
 #include "sd-login.h"
 
index 2576f4831d36bccb333f89dbda2022798d2b18f6..b4971da323db89ca61c6183650a78daaa1d65bbd 100644 (file)
@@ -99,7 +99,6 @@ static int lookup_id(sd_netlink *nl, sd_genl_family family, uint16_t *id) {
                 return 0;
         }
 
-
         r = sd_genl_message_new(nl, SD_GENL_ID_CTRL, CTRL_CMD_GETFAMILY, &req);
         if (r < 0)
                 return r;
index 013e8ae95798f2e73d0598a1f9a6e352348b2af7..87350e8591dc7ecca902615673328aa396b6881a 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <poll.h>
-#include <sys/socket.h>
 
 #include "sd-netlink.h"
 
index bdd891d0cd1f911e5763b5c930f3831416d10d88..dc5ccb793bc9d7b36dc0661553b1263403c42910 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <poll.h>
-#include <string.h>
 #include <sys/inotify.h>
 
 #include "sd-network.h"
index 8de7adcd16d7abcd81d9497c36c1bfc0e76fb49e..38a78ee8a25c810be7a47022c2f18506a268fdd3 100644 (file)
@@ -5,8 +5,6 @@
 #include <netinet/in.h>
 #include <resolv.h>
 #include <stdio.h>
-#include <string.h>
-#include <sys/socket.h>
 
 #include "sd-resolve.h"
 
index af7312a011075a43b1f1380579de6f56dc889be5..b4450727ca5e7351926af6c345634d08de9f357e 100644 (file)
@@ -5,7 +5,6 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "libudev.h"
 
index f8c36c94f5dbf3c3beb74b29bcb2e7c7dcff8a87..519dd0d188cfea6abd2f3efb26578989d7c291c0 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
index 5532e932551a4ca2a1d82b9308972d3bc9c89c54..fb02bfd4a639db2882f36b4f48b235175d11dc5a 100644 (file)
@@ -2,10 +2,8 @@
 
 #include <ftw.h>
 #include <getopt.h>
-#include <locale.h>
 #include <stdbool.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "sd-bus.h"
 
index 8d0eec96a53b6b7966139bb3bf3c82e0d639ea2f..baf0bd102ba99d58fdf25749affb35e1f69fad87 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
index 706a4e45fefddbad53a8eaa59b6f76424b0cf79e..26681ac947566611f4fc6011b9fcdee2c6782a30 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <getopt.h>
 #include <locale.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "sd-bus.h"
index 2e13e4aed6501d331f82b22b0d13813912b09646..ff192c53eb962f650fe7a9bee162b55601169d66 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 
 #include "sd-device.h"
 
index 5598fb2c0b30e6187008779533aafdc256b310a8..9ec235a1709d73c816a609941671dfe4051673a7 100644 (file)
@@ -2,10 +2,8 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <string.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
-#include <linux/input.h>
 
 #include "sd-messages.h"
 
index b981544e12d72a36dd35bc78d511d8a09c62cf0a..4585afedc617bfa7e4fbfa23b8307c338e6f085f 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <fcntl.h>
-#include <pwd.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <linux/vt.h>
index 6b3f2a731bf83e45b8d63a994f17f02b9dc0f9df..69b59948786f62a18a8facecea37bc722f3769f3 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <pwd.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
index 67fe9921d4019385f844d9a4da092f53b3388511..1d335f914c6fe84b02bcaf44ffcda27360c499d7 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
index 99584908757170958725dcaf16fb4f68507d7449..34ac0350f2dd93b69d455b5740ae71396e82dc9d 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "bus-common-errors.h"
index 094fcd668dcb1a178dc055586e1d1a400d082828..026bcf4d8eb9a065909f525d329954f51cc10547 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
index 872b9a86d98074e655bb160e4a3e295e512c3570..8f13edafb00fd991ba447b208fa4c412a17b698a 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "bus-common-errors.h"
index 0fea372155e6f9e28016ded1f3d093c615c7643e..23df756ae2f712bc4b1357ab7baf9cebab6266e5 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <fcntl.h>
-#include <linux/input.h>
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
index 68468464cd2d1533726769f19d384959b36e0704..9e8f04d3eaa431114929e8cdc284e3535cac1aaf 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/kd.h>
 #include <linux/vt.h>
 #include <signal.h>
-#include <string.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <unistd.h>
index a6e2d4950df2a5b0f350cde760c099a76a8adca1..1dc222f90ef51c344ac31ab232e663a5c134902c 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "bus-util.h"
index b17fb2e3225e6372244acade33b5ce86328fa7aa..c3c8b1a2a57cf2fe009f576ff74b2e8607d859bf 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index 3a5a33349662656de054afd04eea65e7a8a57232..d2a5890277dff631e5357d3232456eec835df38d 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <pwd.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "sd-messages.h"
index d889d7b9bec953851354a57a7f89810868261843..d8c1bbe15b95eec66d3ed11776a7821b1d405d2b 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "sd-daemon.h"
index 9104e023e8e58239a58ec4a5a732784d28916313..a66be28ad96fb46d72c2b19aab45e0ca05b46045 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 
 #include "sd-device.h"
 
index dbb5254f3d0f642a66625038efbc52405b35260d..3b2ac3829859618b633587d21864136cf82339ea 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <sys/mount.h>
 #include <sys/wait.h>
 
index c6475a5398b0ebd3e35c857e2fe598015454d1d8..acd57aedc4f333da2cf8af18d3e2cb9e2c69b90b 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <unistd.h>
 #include <sys/stat.h>
 
index 907f751ef2974b32d2168927ae76ac7ece373c3b..6dbdba12fd4d67f988a24d1bf607b6df31427983 100644 (file)
@@ -4,11 +4,9 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
-#include <locale.h>
 #include <math.h>
 #include <net/if.h>
 #include <netinet/in.h>
-#include <string.h>
 #include <sys/mount.h>
 #include <sys/socket.h>
 #include <unistd.h>
index 5276398ab542654d9c38d6b622846fc8fd410dd9..35e06f5d6a64452478afd4875e9aa24ad1bc557a 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "sd-id128.h"
index 7797f36d44916ddc44c71130f4204ba27eff370d..337a460318d0cb8a706d0e7bb6889e8d30f1634f 100644 (file)
@@ -2,9 +2,7 @@
 
 #include <errno.h>
 #include <getopt.h>
-#include <libkmod.h>
 #include <limits.h>
-#include <string.h>
 #include <sys/stat.h>
 
 #include "conf-files.h"
index 5a8740883b428be6bb10eef482ca852e57a837c5..a43a179cbf3a89673e55cddb4f1090acf9779ae6 100644 (file)
@@ -1812,7 +1812,6 @@ static int link_renew(int argc, char *argv[], void *userdata) {
         return k;
 }
 
-
 static int verb_reload(int argc, char *argv[], void *userdata) {
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
         _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
index 0b6232602425df5bbe4e5d4f4cf7abc1b318a13a..c8b8241ff192862908efb78486fca7ac5a59f803 100644 (file)
@@ -145,7 +145,6 @@ typedef struct Link {
         struct rtnl_link_stats64 stats_old, stats_new;
         bool stats_updated;
 
-
         /* All kinds of DNS configuration */
         struct in_addr_data *dns;
         unsigned n_dns;
index 6a9e459494af315e2af655ff49ce2a7426c5442d..51db60e1f2e816a987801c3510187a66bebf827a 100644 (file)
@@ -4,7 +4,6 @@
 #include <inttypes.h>
 #include <net/if.h>
 #include <net/if_arp.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "env-file.h"
index 90d86f35a9542c6b9d49ff5f831251ab6c640276..8727fd329fabc71717b712801b46f3510262d118 100644 (file)
@@ -145,6 +145,7 @@ static int network_resolve_stacked_netdevs(Network *network) {
 }
 
 int network_verify(Network *network) {
+        RoutePrefix *route_prefix, *route_prefix_next;
         RoutingPolicyRule *rule, *rule_next;
         Neighbor *neighbor, *neighbor_next;
         AddressLabel *label, *label_next;
@@ -304,9 +305,9 @@ int network_verify(Network *network) {
                 if (section_is_invalid(prefix->section))
                         prefix_free(prefix);
 
-        LIST_FOREACH_SAFE(prefixes, prefix, prefix_next, network->static_route_prefixes)
-                if (section_is_invalid(prefix->section))
-                        prefix_free(prefix);
+        LIST_FOREACH_SAFE(route_prefixes, route_prefix, route_prefix_next, network->static_route_prefixes)
+                if (section_is_invalid(route_prefix->section))
+                        route_prefix_free(route_prefix);
 
         LIST_FOREACH_SAFE(rules, rule, rule_next, network->rules)
                 if (routing_policy_rule_section_verify(rule) < 0)
@@ -577,10 +578,11 @@ failure:
 
 static Network *network_free(Network *network) {
         IPv6ProxyNDPAddress *ipv6_proxy_ndp_address;
+        RoutePrefix *route_prefix;
         RoutingPolicyRule *rule;
+        AddressLabel *label;
         FdbEntry *fdb_entry;
         Neighbor *neighbor;
-        AddressLabel *label;
         Address *address;
         NextHop *nexthop;
         Prefix *prefix;
@@ -654,6 +656,9 @@ static Network *network_free(Network *network) {
         while ((prefix = network->static_prefixes))
                 prefix_free(prefix);
 
+        while ((route_prefix = network->static_route_prefixes))
+                route_prefix_free(route_prefix);
+
         while ((rule = network->rules))
                 routing_policy_rule_free(rule);
 
@@ -664,6 +669,7 @@ static Network *network_free(Network *network) {
         hashmap_free(network->neighbors_by_section);
         hashmap_free(network->address_labels_by_section);
         hashmap_free(network->prefixes_by_section);
+        hashmap_free(network->route_prefixes_by_section);
         hashmap_free(network->rules_by_section);
         ordered_hashmap_free_with_destructor(network->qdiscs_by_section, qdisc_free);
 
index 9258bf55f74826baa5c5251fa4b8582878c16ed2..9c4dcf0532eb42de3d63f7e9376faaa73edff8ca 100644 (file)
@@ -245,7 +245,7 @@ struct Network {
         LIST_HEAD(Neighbor, neighbors);
         LIST_HEAD(AddressLabel, address_labels);
         LIST_HEAD(Prefix, static_prefixes);
-        LIST_HEAD(Prefix, static_route_prefixes);
+        LIST_HEAD(RoutePrefix, static_route_prefixes);
         LIST_HEAD(RoutingPolicyRule, rules);
 
         unsigned n_static_addresses;
index 8972c661ae4c53ef104d8cbbf038362d73908593..d48609f985ad7a9b1498440ab02b1d0e14744e79 100644 (file)
@@ -31,12 +31,12 @@ void prefix_free(Prefix *prefix) {
         }
 
         network_config_section_free(prefix->section);
-        prefix->radv_prefix = sd_radv_prefix_unref(prefix->radv_prefix);
+        sd_radv_prefix_unref(prefix->radv_prefix);
 
         free(prefix);
 }
 
-int prefix_new(Prefix **ret) {
+static int prefix_new(Prefix **ret) {
         _cleanup_(prefix_freep) Prefix *prefix = NULL;
 
         prefix = new0(Prefix, 1);
@@ -101,10 +101,10 @@ static int prefix_new_static(Network *network, const char *filename,
         return 0;
 }
 
-int route_prefix_new(Prefix **ret) {
-        _cleanup_(prefix_freep) Prefix *prefix = NULL;
+static int route_prefix_new(RoutePrefix **ret) {
+        _cleanup_(route_prefix_freep) RoutePrefix *prefix = NULL;
 
-        prefix = new0(Prefix, 1);
+        prefix = new0(RoutePrefix, 1);
         if (!prefix)
                 return -ENOMEM;
 
@@ -116,12 +116,12 @@ int route_prefix_new(Prefix **ret) {
         return 0;
 }
 
-void route_prefix_free(Prefix *prefix) {
+void route_prefix_free(RoutePrefix *prefix) {
         if (!prefix)
                 return;
 
         if (prefix->network) {
-                LIST_REMOVE(prefixes, prefix->network->static_route_prefixes, prefix);
+                LIST_REMOVE(route_prefixes, prefix->network->static_route_prefixes, prefix);
                 assert(prefix->network->n_static_route_prefixes > 0);
                 prefix->network->n_static_route_prefixes--;
 
@@ -131,14 +131,15 @@ void route_prefix_free(Prefix *prefix) {
         }
 
         network_config_section_free(prefix->section);
+        sd_radv_route_prefix_unref(prefix->radv_route_prefix);
 
         free(prefix);
 }
 
 static int route_prefix_new_static(Network *network, const char *filename,
-                                   unsigned section_line, Prefix **ret) {
+                                   unsigned section_line, RoutePrefix **ret) {
         _cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL;
-        _cleanup_(prefix_freep) Prefix *prefix = NULL;
+        _cleanup_(route_prefix_freep) RoutePrefix *prefix = NULL;
         int r;
 
         assert(network);
@@ -165,7 +166,7 @@ static int route_prefix_new_static(Network *network, const char *filename,
                 return r;
 
         prefix->network = network;
-        LIST_APPEND(prefixes, network->static_route_prefixes, prefix);
+        LIST_APPEND(route_prefixes, network->static_route_prefixes, prefix);
         network->n_static_route_prefixes++;
 
         if (filename) {
@@ -330,7 +331,7 @@ int config_parse_route_prefix(const char *unit,
                               void *userdata) {
 
         Network *network = userdata;
-        _cleanup_(prefix_free_or_set_invalidp) Prefix *p = NULL;
+        _cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
         uint8_t prefixlen = 64;
         union in_addr_union in6addr;
         int r;
@@ -372,7 +373,7 @@ int config_parse_route_prefix_lifetime(const char *unit,
                                        void *data,
                                        void *userdata) {
         Network *network = userdata;
-        _cleanup_(prefix_free_or_set_invalidp) Prefix *p = NULL;
+        _cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
         usec_t usec;
         int r;
 
@@ -388,7 +389,8 @@ int config_parse_route_prefix_lifetime(const char *unit,
 
         r = parse_sec(rvalue, &usec);
         if (r < 0) {
-                log_syntax(unit, LOG_ERR, filename, line, r, "Roure lifetime is invalid, ignoring assignment: %s", rvalue);
+                log_syntax(unit, LOG_ERR, filename, line, r,
+                           "Route lifetime is invalid, ignoring assignment: %s", rvalue);
                 return 0;
         }
 
@@ -547,8 +549,9 @@ int radv_emit_dns(Link *link) {
 }
 
 int radv_configure(Link *link) {
-        int r;
+        RoutePrefix *q;
         Prefix *p;
+        int r;
 
         assert(link);
         assert(link->network);
@@ -607,8 +610,8 @@ int radv_configure(Link *link) {
                                 return r;
                 }
 
-                LIST_FOREACH(prefixes, p, link->network->static_route_prefixes) {
-                        r = sd_radv_add_route_prefix(link->radv, p->radv_route_prefix, false);
+                LIST_FOREACH(route_prefixes, q, link->network->static_route_prefixes) {
+                        r = sd_radv_add_route_prefix(link->radv, q->radv_route_prefix, false);
                         if (r == -EEXIST)
                                 continue;
                         if (r < 0)
index 2f60b285ae3f468815f83dac7cb19607df9e03e7..21b323e83e2b3574963c3f148bffec0a67ee22c2 100644 (file)
@@ -11,6 +11,7 @@
 #include "networkd-util.h"
 
 typedef struct Prefix Prefix;
+typedef struct RoutePrefix RoutePrefix;
 
 typedef enum RADVPrefixDelegation {
         RADV_PREFIX_DELEGATION_NONE,
@@ -26,21 +27,26 @@ struct Prefix {
         NetworkConfigSection *section;
 
         sd_radv_prefix *radv_prefix;
-        sd_radv_route_prefix *radv_route_prefix;
 
         LIST_FIELDS(Prefix, prefixes);
-        LIST_FIELDS(Prefix, route_prefixes);
 };
 
-int prefix_new(Prefix **ret);
+struct RoutePrefix {
+        Network *network;
+        NetworkConfigSection *section;
+
+        sd_radv_route_prefix *radv_route_prefix;
+
+        LIST_FIELDS(RoutePrefix, route_prefixes);
+};
+
 void prefix_free(Prefix *prefix);
 
 DEFINE_NETWORK_SECTION_FUNCTIONS(Prefix, prefix_free);
 
-int route_prefix_new(Prefix **ret);
-void route_prefix_free(Prefix *prefix);
+void route_prefix_free(RoutePrefix *prefix);
 
-DEFINE_NETWORK_SECTION_FUNCTIONS(Prefix, route_prefix_free);
+DEFINE_NETWORK_SECTION_FUNCTIONS(RoutePrefix, route_prefix_free);
 
 int radv_emit_dns(Link *link);
 int radv_configure(Link *link);
index 199e5804dd9387575df68bb4e90a38d2d07b6a16..fc591e2725387b8f5c3b9866328d043a07c0cf5b 100644 (file)
@@ -1,11 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <fcntl.h>
-#include <linux/magic.h>
-#if HAVE_ACL
-#include <sys/acl.h>
-#endif
-#include <sys/stat.h>
 #include <sys/statvfs.h>
 #include <sys/vfs.h>
 #include <unistd.h>
index 3c302d6487dad06410221f299146c8b2f2d64029..cb2b2272b6bbeb177d2889b0d7aa553274c3d331 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <fcntl.h>
-#include <grp.h>
 #include <sys/types.h>
 #include <unistd.h>
 
index c9ff00544cf763fc78ea900c3af37fd8a2199b6e..c87e8591949facd285c9bb4a06124c2d2c0dcad6 100644 (file)
@@ -1,22 +1,15 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #if HAVE_BLKID
-#include <blkid.h>
 #endif
 #include <errno.h>
 #include <getopt.h>
-#include <grp.h>
 #include <linux/fs.h>
 #include <linux/loop.h>
-#include <pwd.h>
-#include <sched.h>
 #if HAVE_SELINUX
 #include <selinux/selinux.h>
 #endif
-#include <signal.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/file.h>
 #include <sys/personality.h>
 #include <sys/prctl.h>
 #include "terminal-util.h"
 #include "tmpfile-util.h"
 #include "umask-util.h"
+#include "unit-name.h"
 #include "user-util.h"
 #include "util.h"
 
@@ -891,13 +885,17 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_settings_mask |= SETTING_MACHINE_ID;
                         break;
 
-                case 'S':
-                        r = free_and_strdup(&arg_slice, optarg);
+                case 'S': {
+                        _cleanup_free_ char *mangled = NULL;
+
+                        r = unit_name_mangle_with_suffix(optarg, NULL, UNIT_NAME_MANGLE_WARN, ".slice", &mangled);
                         if (r < 0)
                                 return log_oom();
 
+                        free_and_replace(arg_slice, mangled);
                         arg_settings_mask |= SETTING_SLICE;
                         break;
+                }
 
                 case 'M':
                         if (isempty(optarg))
@@ -2385,7 +2383,8 @@ static int drop_capabilities(uid_t uid) {
                 /* If we're not using OCI, proceed with mangled capabilities (so we don't error out)
                  * in order to maintain the same behavior as systemd < 242. */
                 if (capability_quintet_mangle(&q))
-                        log_warning("Some capabilities will not be set because they are not in the current bounding set.");
+                        log_full(arg_quiet ? LOG_DEBUG : LOG_WARNING,
+                                 "Some capabilities will not be set because they are not in the current bounding set.");
 
         }
 
index 90de140a9d6267519623aa212d35c99f2e959574..8c16b7f360c294704a802224b8b3c9a063bae6cd 100644 (file)
@@ -5,7 +5,6 @@
 #include <netdb.h>
 #include <nss.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "errno-util.h"
index 95f80572bdb7ddce7fd561c55456d96a9a230259..de46a8d4697c2d6bfc08ff63d37549620fa94585 100644 (file)
@@ -4,7 +4,6 @@
 #include <netdb.h>
 #include <nss.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
 
index 5f55d3fc959b1a271fbb4f0ccf2791a2d31cabff..1dbc9a46d617f147e3dfd240cb3bcb211568fed1 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/magic.h>
 #include <sys/ioctl.h>
 #include <sys/mount.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/vfs.h>
 
index 0b9bae55e7b3435d3416a35b9b764b8908b0ac2d..ee4907f73f6249a5621baf613254cc820893a299 100644 (file)
@@ -3,7 +3,6 @@
 ***/
 
 #include <fcntl.h>
-#include <signal.h>
 #include <sys/prctl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
index e8a4b5e88ce55781014139efcd408afbca951510..2fcbcb281ab7255aa000796319d875a27e6a56bb 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <linux/random.h>
-#include <string.h>
 #include <sys/ioctl.h>
 #if USE_SYS_RANDOM_H
 #  include <sys/random.h>
index 0df29aa69ff0cb26f45b8fdbf9ebb6b55a8bedd4..589101342703bd203ff42e1852530d2b4ea61dd0 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <mntent.h>
-#include <string.h>
 #include <sys/prctl.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
index 1a8a9a6d623911f3ff6d354552aad214bc9f15b3..3a0eb5c4b805f35a268a131693dff9a08fd882f7 100644 (file)
@@ -2,8 +2,6 @@
 
 #include <errno.h>
 #include <stddef.h>
-#include <string.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 
 #include "alloc-util.h"
index fc375a88215037759b33b3dc9114a1f4bd62804a..ec9bfd7ad3b265f4cae399d6d71cf675a4a1d056 100644 (file)
@@ -1,9 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#if HAVE_GCRYPT
-#  include <gcrypt.h>
-#endif
-
 #include "alloc-util.h"
 #include "dns-domain.h"
 #include "fd-util.h"
index f6df9135ee936410bf82c0cd139fce5c802b2053..7c6346cb66a5066ee776f4aa221942504601b8b8 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <net/if.h>
-#include <glob.h>
 
 #include "sd-id128.h"
 
index 9b5b8f8f13828941a281c1e72292d2eb7caa316c..5488d8a74b70ea2350fa1447b0e232088f76025a 100644 (file)
@@ -5,16 +5,13 @@
 #include <inttypes.h>
 #include <limits.h>
 #include <poll.h>
-#include <signal.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/inotify.h>
 #include <sys/signalfd.h>
-#include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/uio.h>
index 7a4da519115e7018f49ddb9d523df90bce9f6c24..5fbc55770e1d0192280859949e9afc113730b727 100644 (file)
@@ -3,9 +3,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <inttypes.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/ioctl.h>
 #include <sys/resource.h>
 #include <sys/socket.h>
index 9b1582da9975ed0e499b93d4d9ec76bf9a7d7900..aa0d6a8224f8c9b5b21d67b4f91e27201ed1e0bb 100644 (file)
@@ -1,15 +1,12 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <alloca.h>
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/mman.h>
-#include <time.h>
 
 #include "alloc-util.h"
 #include "calendarspec.h"
index ddcd156801ced342633de8538978d41a5856119e..e8398cbde5ba7fdba370453b4cdfc9a5b8d9da11 100644 (file)
@@ -149,7 +149,6 @@ int cg_blkio_weight_parse(const char *s, uint64_t *ret) {
         return 0;
 }
 
-
 static int trim_cb(const char *path, const struct stat *sb, int typeflag, struct FTW *ftwbuf) {
         assert(path);
         assert(sb);
index 732bc752afdad22fcab6d68742bbf6aea10e71b8..4657e820d9641968175da62309ec053772e5021c 100644 (file)
@@ -5,7 +5,6 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "bus-error.h"
index 46fa68027ed9477e6abdad61fcf89a4f07360f76..e4cd2d30d0a34748e5075989072deae94c36cc8a 100644 (file)
@@ -1,13 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
 #include <mqueue.h>
 #include <stdbool.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/ipc.h>
 #include <sys/msg.h>
 #include <sys/sem.h>
index 5a5d35bcc383b1c27bcb5580886142f44d75fddf..9f4c7fe3380f7639644dfc541d7c61840cd99505 100644 (file)
@@ -5,8 +5,6 @@
 #include <fnmatch.h>
 #include <limits.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/utsname.h>
 #include <time.h>
index ce714bcc8bb9054650079c7a1a4dbb6fc3ec7b98..3269d8303117c35de933e374c0f0fac8e2b9b27d 100644 (file)
@@ -5,7 +5,6 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/types.h>
 
 #include "alloc-util.h"
index f73bf93520a3001d78b1370fcd59ccbb721920b5..d817e5b0e5e2a14207cf54d15da907fd655f4881 100644 (file)
@@ -1,6 +1,5 @@
 #include <fcntl.h>
 #include <linux/dm-ioctl.h>
-#include <string.h>
 #include <sys/ioctl.h>
 
 #include "dm-util.h"
index f62ad0a0f58aa7307df55d7e7208aeaac0dc68f9..b812665315f63dc0dc872dc03660a1508c969743 100644 (file)
@@ -10,7 +10,6 @@
 #include <endian.h>
 #include <netinet/in.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/socket.h>
 
 #include "alloc-util.h"
index 46e187000f56ca079a8110fd130e84432e735f1c..3d1df09907f6c01d56b57ff649b3db8364d33b2f 100644 (file)
@@ -181,7 +181,6 @@ int efi_set_reboot_to_firmware(bool value) {
         return 0;
 }
 
-
 static ssize_t utf16_size(const uint16_t *s, size_t buf_len_bytes) {
         size_t l = 0;
 
index e29b81f1329f1f76e6af540656430d9f95e8585d..8fec1a83f072a376e9e586b9a1e0b0a1e50a599a 100644 (file)
@@ -411,7 +411,6 @@ int ethtool_set_nic_buffer_size(int *fd, const char *ifname, netdev_ring_param *
         return 0;
 }
 
-
 static int get_stringset(int fd, struct ifreq *ifr, int stringset_id, struct ethtool_gstrings **gstrings) {
         _cleanup_free_ struct ethtool_gstrings *strings = NULL;
         struct {
index 5dd78008529e5d42608a6fa37ff1e11741db8160..d408bcd90a0b514deed5be6d3d3046a4abe22fc5 100644 (file)
@@ -87,7 +87,6 @@ typedef struct netdev_ring_param {
         bool tx_pending_set;
 } netdev_ring_param;
 
-
 int ethtool_get_driver(int *fd, const char *ifname, char **ret);
 int ethtool_get_link_info(int *fd, const char *ifname,
                           int *ret_autonegotiation, size_t *ret_speed,
index ae65286c783ef27f41917b1095b1cea2e9fa2d9a..89d118a3aa9c4532550407a6f7e1a9a214dbc6b5 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <alloca.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stddef.h>
index 93bdd8c7f1241ebba44a4052fd45c47f3b98d6a2..4d4d615bb7890303b9579c96e19d65e041bc1810 100644 (file)
@@ -5,13 +5,11 @@
  */
 #define _NET_IF_H 1
 
-#include <alloca.h>
 #include <arpa/inet.h>
 #include <endian.h>
 #include <errno.h>
 #include <stddef.h>
 #include <string.h>
-#include <sys/socket.h>
 #include <net/if.h>
 #ifndef IFNAMSIZ
 #define IFNAMSIZ 16
index 135b01f28207589bd77b8ca299918f1fc40e3faf..75e4784c3879a38f7c569b470e7b9791b8fa94c4 100644 (file)
@@ -1,10 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <mntent.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "device-nodes.h"
index dad6c1c2fe733804c0acdc191def9a034ba6c165..f7770e7df50aea23fc799a426304295fea624106 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "btrfs-util.h"
index d2143beda3a05a5364b7f25389791910d5956000..2061384afe30d0e589d9121c3ba4de7a9f55dc5f 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <stdio.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "format-util.h"
index 0724dd96ee72eb43f4bd225abe874c71887db405..14dfd331d584a0f5ded6c70ed4a8f50640124053 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <fnmatch.h>
@@ -8,8 +7,6 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
@@ -1191,6 +1188,11 @@ static int config_parse_default_instance(
         if (r < 0)
                 return r;
 
+        if (isempty(printed)) {
+                i->default_instance = mfree(i->default_instance);
+                return 0;
+        }
+
         if (!unit_instance_is_valid(printed))
                 return -EINVAL;
 
index f1bb50cfa2c8ce84df08ac44799b77a9fabe2596..7393c100cd7f3fa756ea1a2e654002513c9e4d38 100644 (file)
@@ -5,7 +5,6 @@
 #include <math.h>
 #include <stdarg.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/types.h>
 
 #include "sd-messages.h"
index b615c70dff14400df2680af1a05ddfbdddb031b1..95b2e3376e9a5e903d3f57541f492bc6d2c66a70 100644 (file)
@@ -5,10 +5,8 @@
 #include <signal.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/socket.h>
 #include <syslog.h>
-#include <time.h>
 #include <unistd.h>
 
 #include "sd-id128.h"
index 22525d5c63303b0111f229bd18a902b2c156230a..559d7f8174eff6813b6594e1da87ea0ecdf8b691 100644 (file)
@@ -4,7 +4,6 @@
 #include <fcntl.h>
 #include <linux/loop.h>
 #include <sys/ioctl.h>
-#include <sys/stat.h>
 
 #include "alloc-util.h"
 #include "fd-util.h"
index cceed58f74489b9f8d055f4693b566f9aaa80e13..a11803e731adfa5424f87666c900fca83b2ecf21 100644 (file)
@@ -1,11 +1,9 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
index 98f54131337c96bd099ed4efc381b43b615be680..7e3312835d71961fbce73b1a5a587371641df6aa 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <sys/statfs.h>
 
 #include "btrfs-util.h"
 #include "label.h"
index e55d3c231568261131814d9572a432092ec35530..d316e81aa243586edb4cc689c198de793d3409cb 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
 #include <sys/statvfs.h>
index 7c20b100b46d677281c72d33082702e410941f9d..1fe9db17917680f3745cbe61bd3b2102492d6b49 100644 (file)
@@ -1,12 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <signal.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/prctl.h>
 #include <unistd.h>
 
index 6bf0ff0316a98d4f7b92c4418ecdd195b263b8c0..5b162097453659ea35af3c117b82d92661420dd2 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "fs-util.h"
index 5b5e4947ef0cc374acb4fb02bea73a90731d7562..00b70a777ee3a10aca42a701081758a99d32e434 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <fcntl.h>
-#include <sys/mman.h>
 
 #include "alloc-util.h"
 #include "env-util.h"
index e8f61b36e9c8c378a9180d0ab01812e2e68876b3..03108b92cbe83ae6cb3629d5f2fdc9f195e52ce1 100644 (file)
@@ -8,8 +8,6 @@
 #include <linux/fs.h>
 #include <stdbool.h>
 #include <stddef.h>
-#include <stdio.h>
-#include <string.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
index c8e789680d3455341c78df14513acefbd563aed0..b036ff67ddbdf3690a2f4a8961416fba8b84c49e 100644 (file)
@@ -4,7 +4,6 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/utsname.h>
 
 #include "sd-id128.h"
index ebe9041482bd162fe45349d448fee8872ae268f5..bd89cb4ef11f4877b82681ba74bc05e1051a4f4b 100644 (file)
@@ -4,7 +4,6 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <stdbool.h>
-#include <stdio.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
 #include <unistd.h>
index 93bdcf11bf4effa16e7e5effc28f99d27a8c7675..12fb3ef7ea0e2d58f7f548d65a962163cd1bbc88 100644 (file)
@@ -3,7 +3,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "fd-util.h"
index 646f449821818efe3292b67cddf44a0d8d9c2876..fa4f32f3538b29c40a16254fbf6310519fb2e7ae 100644 (file)
@@ -6,7 +6,6 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/time.h>
 #include <sys/utsname.h>
 #include <unistd.h>
index c87b496736e6caf88ca9c5e0d54da612e27fde9b..1d23ed48a2b87635b232dca04ed86264ee740a59 100644 (file)
@@ -4,7 +4,6 @@
 #include <getopt.h>
 #include <stdbool.h>
 #include <stddef.h>
-#include <string.h>
 
 #include "env-util.h"
 #include "log.h"
index 27090762642d6e962bf4f470ff672b2a83b60f38..78ac42f08025fa642c424ca012f163d827a17bfe 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <stddef.h>
-#include <string.h>
 
 #include "macro.h"
 #include "string-util.h"
index 1be26bf56ff87802e84e1947a856d5c8f9056c88..15e6c1799e71451ad846ed16f0af7e79c464257b 100644 (file)
@@ -6,7 +6,6 @@
 #include <errno.h>
 #include <getopt.h>
 #include <linux/reboot.h>
-#include <signal.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <sys/mman.h>
index c75be39fefc88c9a0fcf61452107e179b12630e2..4563a9d720453c32987bd34edea60b18a5cecec1 100644 (file)
@@ -7,7 +7,6 @@
 #include <fcntl.h>
 #include <linux/dm-ioctl.h>
 #include <linux/loop.h>
-#include <string.h>
 #include <sys/mount.h>
 #include <sys/swap.h>
 #include <sys/stat.h>
index f6a94f128a1119a7b03ff7e2151940571b21c7e5..89b80367f8f4f1f4b9abe3813d51e8d20e238c8d 100644 (file)
@@ -9,7 +9,6 @@
 #include <getopt.h>
 #include <linux/fiemap.h>
 #include <poll.h>
-#include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/timerfd.h>
index abbbc9f2d61852b75708b32c679a4297da5398b0..2fb9c854fa504ba000b3b4073efeba5703243207 100644 (file)
@@ -6,8 +6,6 @@
 #include <netdb.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
 
index c67782ea8fb807a5f47f0a4a1470c9bab23a4356..56d86d8eba31e7d382f21614db4724206c14743b 100644 (file)
@@ -6,7 +6,6 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
index 3fabbb665cc4396f8d17e6d529313fffc5d86299..b2dafd731b4e827ceb8bcc4332c2be1e33ffc80b 100644 (file)
@@ -3,15 +3,12 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
-#include <locale.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/mount.h>
 #include <sys/prctl.h>
 #include <sys/reboot.h>
-#include <sys/socket.h>
 #include <unistd.h>
 
 #include "sd-bus.h"
@@ -807,7 +804,6 @@ static int expand_names(sd_bus *bus, char **names, const char* suffix, char ***r
         return 0;
 }
 
-
 static int list_units(int argc, char *argv[], void *userdata) {
         _cleanup_free_ UnitInfo *unit_infos = NULL;
         _cleanup_(message_set_freep) Set *replies = NULL;
index c8ef3295b568556e7869f6bfebffbce318317ac8..884372e60e228f5f0d28c06293e18323b17b450e 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <string.h>
 #include <sys/socket.h>
 
 #include "macro.h"
index 46358ef9527824867183203f0b275626e8b3f617..899e4b5d27775767ad10b5be9c526fb263aad42a 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <string.h>
-
 #include "alloc-util.h"
 #include "calendarspec.h"
 #include "errno-util.h"
index 84a6e92df1ddc457ed62e24cfead11137e1543b2..295136e1ef78407293394c82c4f4eacc17c4dec1 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <netinet/in.h>
 #include <pwd.h>
-#include <sys/capability.h>
 #include <sys/prctl.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
index 1891df0eb9e53e28b8738a70a06027d911571f9b..f16cb291f222f8527d10c0515b2233db5641c2a7 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <string.h>
 #include <unistd.h>
 
 #include "cgroup-setup.h"
index 9888b65998fa0a60e426e39dfe3f4d8b788c8578..7d27cfa703d4311653327d383750fb2e50cc2fed 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <string.h>
-
 #include "alloc-util.h"
 #include "string-util.h"
 #include "tests.h"
index 10648114971c0bd42b5de145b10fe6739ce40083..265152fb76e83d9301de74798fd9c75d3da94a2d 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <stdio.h>
-#include <string.h>
 
 #include "bus-util.h"
 #include "manager.h"
index 17dacda70f1f22d4efdf268ffa3d601c409d0f0b..f0ffe89729b069617b6d85b611c1ef81a12151d3 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <string.h>
-
 #include "env-util.h"
 #include "fd-util.h"
 #include "fileio.h"
index ec5189163473f0a46d9b04f0ccfed6b409f5c470..3168411d8bf1cf8abc498a2d9ec0152f65c90620 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <unistd.h>
index 435ab39cd250bcd264a22fadf03259b50b19abd6..92fb35fd8772018c9841fe8fe1e8c9d17d3e56eb 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <grp.h>
-#include <pwd.h>
 #include <stdio.h>
 #include <sys/prctl.h>
 #include <sys/types.h>
index bf47a598a94628a407bd18b1484715fb5ab9ea3c..4ca57555f1da419b710294f0ffa082a643502584 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "extract-word.h"
 #include "log.h"
index b4f41445fe22d65446e6be3e043f5f00607829d2..667d15335fbf19c31df1d66e4b6756e82c6256e0 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <fcntl.h>
-#include <glob.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
index eea0765b7a3dedf439b01ef159ab760ad6119be6..4d7513f6d5f73a5e0fe507ac6c32378f3667b241 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <fcntl.h>
-#include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
 
index dcb5bcc254481b3da1d99805133903e5a475427d..3ca8e1b10832f68d7d60c8b3430c15a6193d0331 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <getopt.h>
-#include <stdio.h>
 #include <sys/epoll.h>
 #include <unistd.h>
 
index 8deaf4eb0f66decb822e474e8dff71964d03dcb8..216f0e4d944de5987bf524faafc8e5a596e26648 100644 (file)
@@ -3,8 +3,6 @@
 #include <fcntl.h>
 #include <stddef.h>
 #include <stdio.h>
-#include <string.h>
-#include <sys/capability.h>
 #include <unistd.h>
 
 #include "all-units.h"
index 031a47605e2558c17de8d2ea6589227cf6fb0d47..a734524eebd403ed3ddd7667b89f91f499545884 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <arpa/inet.h>
-#include <libkmod.h>
 #include <linux/if_tunnel.h>
 #include <linux/ip.h>
 #include <sys/types.h>
index ad441ae731a83a00ba18153fe91416a5492d04d8..762a203577155089bfd5e6f6009b021e948256b8 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <fcntl.h>
-#include <sched.h>
 #include <sys/mount.h>
 #include <sys/personality.h>
 #include <sys/prctl.h>
index af17a5651616c5ca75e87faa50d024ab4c248968..018c20f8be26f75928bb43d7df45e7f9abafef91 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <fcntl.h>
 #include <poll.h>
-#include <sched.h>
 #include <stdlib.h>
 #include <sys/eventfd.h>
 #include <sys/mman.h>
index 8ea4163790a30ddb9609e90c20273d75c1dac457..1a8c60ad4204fdec4dfa3102393e55c75d1edb85 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <signal.h>
 #include <unistd.h>
 
 #include "log.h"
index 9e93bc175105330cf1f314396d5b1136528bf0e1..483ba44caa1394691d3ce7995f67e53b6bc5b405 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <stdlib.h>
-#include <string.h>
 
 #include "strbuf.h"
 #include "string-util.h"
index 5e96f3a8a7ed524b5d4db8cfd94e7acc8db7e05a..f31ea6f8c61cf6b86efc4c8757ac4509029cb538 100644 (file)
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <string.h>
-
 #include "alloc-util.h"
 #include "escape.h"
 #include "nulstr-util.h"
index d7199124a3d9ed246ce173a2d392fc2ea5edf4a7..749aa46d75f2debcee1c4e242e983c95567a921d 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <stdio.h>
-#include <string.h>
 
 #include "string-util.h"
 #include "strxcpyx.h"
index f0186b078f0cfac6af0a9123a93ca8cfefb74b15..6021164739d3709763ccf9063bae4d97d60ef3e4 100644 (file)
@@ -56,7 +56,6 @@ static void test_unit_file_build_name_map(char **ids) {
         if (r == 0)
                 log_debug("Cache rebuild skipped based on mtime.");
 
-
         char **id;
         STRV_FOREACH(id, ids) {
                  const char *fragment, *name;
index aa072c4ca8220d0b58fa4dc3e9e8fe415f27a622..c65f6ffe0839e14bddc3ce2c1d812f6a4fc59862 100644 (file)
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
-#include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "alloc-util.h"
 #include "all-units.h"
index 9475b99c2803e37fa0297b8e6d6b40b00c842f6f..47baacb518a19e94410123972ff17662eb355469 100644 (file)
@@ -286,6 +286,15 @@ static void test_make_salt(void) {
         assert(!streq(s, t));
 }
 
+static void test_in_gid(void) {
+
+        assert(in_gid(getgid()) >= 0);
+        assert(in_gid(getegid()) >= 0);
+
+        assert(in_gid(GID_INVALID) < 0);
+        assert(in_gid(TTY_GID) == 0); /* The TTY gid is for owning ttys, it would be really really weird if we were in it. */
+}
+
 int main(int argc, char *argv[]) {
         test_uid_to_name_one(0, "root");
         test_uid_to_name_one(UID_NOBODY, NOBODY_USER_NAME);
@@ -320,5 +329,7 @@ int main(int argc, char *argv[]) {
 
         test_make_salt();
 
+        test_in_gid();
+
         return 0;
 }
index 120baa35937d51691ae8a1d5265dc85856dc5a00..61725bdf087097ef741da8ef57dc3eb7a915474f 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <sys/wait.h>
 #include <unistd.h>
 
index 124c74076ba285bc0973f1c804d80254421af57a..e880f9e6b67d33bf50fa3d0fb34e9fd5defcdcfa 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 #include <errno.h>
-#include <signal.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
index 4f15a400ab07f1fbaa20a7c895ad1fe8b3a4e328..97a0868bc1b1e057414290719ac8ad565c100188 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
index 738178532c19a5ad1475ba5af30ae7541168b97b..da6b4104767eca24da1ce1dcb1eed37cca215138 100644 (file)
@@ -6,11 +6,9 @@
 #include <netinet/ip.h>
 #include <resolv.h>
 #include <stdlib.h>
-#include <sys/socket.h>
 #include <sys/timerfd.h>
 #include <sys/timex.h>
 #include <sys/types.h>
-#include <time.h>
 
 #include "sd-daemon.h"
 
index 808cc18892d5cede4263f29b3f38113c2df813c8..f4f7705a32ec189e90f5d1f12f2bf1f48e3738c1 100644 (file)
@@ -4,16 +4,12 @@
 #include <fcntl.h>
 #include <fnmatch.h>
 #include <getopt.h>
-#include <glob.h>
 #include <limits.h>
 #include <linux/fs.h>
 #include <stdbool.h>
 #include <stddef.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/file.h>
-#include <sys/stat.h>
 #include <sys/xattr.h>
 #include <sysexits.h>
 #include <time.h>
index 068988e2033de540812a9946af55cee935918197..784dd0df72da769834b5c8cc88aaaf3dfbfe2fc0 100644 (file)
@@ -7,13 +7,10 @@
 #include <fcntl.h>
 #include <getopt.h>
 #include <poll.h>
-#include <signal.h>
 #include <stdbool.h>
 #include <stddef.h>
-#include <string.h>
 #include <sys/prctl.h>
 #include <sys/signalfd.h>
-#include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/un.h>
index e1a8d7e3a9252819f3c8d28de8106549c738c4a9..94c3b232e5e408e3dae2eef76d16c370400dda35 100644 (file)
@@ -13,7 +13,6 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
index 8deb692f13c3f3f20a06e97d3aca988f60e2ce48..7f25824df3d646d85da205368382bfce9830a832 100644 (file)
@@ -14,7 +14,6 @@
 #include <scsi/sg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
index c6b0208b4b7528604b339521fc9d49b2203f5fae..8798a5a5e298af0e21af08d4e117fca24130b4c3 100644 (file)
@@ -5,13 +5,11 @@
  * Copyright Â© 2011 Karel Zak <kzak@redhat.com>
  */
 
-#include <blkid.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/stat.h>
 
 #include "sd-id128.h"
index 7a8e1f75dd86ced2b50c0fd078cb3cdabd448dc1..840bd01e1b2dbbc344a7e57fb183de9cf0c380d0 100644 (file)
@@ -9,12 +9,9 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdarg.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
 #include <linux/limits.h>
-#include <linux/input.h>
 
 #include "device-util.h"
 #include "fd-util.h"
index 800eeb21801cc83a32d157dfef547f8519980e11..bb82e8ae9798f620b21117117b341b420fd7a09c 100644 (file)
@@ -2,9 +2,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/ioctl.h>
 #include <linux/input.h>
 
index 86612fc975c91d73f41882cbc69074d08c862a37..b3daddcdd5465c29ba2f04c2520b4b456c93f33e 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include <errno.h>
-#include <libkmod.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
index e6d4659d9f7cab1687a0061e3b27af8ecfe0259d..65f668d2a7ebb500e42ed96b45ad284ef295cf68 100644 (file)
@@ -17,9 +17,7 @@
 #include <net/if.h>
 #include <net/if_arp.h>
 #include <stdarg.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
 #include <linux/pci_regs.h>
 
index e8f1ce135460f5f92420733efbe5dfd04a5a0f39..ca38f56087911f283165d6207ca69e67ec616c1c 100644 (file)
@@ -12,7 +12,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index 58d665998a636105341fd502e8fdba8679b4946c..c12af28d10c522b09310f89a99fd22ea5b046f63 100644 (file)
@@ -12,7 +12,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
index 9bbed82209ff69320031c64d02faa2f50b593bb0..b41fbfc39a9436de1d89ed387e30b6889eef16d5 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <getopt.h>
 #include <stdio.h>
-#include <string.h>
 
 #include "device-private.h"
 #include "device-util.h"
index f1befc73043d5d97b5bdaba9fa97a5bf1a1a09a8..b8c0d83a022c1729211d0c96fe5231d08502d746 100644 (file)
@@ -13,7 +13,6 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
 
index 8cfa2cdf233c77ed80fdff274ca9db4707d39edb..bff75ed5219e6010e99355a2f27d10f57a3baa9f 100644 (file)
@@ -5,7 +5,6 @@
 #include <fcntl.h>
 #include <net/if.h>
 #include <stddef.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <sys/wait.h>
 #include <unistd.h>
index f161402f3aecdb440bf939ad9c94153e5cfaa22d..2d725707d0dff9df4c8764624214b922c7103499 100644 (file)
@@ -4,8 +4,6 @@
 #include <fcntl.h>
 #include <stdbool.h>
 #include <stddef.h>
-#include <stdio.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
index 2c8626ffad2f06d5dd1097f5dcce43a739bb164c..2d2bc0026e8dfbe4f34f5974290bae1b857a8e7b 100644 (file)
@@ -6,7 +6,6 @@
 #include <getopt.h>
 #include <stddef.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
index ca7ca3c37f51cfc4db206ea77a713ded321bf95b..2ca98a729f01541486e43cc3304cce3e897734d4 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <getopt.h>
-#include <signal.h>
 
 #include "sd-device.h"
 #include "sd-event.h"
index 1524808ffe27a142bd6cef539d0e72051bf9ebc0..7d7044eac3c019dc5cb58394782321d560ab3d79 100644 (file)
@@ -10,7 +10,6 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
 
 #include "sd-bus.h"
index cb5123042a2a5195f08c39b5a23f4b429230967c..0ae61c1e8b396775b300184ced0151e611756d4c 100644 (file)
@@ -8,12 +8,10 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
-#include <signal.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/epoll.h>
 #include <sys/file.h>
 #include <sys/inotify.h>
@@ -21,7 +19,6 @@
 #include <sys/mount.h>
 #include <sys/prctl.h>
 #include <sys/signalfd.h>
-#include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/wait.h>
index 9338524a33d21f884829bb34abe098aaa29338cf..55fd8ba46e4c1a530ace772e6c4f44047b0b7c92 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
-#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
index 75d052ae705bb730a93349cab9d90d5bf5b73944..9d706085fb474a2bd173dc4bfaa985092dd57f14 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/tiocl.h>
 #include <linux/vt.h>
 #include <stdbool.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
 #include <sysexits.h>
index 4e539aa151d8bc5ca50cfbf62b0f4a097f746a7b..de27eb00645afb6cbb908be1da6e8313da320e09 100755 (executable)
@@ -74,6 +74,22 @@ cmp /expected /output
 { journalctl -ball -b  -m 2>&1 || :; } | head -1 > /output
 cmp /expected /output
 
+# https://github.com/systemd/systemd/issues/13708
+ID=$(systemd-id128 new)
+systemd-cat -t "$ID" bash -c 'echo parent; (echo child) & wait' &
+PID=$!
+wait %%
+journalctl --sync
+# We can drop this grep when https://github.com/systemd/systemd/issues/13937
+# has a fix.
+journalctl -b -o export -t "$ID" --output-fields=_PID | grep '^_PID=' >/output
+[[ `grep -c . /output` -eq 2 ]]
+grep -q "^_PID=$PID" /output
+grep -vq "^_PID=$PID" /output
+
+# Add new tests before here, the journald restarts below
+# may make tests flappy.
+
 # Don't lose streams on restart
 systemctl start forever-print-hola
 sleep 3
diff --git a/test/fuzz/fuzz-network-parser/github-13938 b/test/fuzz/fuzz-network-parser/github-13938
new file mode 100644 (file)
index 0000000..a944a5b
Binary files /dev/null and b/test/fuzz/fuzz-network-parser/github-13938 differ
index e9b9fb0d7c116dc98afdf43f7044940240f06360..ab6e11e0e527dbbe022298832913cee1c288c427 100755 (executable)
@@ -22,12 +22,16 @@ network_sysctl_ipv4_path='/proc/sys/net/ipv4/conf'
 dnsmasq_pid_file='/run/networkd-ci/test-test-dnsmasq.pid'
 dnsmasq_log_file='/run/networkd-ci/test-dnsmasq-log-file'
 
-networkd_bin='/usr/lib/systemd/systemd-networkd'
-resolved_bin='/usr/lib/systemd/systemd-resolved'
-wait_online_bin='/usr/lib/systemd/systemd-networkd-wait-online'
-networkctl_bin='/usr/bin/networkctl'
-resolvectl_bin='/usr/bin/resolvectl'
-timedatectl_bin='/usr/bin/timedatectl'
+systemd_lib_paths=['/usr/lib/systemd', '/lib/systemd']
+which_paths=':'.join(systemd_lib_paths + os.getenv('PATH', os.defpath).lstrip(':').split(':'))
+
+networkd_bin=shutil.which('systemd-networkd', path=which_paths)
+resolved_bin=shutil.which('systemd-resolved', path=which_paths)
+wait_online_bin=shutil.which('systemd-networkd-wait-online', path=which_paths)
+networkctl_bin=shutil.which('networkctl', path=which_paths)
+resolvectl_bin=shutil.which('resolvectl', path=which_paths)
+timedatectl_bin=shutil.which('timedatectl', path=which_paths)
+
 use_valgrind=False
 enable_debug=True
 env = {}
@@ -53,7 +57,7 @@ def run(*command, **kwargs):
 def is_module_available(module_name):
     lsmod_output = check_output('lsmod')
     module_re = re.compile(rf'^{re.escape(module_name)}\b', re.MULTILINE)
-    return module_re.search(lsmod_output) or not call('modprobe', module_name)
+    return module_re.search(lsmod_output) or not call('modprobe', module_name, stderr=subprocess.DEVNULL)
 
 def expectedFailureIfModuleIsNotAvailable(module_name):
     def f(func):
@@ -65,7 +69,7 @@ def expectedFailureIfModuleIsNotAvailable(module_name):
 
 def expectedFailureIfERSPANModuleIsNotAvailable():
     def f(func):
-        rc = call('ip link add dev erspan99 type erspan seq key 30 local 192.168.1.4 remote 192.168.1.1 erspan_ver 1 erspan 123')
+        rc = call('ip link add dev erspan99 type erspan seq key 30 local 192.168.1.4 remote 192.168.1.1 erspan_ver 1 erspan 123', stderr=subprocess.DEVNULL)
         if rc == 0:
             call('ip link del erspan99')
             return func
@@ -76,7 +80,7 @@ def expectedFailureIfERSPANModuleIsNotAvailable():
 
 def expectedFailureIfRoutingPolicyPortRangeIsNotAvailable():
     def f(func):
-        rc = call('ip rule add from 192.168.100.19 sport 1123-1150 dport 3224-3290 table 7')
+        rc = call('ip rule add from 192.168.100.19 sport 1123-1150 dport 3224-3290 table 7', stderr=subprocess.DEVNULL)
         if rc == 0:
             call('ip rule del from 192.168.100.19 sport 1123-1150 dport 3224-3290 table 7')
             return func
@@ -87,7 +91,7 @@ def expectedFailureIfRoutingPolicyPortRangeIsNotAvailable():
 
 def expectedFailureIfRoutingPolicyIPProtoIsNotAvailable():
     def f(func):
-        rc = call('ip rule add not from 192.168.100.19 ipproto tcp table 7')
+        rc = call('ip rule add not from 192.168.100.19 ipproto tcp table 7', stderr=subprocess.DEVNULL)
         if rc == 0:
             call('ip rule del not from 192.168.100.19 ipproto tcp table 7')
             return func
@@ -99,7 +103,7 @@ def expectedFailureIfRoutingPolicyIPProtoIsNotAvailable():
 def expectedFailureIfLinkFileFieldIsNotSet():
     def f(func):
         support = False
-        rc = call('ip link add name dummy99 type dummy')
+        rc = call('ip link add name dummy99 type dummy', stderr=subprocess.DEVNULL)
         if rc == 0:
             ret = run('udevadm info -w10s /sys/class/net/dummy99', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
             if ret.returncode == 0 and 'E: ID_NET_LINK_FILE=' in ret.stdout.rstrip():
@@ -115,7 +119,7 @@ def expectedFailureIfLinkFileFieldIsNotSet():
 
 def expectedFailureIfNexthopIsNotAvailable():
     def f(func):
-        rc = call('ip nexthop list')
+        rc = call('ip nexthop list', stderr=subprocess.DEVNULL)
         if rc == 0:
             return func
         else:
@@ -510,12 +514,12 @@ class NetworkctlTests(unittest.TestCase, Utilities):
 
         output = check_output(*networkctl_cmd, 'status', 'test1')
         print(output)
-        self.assertRegex(output, r'Link File: (?:/usr)/lib/systemd/network/99-default.link')
+        self.assertRegex(output, r'Link File: (/usr)?/lib/systemd/network/99-default.link')
         self.assertRegex(output, r'Network File: /run/systemd/network/11-dummy.network')
 
         output = check_output(*networkctl_cmd, 'status', 'lo')
         print(output)
-        self.assertRegex(output, r'Link File: (?:/usr)/lib/systemd/network/99-default.link')
+        self.assertRegex(output, r'Link File: (/usr)?/lib/systemd/network/99-default.link')
         self.assertRegex(output, r'Network File: n/a')
 
     def test_delete_links(self):
@@ -748,7 +752,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
 
         self.wait_online(['bridge99', 'test1:degraded'], bool_any=True)
 
-        self.check_operstate('bridge99', '(?:off|no-carrier)', setup_state='configuring')
+        self.check_operstate('bridge99', '(off|no-carrier)', setup_state='configuring')
         self.check_operstate('test1', 'degraded')
 
     def test_bridge(self):
@@ -921,7 +925,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         output = check_output('ip -d link show tun99')
         print(output)
         # Old ip command does not support IFF_ flags
-        self.assertRegex(output, 'tun (?:type tun pi on vnet_hdr on multi_queue|addrgenmode) ')
+        self.assertRegex(output, 'tun (type tun pi on vnet_hdr on multi_queue|addrgenmode) ')
 
     def test_tap(self):
         copy_unit_to_networkd_unit_path('25-tap.netdev')
@@ -932,7 +936,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         output = check_output('ip -d link show tap99')
         print(output)
         # Old ip command does not support IFF_ flags
-        self.assertRegex(output, 'tun (?:type tap pi on vnet_hdr on multi_queue|addrgenmode) ')
+        self.assertRegex(output, 'tun (type tap pi on vnet_hdr on multi_queue|addrgenmode) ')
 
     @expectedFailureIfModuleIsNotAvailable('vrf')
     def test_vrf(self):
@@ -1010,16 +1014,16 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
 
         output = check_output('ip -d link show ipiptun99')
         print(output)
-        self.assertRegex(output, 'ipip (?:ipip |)remote 192.169.224.239 local 192.168.223.238 dev dummy98')
+        self.assertRegex(output, 'ipip (ipip )?remote 192.169.224.239 local 192.168.223.238 dev dummy98')
         output = check_output('ip -d link show ipiptun98')
         print(output)
-        self.assertRegex(output, 'ipip (?:ipip |)remote 192.169.224.239 local any dev dummy98')
+        self.assertRegex(output, 'ipip (ipip )?remote 192.169.224.239 local any dev dummy98')
         output = check_output('ip -d link show ipiptun97')
         print(output)
-        self.assertRegex(output, 'ipip (?:ipip |)remote any local 192.168.223.238 dev dummy98')
+        self.assertRegex(output, 'ipip (ipip )?remote any local 192.168.223.238 dev dummy98')
         output = check_output('ip -d link show ipiptun96')
         print(output)
-        self.assertRegex(output, 'ipip (?:ipip |)remote any local any dev dummy98')
+        self.assertRegex(output, 'ipip (ipip )?remote any local any dev dummy98')
 
     def test_gre_tunnel(self):
         copy_unit_to_networkd_unit_path('12-dummy.netdev', 'gretun.network',
@@ -1159,10 +1163,10 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         self.assertRegex(output, 'vti6 remote 2001:473:fece:cafe::5179 local 2a00:ffde:4567:edde::4987 dev dummy98')
         output = check_output('ip -d link show vti6tun98')
         print(output)
-        self.assertRegex(output, 'vti6 remote 2001:473:fece:cafe::5179 local (?:any|::) dev dummy98')
+        self.assertRegex(output, 'vti6 remote 2001:473:fece:cafe::5179 local (any|::) dev dummy98')
         output = check_output('ip -d link show vti6tun97')
         print(output)
-        self.assertRegex(output, 'vti6 remote (?:any|::) local 2a00:ffde:4567:edde::4987 dev dummy98')
+        self.assertRegex(output, 'vti6 remote (any|::) local 2a00:ffde:4567:edde::4987 dev dummy98')
 
     def test_ip6tnl_tunnel(self):
         copy_unit_to_networkd_unit_path('12-dummy.netdev', 'ip6tnl.network',
@@ -1177,10 +1181,10 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         self.assertRegex(output, 'ip6tnl ip6ip6 remote 2001:473:fece:cafe::5179 local 2a00:ffde:4567:edde::4987 dev dummy98')
         output = check_output('ip -d link show ip6tnl98')
         print(output)
-        self.assertRegex(output, 'ip6tnl ip6ip6 remote 2001:473:fece:cafe::5179 local (?:any|::) dev dummy98')
+        self.assertRegex(output, 'ip6tnl ip6ip6 remote 2001:473:fece:cafe::5179 local (any|::) dev dummy98')
         output = check_output('ip -d link show ip6tnl97')
         print(output)
-        self.assertRegex(output, 'ip6tnl ip6ip6 remote (?:any|::) local 2a00:ffde:4567:edde::4987 dev dummy98')
+        self.assertRegex(output, 'ip6tnl ip6ip6 remote (any|::) local 2a00:ffde:4567:edde::4987 dev dummy98')
 
     def test_sit_tunnel(self):
         copy_unit_to_networkd_unit_path('12-dummy.netdev', 'sit.network',
@@ -1193,16 +1197,16 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
 
         output = check_output('ip -d link show sittun99')
         print(output)
-        self.assertRegex(output, "sit (?:ip6ip |)remote 10.65.223.239 local 10.65.223.238 dev dummy98")
+        self.assertRegex(output, "sit (ip6ip )?remote 10.65.223.239 local 10.65.223.238 dev dummy98")
         output = check_output('ip -d link show sittun98')
         print(output)
-        self.assertRegex(output, "sit (?:ip6ip |)remote 10.65.223.239 local any dev dummy98")
+        self.assertRegex(output, "sit (ip6ip )?remote 10.65.223.239 local any dev dummy98")
         output = check_output('ip -d link show sittun97')
         print(output)
-        self.assertRegex(output, "sit (?:ip6ip |)remote any local 10.65.223.238 dev dummy98")
+        self.assertRegex(output, "sit (ip6ip )?remote any local 10.65.223.238 dev dummy98")
         output = check_output('ip -d link show sittun96')
         print(output)
-        self.assertRegex(output, "sit (?:ip6ip |)remote any local any dev dummy98")
+        self.assertRegex(output, "sit (ip6ip )?remote any local any dev dummy98")
 
     def test_isatap_tunnel(self):
         copy_unit_to_networkd_unit_path('12-dummy.netdev', 'isatap.network',
@@ -1596,7 +1600,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         print(output)
         self.assertRegex(output, '111:')
         self.assertRegex(output, 'from 192.168.100.18')
-        self.assertRegex(output, r'tos (?:0x08|throughput)\s')
+        self.assertRegex(output, r'tos (0x08|throughput)\s')
         self.assertRegex(output, 'iif test1')
         self.assertRegex(output, 'oif test1')
         self.assertRegex(output, 'lookup 7')
@@ -1634,11 +1638,11 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
 
             output = check_output('ip rule list table 7')
             print(output)
-            self.assertRegex(output, '111:     from 192.168.100.18 tos (?:0x08|throughput) iif test1 oif test1 lookup 7')
+            self.assertRegex(output, '111:     from 192.168.100.18 tos (0x08|throughput) iif test1 oif test1 lookup 7')
 
             output = check_output('ip rule list table 8')
             print(output)
-            self.assertRegex(output, '112:     from 192.168.101.18 tos (?:0x08|throughput) iif dummy98 oif dummy98 lookup 8')
+            self.assertRegex(output, '112:     from 192.168.101.18 tos (0x08|throughput) iif dummy98 oif dummy98 lookup 8')
 
             stop_networkd(remove_state_files=False)
 
@@ -2109,7 +2113,7 @@ class NetworkdStateFileTests(unittest.TestCase, Utilities):
             self.assertRegex(data, r'LLMNR=no')
             self.assertRegex(data, r'MDNS=yes')
             self.assertRegex(data, r'DNSSEC=no')
-            self.assertRegex(data, r'ADDRESSES=192.168.(?:10.10|12.12)/24 192.168.(?:12.12|10.10)/24')
+            self.assertRegex(data, r'ADDRESSES=192.168.(10.10|12.12)/24 192.168.(12.12|10.10)/24')
 
         check_output(*resolvectl_cmd, 'dns', 'dummy98', '10.10.10.12', '10.10.10.13', env=env)
         check_output(*resolvectl_cmd, 'domain', 'dummy98', 'hogehogehoge', '~foofoofoo', env=env)
@@ -2379,7 +2383,7 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
         print('### ip -6 route list table all dev bridge99')
         output = check_output('ip -6 route list table all dev bridge99')
         print(output)
-        self.assertRegex(output, 'ff00::/8 table local metric 256 (?:linkdown |)pref medium')
+        self.assertRegex(output, 'ff00::/8 table local metric 256 (linkdown )?pref medium')
 
     def test_bridge_ignore_carrier_loss(self):
         copy_unit_to_networkd_unit_path('11-dummy.netdev', '12-dummy.netdev', '26-bridge.netdev',
@@ -2645,7 +2649,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
 
         # link become 'routable' when at least one protocol provide an valid address.
         self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
-        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
 
         output = check_output(*networkctl_cmd, 'status', 'veth99', env=env)
         print(output)
@@ -2824,7 +2828,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
 
         output = check_output('ip address show dev veth99 scope global')
         print(output)
-        self.assertRegex(output, r'inet6 2600::[0-9a-f]*/128 scope global (?:noprefixroute dynamic|dynamic noprefixroute)')
+        self.assertRegex(output, r'inet6 2600::[0-9a-f]*/128 scope global (noprefixroute dynamic|dynamic noprefixroute)')
 
         output = check_output('ip -6 route show dev veth99')
         print(output)
@@ -2933,7 +2937,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
 
         # link become 'routable' when at least one protocol provide an valid address.
         self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
-        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
 
         output = check_output('ip address show dev veth99 scope global')
         print(output)
@@ -2976,7 +2980,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
 
         # link become 'routable' when at least one protocol provide an valid address.
         self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
-        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
 
         print('## ip -d link show dev vrf99')
         output = check_output('ip -d link show dev vrf99')
@@ -2988,7 +2992,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
         print(output)
         self.assertRegex(output, 'inet 169.254.[0-9]*.[0-9]*/16 brd 169.254.255.255 scope link veth99')
         self.assertRegex(output, 'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic veth99')
-        self.assertRegex(output, 'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)')
+        self.assertRegex(output, 'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)')
         self.assertRegex(output, 'inet6 .* scope link')
 
         print('## ip address show dev veth99')
@@ -2996,7 +3000,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
         print(output)
         self.assertRegex(output, 'inet 169.254.[0-9]*.[0-9]*/16 brd 169.254.255.255 scope link veth99')
         self.assertRegex(output, 'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic veth99')
-        self.assertRegex(output, 'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)')
+        self.assertRegex(output, 'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)')
         self.assertRegex(output, 'inet6 .* scope link')
 
         print('## ip route show vrf vrf99')
@@ -3145,7 +3149,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
 
         # link become 'routable' when at least one protocol provide an valid address.
         self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
-        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
 
         time.sleep(3)
         output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
@@ -3163,7 +3167,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
 
         # link become 'routable' when at least one protocol provide an valid address.
         self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
-        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
 
         time.sleep(3)
         output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
@@ -3181,7 +3185,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
 
         # link become 'routable' when at least one protocol provide an valid address.
         self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
-        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
 
         time.sleep(3)
         output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)
@@ -3199,7 +3203,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
 
         # link become 'routable' when at least one protocol provide an valid address.
         self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic', ipv='-4')
-        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (?:dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
+        self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
 
         time.sleep(3)
         output = check_output(*resolvectl_cmd, 'dns', 'veth99', env=env)