diff --git a/NEWS b/NEWS index 0a32e99be..f010959be 100644 --- a/NEWS +++ b/NEWS @@ -10698,7 +10698,7 @@ CHANGES WITH 211: also supports LUKS-encrypted partitions now. With this in place, automatic discovery of partitions to mount following the Discoverable Partitions Specification - (https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec) + (https://systemd.io/DISCOVERABLE_PARTITIONS/) is now a lot more complete. This allows booting without /etc/fstab and without root= on the kernel command line on systems prepared appropriately. @@ -12203,7 +12203,7 @@ CHANGES WITH 198: only in conjunction with Gummiboot, but could be supported by other boot loaders too. For details see: - https://www.freedesktop.org/wiki/Software/systemd/BootLoaderInterface + https://systemd.io/BOOT_LOADER_INTERFACE * A new generator has been added that automatically mounts the EFI System Partition (ESP) to /boot, if that directory @@ -12279,7 +12279,7 @@ CHANGES WITH 198: * A new tool kernel-install has been added that can install kernel images according to the Boot Loader Specification: - https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec + https://systemd.io/BOOT_LOADER_SPECIFICATION * Boot time console output has been improved to provide animated boot time output for hanging jobs. @@ -12369,7 +12369,7 @@ CHANGES WITH 197: of these policies is now the default. Please see this wiki document for details: - https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames + https://www.freedesktop.org/software/systemd/man/systemd.net-naming-scheme.html * Auke Kok's bootchart implementation has been added to the systemd tree. It is an optional component that can graph the @@ -13368,7 +13368,7 @@ CHANGES WITH 183: * A framework for implementing offline system updates is now integrated, for details see: - https://www.freedesktop.org/wiki/Software/systemd/SystemUpdates + https://www.freedesktop.org/software/systemd/man/systemd.offline-updates.html * A new service type Type=idle is available now which helps us avoiding ugly interleaving of getty output and boot status @@ -13736,7 +13736,7 @@ CHANGES WITH 38: * Processes with '@' in argv[0][0] are now excluded from the final shut-down killing spree, following the logic explained in: - https://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons + https://systemd.io/ROOT_STORAGE_DAEMONS/ * All processes remaining in a service cgroup when we enter the START or START_PRE states are now killed with diff --git a/README b/README index 6d5b91bbb..f47a88454 100644 --- a/README +++ b/README @@ -1,10 +1,7 @@ systemd System and Service Manager -DETAILS: - http://0pointer.de/blog/projects/systemd.html - WEB SITE: - https://www.freedesktop.org/wiki/Software/systemd + https://systemd.io GIT: git@github.com:systemd/systemd.git @@ -19,6 +16,11 @@ IRC: BUG REPORTS: https://github.com/systemd/systemd/issues +OLDER DOCUMENTATION: + + http://0pointer.de/blog/projects/systemd.html + https://www.freedesktop.org/wiki/Software/systemd + AUTHOR: Lennart Poettering Kay Sievers diff --git a/TODO b/TODO index 47ae975b3..8c5074902 100644 --- a/TODO +++ b/TODO @@ -816,7 +816,7 @@ Features: Note that we start initrd-fs.target and initrd-cleanup.target there, so a straightforward ConditionPathExists= is not enough. -* docs: bring http://www.freedesktop.org/wiki/Software/systemd/MyServiceCantGetRealtime up to date +* docs: bring https://www.freedesktop.org/wiki/Software/systemd/MyServiceCantGetRealtime up to date * add a job mode that will fail if a transaction would mean stopping running units. Use this in timedated to manage the NTP service diff --git a/docs/CONTAINER_INTERFACE.md b/docs/CONTAINER_INTERFACE.md index 7caa9eeea..1332ed3e4 100644 --- a/docs/CONTAINER_INTERFACE.md +++ b/docs/CONTAINER_INTERFACE.md @@ -8,7 +8,7 @@ SPDX-License-Identifier: LGPL-2.1-or-later # The Container Interface Also consult [Writing Virtual Machine or Container -Managers](http://www.freedesktop.org/wiki/Software/systemd/writing-vm-managers). +Managers](https://www.freedesktop.org/wiki/Software/systemd/writing-vm-managers). systemd has a number of interfaces for interacting with container managers, when systemd is used inside of an OS container. If you work on a container diff --git a/docs/DISCOVERABLE_PARTITIONS.md b/docs/DISCOVERABLE_PARTITIONS.md index ca4c6ca81..b375106af 100644 --- a/docs/DISCOVERABLE_PARTITIONS.md +++ b/docs/DISCOVERABLE_PARTITIONS.md @@ -31,8 +31,8 @@ for specific uses. This has many benefits: descriptive information about partitions tables. Note that the OS side of this specification is currently implemented in -[systemd](http://systemd.io/) 211 and newer in the -[systemd-gpt-auto-generator(8)](http://www.freedesktop.org/software/systemd/man/systemd-gpt-auto-generator.html) +[systemd](https://systemd.io/) 211 and newer in the +[systemd-gpt-auto-generator(8)](https://www.freedesktop.org/software/systemd/man/systemd-gpt-auto-generator.html) generator tool. Note that automatic discovery of the root only works if the boot loader communicates this information to the OS, by implementing the [Boot Loader @@ -164,7 +164,7 @@ Other GPT type IDs might be used on Linux, for example to mark software RAID or LVM partitions. The definitions of those GPT types is outside of the scope of this specification. -[systemd-id128(1)](http://www.freedesktop.org/software/systemd/man/systemd-id128.html)'s +[systemd-id128(1)](https://www.freedesktop.org/software/systemd/man/systemd-id128.html)'s `show` command may be used to list those GPT partition type UUIDs. ## Partition Names diff --git a/docs/JOURNAL_FILE_FORMAT.md b/docs/JOURNAL_FILE_FORMAT.md index 2bfc7a10c..f9c9fcb31 100644 --- a/docs/JOURNAL_FILE_FORMAT.md +++ b/docs/JOURNAL_FILE_FORMAT.md @@ -7,11 +7,9 @@ SPDX-License-Identifier: LGPL-2.1-or-later # Journal File Format -_Note that this document describes the binary on-disk format of journals -only. For interfacing with web technologies there's the [Journal JSON -Format](http://www.freedesktop.org/wiki/Software/systemd/json). For transfer -of journal data across the network there's the [Journal Export -Format](http://www.freedesktop.org/wiki/Software/systemd/export)._ +_Note that this document describes the binary on-disk format of journals only. +For interfacing with web technologies there's the [Journal JSON Format](https://systemd.io/JOURNAL_EXPORT_FORMATS#journal-json-format). +For transfer of journal data across the network there's the [Journal Export Format](https://systemd.io/JOURNAL_EXPORT_FORMATS#journal-export-format)._ The systemd journal stores log data in a binary format with several features: @@ -32,30 +30,30 @@ keep this document up-to-date and accurate. Instead of implementing your own reader or writer for journal files we ask you to use the [Journal's native C -API](http://www.freedesktop.org/software/systemd/man/sd-journal.html) to access +API](https://www.freedesktop.org/software/systemd/man/sd-journal.html) to access these files. It provides you with full access to the files, and will not withhold any data. If you find a limitation, please ping us and we might add some additional interfaces for you. If you need access to the raw journal data in serialized stream form without C API our recommendation is to make use of the [Journal Export -Format](http://www.freedesktop.org/wiki/Software/systemd/export), which you can -get via "journalctl -o export" or via systemd-journal-gatewayd. The export +Format](https://systemd.io/JOURNAL_EXPORT_FORMATS#journal-export-format), which you can +get via `journalctl -o export` or via `systemd-journal-gatewayd`. The export format is much simpler to parse, but complete and accurate. Due to its stream-based nature it is not indexed. _Or, to put this in other words: this low-level document is probably not what you want to use as base of your project. You want our [C -API](http://www.freedesktop.org/software/systemd/man/sd-journal.html) instead! +API](https://www.freedesktop.org/software/systemd/man/sd-journal.html) instead! And if you really don't want the C API, then you want the [Journal Export -Format](http://www.freedesktop.org/wiki/Software/systemd/export) instead! This -document is primarily for your entertainment and education. Thank you!_ +Format or Journal JSON Format](https://systemd.io/JOURNAL_EXPORT_FORMATS) instead! +This document is primarily for your entertainment and education. Thank you!_ This document assumes you have a basic understanding of the journal concepts, the properties of a journal entry and so on. If not, please go and read up, then come back! This is a good opportunity to read about the [basic properties of journal -entries](http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html), +entries](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html), in particular realize that they may include binary non-text data (though usually don't), and the same field might have multiple values assigned within the same entry. diff --git a/docs/PORTABILITY_AND_STABILITY.md b/docs/PORTABILITY_AND_STABILITY.md index 674fe89b9..0b92fda27 100644 --- a/docs/PORTABILITY_AND_STABILITY.md +++ b/docs/PORTABILITY_AND_STABILITY.md @@ -100,7 +100,7 @@ And now, here's the list of (hopefully) all APIs that we have introduced with sy | [Network](https://www.freedesktop.org/software/systemd/man/systemd.network.html) & [Netdev file format](https://www.freedesktop.org/software/systemd/man/systemd.netdev.html) | File format | yes | yes | no | no | - | no | | [Link file format](https://www.freedesktop.org/software/systemd/man/systemd.link.html) | File format | yes | yes | no | no | - | no | | [Journal File Format](https://systemd.io/JOURNAL_FILE_FORMAT) | File format | yes | yes | - | maybe | - | no | -| [Journal Export Format](https://www.freedesktop.org/wiki/Software/systemd/export) | File format | yes | yes | - | yes | - | no | +| [Journal Export Format](https://systemd.io/JOURNAL_EXPORT_FORMATS#journal-export-format) | File format | yes | yes | - | yes | - | no | | [Cooperation in cgroup tree](https://www.freedesktop.org/wiki/Software/systemd/PaxControlGroups) | Treaty | yes | yes | libvirt | yes | libvirt | no | | [Password Agents](https://systemd.io/PASSWORD_AGENTS) | Socket+Files | yes | yes | - | yes | - | no | | [udev multi-seat properties](https://www.freedesktop.org/software/systemd/man/sd-login.html) | udev Property | yes | yes | X11, gdm | no | - | no | diff --git a/docs/PREDICTABLE_INTERFACE_NAMES.md b/docs/PREDICTABLE_INTERFACE_NAMES.md index ae16d7211..ffc681bda 100644 --- a/docs/PREDICTABLE_INTERFACE_NAMES.md +++ b/docs/PREDICTABLE_INTERFACE_NAMES.md @@ -62,7 +62,7 @@ Does this have any drawbacks? Yes, it does. Previously it was practically guaran You basically have three options: 1. You disable the assignment of fixed names, so that the unpredictable kernel names are used again. For this, simply mask udev's .link file for the default policy: `ln -s /dev/null /etc/systemd/network/99-default.link` -1. You create your own manual naming scheme, for example by naming your interfaces `internet0`, `dmz0` or `lan0`. For that create your own `.link` files in `/etc/systemd/network/`, that choose an explicit name or a better naming scheme for one, some, or all of your interfaces. See [systemd.link(5)](http://www.freedesktop.org/software/systemd/man/systemd.link.html) for more information. +1. You create your own manual naming scheme, for example by naming your interfaces `internet0`, `dmz0` or `lan0`. For that create your own `.link` files in `/etc/systemd/network/`, that choose an explicit name or a better naming scheme for one, some, or all of your interfaces. See [systemd.link(5)](https://www.freedesktop.org/software/systemd/man/systemd.link.html) for more information. 1. You pass the `net.ifnames=0` on the kernel command line ## How does the new naming scheme look like, precisely? diff --git a/docs/TRANSIENT-SETTINGS.md b/docs/TRANSIENT-SETTINGS.md index 7bab5ec15..2c893cad6 100644 --- a/docs/TRANSIENT-SETTINGS.md +++ b/docs/TRANSIENT-SETTINGS.md @@ -34,6 +34,7 @@ Most generic unit settings are available for transient units. ✓ PropagatesReloadTo= ✓ ReloadPropagatedFrom= ✓ PartOf= +✓ Upholds= ✓ JoinsNamespaceOf= ✓ RequiresMountsFor= ✓ StopWhenUnneeded= diff --git a/docs/_config.yml b/docs/_config.yml index d54303126..412db1f41 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later title: systemd baseurl: "" # the subpath of your site, e.g. /blog/ -url: "http://systemd.io" # the base hostname & protocol for your site +url: "https://systemd.io" # the base hostname & protocol for your site permalink: /:title/ diff --git a/man/journalctl.xml b/man/journalctl.xml index 4be2ed347..9e784f3d3 100644 --- a/man/journalctl.xml +++ b/man/journalctl.xml @@ -301,7 +301,7 @@ serializes the journal into a binary (but mostly text-based) stream suitable for backups and network transfer (see - Journal Export Format + Journal Export Format for more information). To import the binary stream back into native journald format use systemd-journal-remote8. @@ -314,7 +314,7 @@ formats entries as JSON objects, separated by newline characters (see Journal JSON Format for more + url="https://systemd.io/JOURNAL_EXPORT_FORMATS#journal-json-format">Journal JSON Format for more information). Field values are generally encoded as JSON strings, with three exceptions: Fields larger than 4096 bytes are encoded as null values. (This diff --git a/man/org.freedesktop.login1.xml b/man/org.freedesktop.login1.xml index a301879ff..d25287b18 100644 --- a/man/org.freedesktop.login1.xml +++ b/man/org.freedesktop.login1.xml @@ -621,7 +621,7 @@ node /org/freedesktop/login1 { whether the inhibit shall be consider mandatory or whether it should just delay the operation to a certain maximum time. The method returns a file descriptor. The lock is released the moment this file descriptor and all its duplicates are closed. For more information on the inhibition logic see - Inhibitor Locks. + Inhibitor Locks. @@ -644,7 +644,7 @@ node /org/freedesktop/login1 { that should be done shortly before shutdown/sleep, in conjunction with delay inhibitor locks. After completion of this work they should release their inhibition locks in order to not delay the operation any further. For more information see - Inhibitor Locks. + Inhibitor Locks. diff --git a/man/org.freedesktop.resolve1.xml b/man/org.freedesktop.resolve1.xml index b8fff5a50..72beffc28 100644 --- a/man/org.freedesktop.resolve1.xml +++ b/man/org.freedesktop.resolve1.xml @@ -506,7 +506,7 @@ node /org/freedesktop/resolve1 { /etc/hosts. Moreover, it is set for all LLMNR or mDNS RRs which originate from the local host. Applications that require authenticated RR data for operation should check this flag before trusting the data. Note that systemd-resolved will never return - invalidated data, hence this flag simply allows to discern the cases where data is known to be + invalidated data, hence this flag simply allows one to discern the cases where data is known to be trusted, or where there is proof that the data is "rightfully" unauthenticated (which includes cases where the underlying protocol or server does not support authenticating data). diff --git a/man/org.freedesktop.systemd1.xml b/man/org.freedesktop.systemd1.xml index 31485935a..bd69a00b5 100644 --- a/man/org.freedesktop.systemd1.xml +++ b/man/org.freedesktop.systemd1.xml @@ -1427,7 +1427,7 @@ node /org/freedesktop/systemd1 { properties contains properties of the unit, specified like in SetUnitProperties(). aux is currently unused and should be passed as an empty array. See the - New Control Group + New Control Group Interface for more information how to make use of this functionality for resource control purposes. @@ -1649,6 +1649,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice { @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as PartOf = ['...', ...]; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") + readonly as Upholds = ['...', ...]; + @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as RequiredBy = ['...', ...]; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as RequisiteOf = ['...', ...]; @@ -1657,6 +1659,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice { @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as BoundBy = ['...', ...]; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") + readonly as UpheldBy = ['...', ...]; + @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as ConsistsOf = ['...', ...]; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as Conflicts = ['...', ...]; @@ -1667,14 +1671,14 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice { @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as After = ['...', ...]; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") - readonly as OnFailure = ['...', ...]; - @org.freedesktop.DBus.Property.EmitsChangedSignal("const") - readonly as OnFailureOf = ['...', ...]; - @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as OnSuccess = ['...', ...]; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as OnSuccessOf = ['...', ...]; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") + readonly as OnFailure = ['...', ...]; + @org.freedesktop.DBus.Property.EmitsChangedSignal("const") + readonly as OnFailureOf = ['...', ...]; + @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as Triggers = ['...', ...]; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly as TriggeredBy = ['...', ...]; @@ -1820,16 +1824,20 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice { + + - + - + + + @@ -1948,6 +1956,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice { + + @@ -1956,6 +1966,8 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice { + + @@ -1966,14 +1978,14 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice { - - - - + + + + diff --git a/man/rules/meson.build b/man/rules/meson.build index ca19dc73e..b689b1c1a 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -962,6 +962,7 @@ manpages = [ ['systemd-sleep.conf', '5', ['sleep.conf.d'], ''], ['systemd-socket-activate', '1', [], ''], ['systemd-socket-proxyd', '8', [], ''], + ['systemd-stdio-bridge', '1', [], ''], ['systemd-stub', '7', ['linuxaa64.efi.stub', 'linuxia32.efi.stub', 'linuxx64.efi.stub'], diff --git a/man/sd_bus_message_read.xml b/man/sd_bus_message_read.xml index 0b921258d..aa325f39c 100644 --- a/man/sd_bus_message_read.xml +++ b/man/sd_bus_message_read.xml @@ -172,7 +172,23 @@ On success, these functions return a non-negative integer. On failure, they return a negative errno-style error code. - + + Errors + + Returned errors may indicate the following problems: + + + + + + + -EBUSY + + When reading from a container, this error will be returned if unread elements + are left in the container. + + + diff --git a/man/sd_bus_message_read_basic.xml b/man/sd_bus_message_read_basic.xml index bd5a149a2..55951430e 100644 --- a/man/sd_bus_message_read_basic.xml +++ b/man/sd_bus_message_read_basic.xml @@ -199,21 +199,21 @@ Returned errors may indicate the following problems: - + -EINVAL Specified type string is invalid or the message parameter is NULL. - + -ENXIO The message does not contain the specified type at current position. - + -EBADMSG The message cannot be parsed. diff --git a/man/sd_bus_set_description.xml b/man/sd_bus_set_description.xml index ce6b8d387..0c38c1612 100644 --- a/man/sd_bus_set_description.xml +++ b/man/sd_bus_set_description.xml @@ -141,7 +141,7 @@ specification, informing the receiving side that the caller is prepared to wait for interactive authorization, which might take a considerable time to complete. If this flag is set, the user may be queried for passwords or confirmation via - polkit or a similar + polkit or a similar framework. sd_bus_get_allow_interactive_authorization() returns true if diff --git a/man/systemd-coredump.xml b/man/systemd-coredump.xml index bb84cf5f9..cb9f47745 100644 --- a/man/systemd-coredump.xml +++ b/man/systemd-coredump.xml @@ -79,7 +79,7 @@ It is also possible to invoke systemd-coredump with option. In this case, systemd-coredump expects a journal entry in the journal - Journal Export Format + Journal Export Format on standard input. The entry should contain a MESSAGE= field and any additional metadata fields the caller deems reasonable. systemd-coredump will append additional metadata fields in the same way it does for core dumps received from the kernel. In this mode, no core diff --git a/man/systemd-journal-gatewayd.service.xml b/man/systemd-journal-gatewayd.service.xml index 5f4a0dbef..609d05037 100644 --- a/man/systemd-journal-gatewayd.service.xml +++ b/man/systemd-journal-gatewayd.service.xml @@ -212,9 +212,8 @@ Entries are formatted as JSON data structures, one per line (like journalctl --output json). - See Journal - JSON Format for more information. + See Journal JSON Format + for more information. @@ -233,13 +232,10 @@ application/vnd.fdo.journal - Entries are serialized into a binary (but - mostly text-based) stream suitable for backups and network - transfer - (like journalctl --output export). - See Journal - Export Format for more information. + Entries are serialized into a binary (but mostly text-based) stream suitable for + backups and network transfer (like journalctl --output export). See Journal Export Format + for more information. @@ -303,10 +299,8 @@ Examples - Retrieve events from this boot from local journal - in Journal - Export Format: + Retrieve events from this boot from local journal in + Journal Export Format: curl --silent -H'Accept: application/vnd.fdo.journal' \ 'http://localhost:19531/entries?boot' diff --git a/man/systemd-journal-remote.service.xml b/man/systemd-journal-remote.service.xml index bea0936d6..e66e0f1e9 100644 --- a/man/systemd-journal-remote.service.xml +++ b/man/systemd-journal-remote.service.xml @@ -42,7 +42,7 @@ systemd-journal-remote is a command to receive serialized journal events and store them to journal files. Input streams are in the - Journal Export Format, + Journal Export Format, i.e. like the output from journalctl --output=export. For transport over the network, this serialized stream is usually carried over an HTTPS connection. diff --git a/man/systemd-logind.service.xml b/man/systemd-logind.service.xml index 746c9163b..0bffbbb38 100644 --- a/man/systemd-logind.service.xml +++ b/man/systemd-logind.service.xml @@ -43,7 +43,7 @@ used. Providing polkit-based + url="https://www.freedesktop.org/wiki/Software/polkit">polkit-based access for users for operations such as system shutdown or sleep @@ -92,7 +92,7 @@ Writing Display Managers. If you are interested in writing a desktop environment that makes use of logind, please have look at - Writing + Writing Desktop Environments. diff --git a/man/systemd-stdio-bridge.xml b/man/systemd-stdio-bridge.xml new file mode 100644 index 000000000..002a91b12 --- /dev/null +++ b/man/systemd-stdio-bridge.xml @@ -0,0 +1,92 @@ + + + + + + + + systemd-stdio-bridge + systemd + + + + systemd-stdio-bridge + 1 + + + + systemd-stdio-bridge + D-Bus proxy + + + + + systemd-stdio-bridge + OPTIONS + + + + + Description + + systemd-stdio-bridge implements a proxy for a D-Bus endpoint. It expects to + receive an open connection to a bus when started, and will also connect to a (different) bus as a + client. It will then act as a server on the first connection, and forward messages between the two + busses. This program is suitable for socket activation: the first connection may be a pipe or a socket + and must be passed as either standard input, or as an open file descriptor according to the protocol + described in + sd_listen_fds3. The + second connection will be made by default to the local system bus, but this can be influenced by the + , , , and + options described below. + + sd-bus3 uses + systemd-stdio-bridge to forward D-Bus connections over + ssh1, + or to connect to the bus of a different user, see + sd_bus_set_address3. + + + + + Options + + The following options are understood: + + + + + + + + + + + Path to the bus address. Default: unix:path=/run/dbus/system_bus_socket + + + + + + + + + + Exit status + + On success, 0 is returned, a non-zero failure code otherwise. + + + + See Also + + dbus-daemon1, + dbus-broker1, + D-Bus, + systemd1 + + + + diff --git a/man/systemd-xdg-autostart-generator.xml b/man/systemd-xdg-autostart-generator.xml index 4d153c304..bafe6e9c2 100644 --- a/man/systemd-xdg-autostart-generator.xml +++ b/man/systemd-xdg-autostart-generator.xml @@ -41,6 +41,55 @@ systemd.special7 for more details. + XDG autostart may be conditionalized using both standardized and non-standardized keys. + In order to handle these, the generator may create one or more ExecCondition= entries. + For non-standardized keys, well-known helper binaries provided by Desktop Environments are used. + All external helpers must detect their corresponding desktop environment and + must return success when run in a different environment. + This is important as all ExecCondition= directives must succeed for an application to be started. + + + + Special XDG desktop file entries that are processed + + + + + + + Entry + Handling + + + + + Hidden=, X-systemd-skip= + No service will be generated if set to true + + + OnlyShowIn=, NotShowIn= + ExecCondition= using systemd-xdg-autostart-condition + + + TryExec= + No service will be generated if the binary does not exist or cannot be executed + + + AutostartCondition= (GNOME extension) + ExecCondition= using gnome-systemd-autostart-condition + + + X-GNOME-Autostart-Phase= + No service will be generated if set to any value + + + X-KDE-autostart-condition= + ExecCondition= using kde-systemd-start-condition + + + +
+ systemd-xdg-autostart-generator implements systemd.generator7. diff --git a/man/systemd.journal-fields.xml b/man/systemd.journal-fields.xml index 554b51723..241d60f67 100644 --- a/man/systemd.journal-fields.xml +++ b/man/systemd.journal-fields.xml @@ -515,11 +515,10 @@ Address Fields During serialization into external formats, such as the - Journal - Export Format or the Journal - JSON Format, the addresses of journal entries are + Journal Export Format + or the + Journal JSON Format, + the addresses of journal entries are serialized into fields prefixed with double underscores. Note that these are not proper fields when stored in the journal but for addressing metadata of entries. They cannot be written as part of diff --git a/man/systemd.netdev.xml b/man/systemd.netdev.xml index 0aec58fc8..f49f3e842 100644 --- a/man/systemd.netdev.xml +++ b/man/systemd.netdev.xml @@ -1566,14 +1566,14 @@ RouteTable= The table identifier for the routes to the addresses specified in the - AllowedIPs=. Takes the special value off, one of the - predefined names default, main, and - local, names defined in RouteTable= in + AllowedIPs=. Takes a negative boolean value, one of the predefined names + default, main, and local, names + defined in RouteTable= in networkd.conf5, or a number in the range 1…4294967295. When off the routes to the addresses specified in the AllowedIPs= setting will not be configured. - Defaults to main. This setting will be ignored when the same setting is - specified in the [WireGuardPeer] section. + Defaults to false. This setting will be ignored when the same setting is specified in the + [WireGuardPeer] section. @@ -1673,9 +1673,9 @@ RouteTable= The table identifier for the routes to the addresses specified in the - AllowedIPs=. Takes the special value off, one of the - predefined names default, main, and - local, names defined in RouteTable= in + AllowedIPs=. Takes a negative boolean value, one of the predefined names + default, main, and local, names + defined in RouteTable= in networkd.conf5, or a number in the range 1…4294967295. Defaults to unset, and the value specified in the same setting in the [WireGuard] section will be used. @@ -2064,7 +2064,7 @@ HopPenalty= - The hop penalty setting allows to modify + The hop penalty setting allows one to modify batctl8 preference for multihop routes vs. short routes. This integer value is applied to the TQ (Transmit Quality) of each forwarded OGM (Originator Message), thereby propagating the diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 197e0dad1..a98157d9c 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -362,7 +362,7 @@ Trust= - Takes a boolean. Allows to set trust mode of the virtual function (VF). When set, VF + Takes a boolean. Allows one to set trust mode of the virtual function (VF). When set, VF users can set a specific feature which may impact security and/or performance. When unset, the kernel's default will be used. @@ -371,7 +371,7 @@ LinkState= - Allows to set the link state of the virtual function (VF). Takes a boolean or a + Allows one to set the link state of the virtual function (VF). Takes a boolean or a special value auto. Setting to auto means a reflection of the physical function (PF) link state, yes lets the VF to communicate with other VFs on this host even if the PF link state is down, @@ -2038,7 +2038,7 @@ Table=1234 FallbackLeaseLifetimeSec= - Allows to set DHCPv4 lease lifetime when DHCPv4 server does not send the lease + Allows one to set DHCPv4 lease lifetime when DHCPv4 server does not send the lease lifetime. Takes one of forever or infinity. If specified, the acquired address never expires. Defaults to unset. @@ -3234,7 +3234,7 @@ Token=prefixstable:2002:da8:1:: SyncJumpWidth= Specifies the time quanta, propagation segment, phase buffer segment 1 and 2, and the - synchronization jump width, which allow to define the CAN bit-timing in a hardware + synchronization jump width, which allow one to define the CAN bit-timing in a hardware independent format as proposed by the Bosch CAN 2.0 Specification. TimeQuantaNSec= takes a timespan in nanoseconds. PropagationSegment=, PhaseBufferSegment1=, diff --git a/src/basic/log.c b/src/basic/log.c index 7bc2f2800..12071e2eb 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -1189,14 +1189,9 @@ static bool should_parse_proc_cmdline(void) { return getpid_cached() == p; } -void log_parse_environment(void) { +void log_parse_environment_variables(void) { const char *e; - /* Do not call from library code. */ - - if (should_parse_proc_cmdline()) - (void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX); - e = getenv("SYSTEMD_LOG_TARGET"); if (e && log_set_target_from_string(e) < 0) log_warning("Failed to parse log target '%s'. Ignoring.", e); @@ -1222,6 +1217,15 @@ void log_parse_environment(void) { log_warning("Failed to parse log tid '%s'. Ignoring.", e); } +void log_parse_environment(void) { + /* Do not call from library code. */ + + if (should_parse_proc_cmdline()) + (void) proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX); + + log_parse_environment_variables(); +} + LogTarget log_get_target(void) { return log_target; } diff --git a/src/basic/log.h b/src/basic/log.h index 7218b4bf7..1e2bec164 100644 --- a/src/basic/log.h +++ b/src/basic/log.h @@ -82,6 +82,7 @@ int log_open(void); void log_close(void); void log_forget_fds(void); +void log_parse_environment_variables(void); void log_parse_environment(void); int log_dispatch_internal( diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index e1e56cf92..1bcb4d168 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -1382,6 +1382,39 @@ static void print_yes_no_line(bool first, bool good, const char *name) { name); } +static int are_we_installed(void) { + int r; + + r = acquire_esp(/* privileged_mode= */ false, /* graceful= */ false, NULL, NULL, NULL, NULL); + if (r < 0) + return r; + + /* Tests whether systemd-boot is installed. It's not obvious what to use as check here: we could + * check EFI variables, we could check what binary /EFI/BOOT/BOOT*.EFI points to, or whether the + * loader entries directory exists. Here we opted to check whether /EFI/systemd/ is non-empty, which + * should be a suitable and very minimal check for a number of reasons: + * + * → The check is architecture independent (i.e. we check if any systemd-boot loader is installed, + * not a specific one.) + * + * → It doesn't assume we are the only boot loader (i.e doesn't check if we own the main + * /EFI/BOOT/BOOT*.EFI fallback binary. + * + * → It specifically checks for systemd-boot, not for other boot loaders (which a check for + * /boot/loader/entries would do). */ + + _cleanup_free_ char *p = path_join(arg_esp_path, "/EFI/systemd/"); + if (!p) + return log_oom(); + + log_debug("Checking whether %s contains any files…", p); + r = dir_is_empty(p); + if (r < 0 && r != -ENOENT) + return log_error_errno(r, "Failed to check whether %s contains any files: %m", p); + + return r == 0; +} + static int verb_status(int argc, char *argv[], void *userdata) { sd_id128_t esp_uuid = SD_ID128_NULL, xbootldr_uuid = SD_ID128_NULL; int r, k; @@ -1758,6 +1791,17 @@ static int verb_install(int argc, char *argv[], void *userdata) { if (r < 0) return r; + if (!install) { + /* If we are updating, don't do anything if sd-boot wasn't actually installed. */ + r = are_we_installed(); + if (r < 0) + return r; + if (r == 0) { + log_debug("Skipping update because sd-boot is not installed in the ESP."); + return 0; + } + } + r = acquire_xbootldr(/* unprivileged_mode= */ false, NULL); if (r < 0) return r; @@ -1880,41 +1924,19 @@ static int verb_remove(int argc, char *argv[], void *userdata) { } static int verb_is_installed(int argc, char *argv[], void *userdata) { - _cleanup_free_ char *p = NULL; int r; - r = acquire_esp(/* privileged_mode= */ false, /* graceful= */ false, NULL, NULL, NULL, NULL); + r = are_we_installed(); if (r < 0) return r; - /* Tests whether systemd-boot is installed. It's not obvious what to use as check here: we could - * check EFI variables, we could check what binary /EFI/BOOT/BOOT*.EFI points to, or whether the - * loader entries directory exists. Here we opted to check whether /EFI/systemd/ is non-empty, which - * should be a suitable and very minimal check for a number of reasons: - * - * → The check is architecture independent (i.e. we check if any systemd-boot loader is installed, not a - * specific one.) - * - * → It doesn't assume we are the only boot loader (i.e doesn't check if we own the main - * /EFI/BOOT/BOOT*.EFI fallback binary. - * - * → It specifically checks for systemd-boot, not for other boot loaders (which a check for - * /boot/loader/entries would do). */ - - p = path_join(arg_esp_path, "/EFI/systemd/"); - if (!p) - return log_oom(); - - r = dir_is_empty(p); - if (r > 0 || r == -ENOENT) { + if (r > 0) { + puts("yes"); + return EXIT_SUCCESS; + } else { puts("no"); return EXIT_FAILURE; } - if (r < 0) - return log_error_errno(r, "Failed to detect whether systemd-boot is installed: %m"); - - puts("yes"); - return EXIT_SUCCESS; } static int parse_timeout(const char *arg1, char16_t **ret_timeout, size_t *ret_timeout_size) { diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index e4d183125..0286914b8 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -1572,7 +1572,7 @@ static void config_load_entries( _cleanup_freepool_ CHAR8 *content = NULL; err = readdir_harder(entries_dir, &f, &f_size); - if (f_size == 0 || EFI_ERROR(err)) + if (EFI_ERROR(err) || !f) break; if (f->FileName[0] == '.') @@ -2007,7 +2007,7 @@ static void config_entry_add_linux( CHAR8 *key, *value; err = readdir_harder(linux_dir, &f, &f_size); - if (f_size == 0 || EFI_ERROR(err)) + if (EFI_ERROR(err) || !f) break; if (f->FileName[0] == '.') @@ -2341,7 +2341,7 @@ static void config_load_all_entries( } EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { - _cleanup_freepool_ EFI_LOADED_IMAGE *loaded_image = NULL; + EFI_LOADED_IMAGE *loaded_image; _cleanup_(FileHandleClosep) EFI_FILE *root_dir = NULL; _cleanup_(config_free) Config config = {}; CHAR16 *loaded_image_path; diff --git a/src/boot/efi/shim.c b/src/boot/efi/shim.c index 3ce6af42f..fd9c48947 100644 --- a/src/boot/efi/shim.c +++ b/src/boot/efi/shim.c @@ -118,13 +118,14 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT if (!dev_path) return EFI_OUT_OF_RESOURCES; - status = BS->LocateDevicePath(&FileSystemProtocol, &dev_path, &h); + EFI_DEVICE_PATH *dp = dev_path; + status = BS->LocateDevicePath(&FileSystemProtocol, &dp, &h); if (EFI_ERROR(status)) return status; /* No need to check return value, this already happened in efi_main() */ root = LibOpenRoot(h); - dev_path_str = DevicePathToStr(dev_path); + dev_path_str = DevicePathToStr(dp); if (!dev_path_str) return EFI_OUT_OF_RESOURCES; diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c index 76e4eef1e..71639721b 100644 --- a/src/boot/efi/util.c +++ b/src/boot/efi/util.c @@ -596,7 +596,12 @@ EFI_STATUS readdir_harder( * the specified buffer needs to be freed by caller, after final use. */ if (!*buffer) { - sz = offsetof(EFI_FILE_INFO, FileName) /* + 256 */; + /* Some broken firmware violates the EFI spec by still advancing the readdir + * position when returning EFI_BUFFER_TOO_SMALL, effectively skipping over any files when + * the buffer was too small. Therefore, start with a buffer that should handle FAT32 max + * file name length. + * As a side effect, most readdir_harder() calls will now be slightly faster. */ + sz = sizeof(EFI_FILE_INFO) + 256 * sizeof(CHAR16); *buffer = xallocate_pool(sz); *buffer_size = sz; } else diff --git a/src/boot/efi/xbootldr.c b/src/boot/efi/xbootldr.c index 81aa7f61e..4972877d2 100644 --- a/src/boot/efi/xbootldr.c +++ b/src/boot/efi/xbootldr.c @@ -286,7 +286,8 @@ EFI_STATUS xbootldr_open(EFI_HANDLE *device, EFI_HANDLE *ret_device, EFI_FILE ** hd->SignatureType = SIGNATURE_TYPE_GUID; } - err = BS->LocateDevicePath(&BlockIoProtocol, &partition_path, &new_device); + EFI_DEVICE_PATH *dp = partition_path; + err = BS->LocateDevicePath(&BlockIoProtocol, &dp, &new_device); if (EFI_ERROR(err)) return err; diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index f7a1210a3..1128c42ad 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -872,19 +872,21 @@ const sd_bus_vtable bus_unit_vtable[] = { SD_BUS_PROPERTY("Wants", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("BindsTo", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("PartOf", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("Upholds", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("RequiredBy", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("RequisiteOf", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("WantedBy", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("BoundBy", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("UpheldBy", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("ConsistsOf", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Conflicts", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("ConflictedBy", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Before", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("After", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("OnFailure", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("OnFailureOf", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("OnSuccess", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("OnSuccessOf", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("OnFailure", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("OnFailureOf", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Triggers", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("TriggeredBy", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("PropagatesReloadTo", "as", property_get_dependencies, 0, SD_BUS_VTABLE_PROPERTY_CONST), @@ -1312,11 +1314,15 @@ static int append_cgroup(sd_bus_message *reply, const char *p, Set *pids) { for (;;) { pid_t pid; + /* libvirt / qemu uses threaded mode and cgroup.procs cannot be read at the lower levels. + * From https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#threads, + * “cgroup.procs” in a threaded domain cgroup contains the PIDs of all processes in + * the subtree and is not readable in the subtree proper. */ r = cg_read_pid(f, &pid); + if (IN_SET(r, 0, -EOPNOTSUPP)) + break; if (r < 0) return r; - if (r == 0) - break; if (is_kernel_thread(pid) > 0) continue; diff --git a/src/core/org.freedesktop.systemd1.policy.in b/src/core/org.freedesktop.systemd1.policy.in index 74721c516..f34b2d5bf 100644 --- a/src/core/org.freedesktop.systemd1.policy.in +++ b/src/core/org.freedesktop.systemd1.policy.in @@ -16,7 +16,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Send passphrase back to system diff --git a/src/core/restrict-ifaces.c b/src/core/restrict-ifaces.c index 765003143..0132c3c87 100644 --- a/src/core/restrict-ifaces.c +++ b/src/core/restrict-ifaces.c @@ -19,9 +19,12 @@ static struct restrict_ifaces_bpf *restrict_ifaces_bpf_free(struct restrict_ifac DEFINE_TRIVIAL_CLEANUP_FUNC(struct restrict_ifaces_bpf *, restrict_ifaces_bpf_free); -static int prepare_restrict_ifaces_bpf(Unit* u, bool is_allow_list, +static int prepare_restrict_ifaces_bpf( + Unit* u, + bool is_allow_list, const Set *restrict_network_interfaces, struct restrict_ifaces_bpf **ret_object) { + _cleanup_(restrict_ifaces_bpf_freep) struct restrict_ifaces_bpf *obj = NULL; _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL; char *iface; @@ -50,9 +53,10 @@ static int prepare_restrict_ifaces_bpf(Unit* u, bool is_allow_list, SET_FOREACH(iface, restrict_network_interfaces) { uint8_t dummy = 0; int ifindex; + ifindex = rtnl_resolve_interface(&rtnl, iface); if (ifindex < 0) { - log_unit_warning_errno(u, ifindex, "Couldn't find index of network interface: %m. Ignoring '%s'", iface); + log_unit_warning_errno(u, ifindex, "Couldn't find index of network interface '%s', ignoring: %m", iface); continue; } diff --git a/src/home/org.freedesktop.home1.policy b/src/home/org.freedesktop.home1.policy index 10ad7c283..71253e04e 100644 --- a/src/home/org.freedesktop.home1.policy +++ b/src/home/org.freedesktop.home1.policy @@ -7,7 +7,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Create a home area diff --git a/src/hostname/org.freedesktop.hostname1.policy b/src/hostname/org.freedesktop.hostname1.policy index 7d28c395c..dacea0ff0 100644 --- a/src/hostname/org.freedesktop.hostname1.policy +++ b/src/hostname/org.freedesktop.hostname1.policy @@ -14,7 +14,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Set hostname diff --git a/src/import/org.freedesktop.import1.policy b/src/import/org.freedesktop.import1.policy index 9736816e3..e88a6e8ae 100644 --- a/src/import/org.freedesktop.import1.policy +++ b/src/import/org.freedesktop.import1.policy @@ -16,7 +16,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Import a VM or container image diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index d564d542d..3c4a7c0a7 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -552,8 +552,6 @@ static int parse_argv(int argc, char *argv[]) { arg_lines = 1000; arg_boot = true; - arg_boot_id = SD_ID128_NULL; - arg_boot_offset = 0; break; diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c index 11647504e..3afe66db8 100644 --- a/src/journal/test-journal.c +++ b/src/journal/test-journal.c @@ -76,17 +76,17 @@ static void test_non_empty(void) { assert_se(le64toh(o->entry.seqnum) == 1); assert_se(journal_file_find_data_object(f->file, test, strlen(test), NULL, &p) == 1); - assert_se(journal_file_next_entry_for_data(f->file, NULL, 0, p, DIRECTION_DOWN, &o, NULL) == 1); + assert_se(journal_file_next_entry_for_data(f->file, p, DIRECTION_DOWN, &o, NULL) == 1); assert_se(le64toh(o->entry.seqnum) == 1); - assert_se(journal_file_next_entry_for_data(f->file, NULL, 0, p, DIRECTION_UP, &o, NULL) == 1); + assert_se(journal_file_next_entry_for_data(f->file, p, DIRECTION_UP, &o, NULL) == 1); assert_se(le64toh(o->entry.seqnum) == 3); assert_se(journal_file_find_data_object(f->file, test2, strlen(test2), NULL, &p) == 1); - assert_se(journal_file_next_entry_for_data(f->file, NULL, 0, p, DIRECTION_UP, &o, NULL) == 1); + assert_se(journal_file_next_entry_for_data(f->file, p, DIRECTION_UP, &o, NULL) == 1); assert_se(le64toh(o->entry.seqnum) == 2); - assert_se(journal_file_next_entry_for_data(f->file, NULL, 0, p, DIRECTION_DOWN, &o, NULL) == 1); + assert_se(journal_file_next_entry_for_data(f->file, p, DIRECTION_DOWN, &o, NULL) == 1); assert_se(le64toh(o->entry.seqnum) == 2); assert_se(journal_file_find_data_object(f->file, "quux", 4, NULL, &p) == 0); diff --git a/src/kernel-install/50-depmod.install b/src/kernel-install/50-depmod.install index 2fd959865..fd00c4363 100644 --- a/src/kernel-install/50-depmod.install +++ b/src/kernel-install/50-depmod.install @@ -36,7 +36,7 @@ case "$COMMAND" in remove) [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ echo "Removing /lib/modules/${KERNEL_VERSION}/modules.dep and associated files" - exec rm -f /lib/modules/"${KERNEL_VERSION}"/modules.{alias{,.bin},builtin.bin,dep{,.bin},devname,softdep,symbols{,.bin}} + exec rm -f /lib/modules/"${KERNEL_VERSION}"/modules.{alias{,.bin},builtin{,.alias}.bin,dep{,.bin},devname,softdep,symbols{,.bin}} ;; *) exit 0 diff --git a/src/libsystemd-network/dhcp6-internal.h b/src/libsystemd-network/dhcp6-internal.h index 31482d771..f94340985 100644 --- a/src/libsystemd-network/dhcp6-internal.h +++ b/src/libsystemd-network/dhcp6-internal.h @@ -11,6 +11,7 @@ #include "sd-event.h" #include "sd-dhcp6-client.h" +#include "dhcp6-protocol.h" #include "hashmap.h" #include "list.h" #include "macro.h" @@ -130,6 +131,12 @@ int dhcp6_network_bind_udp_socket(int ifindex, struct in6_addr *address); int dhcp6_network_send_udp_socket(int s, struct in6_addr *address, const void *packet, size_t len); +int client_parse_message( + sd_dhcp6_client *client, + DHCP6Message *message, + size_t len, + sd_dhcp6_lease *lease); + const char *dhcp6_message_type_to_string(int s) _const_; int dhcp6_message_type_from_string(const char *s) _pure_; const char *dhcp6_message_status_to_string(int s) _const_; diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index d3c667974..706904c72 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -1124,7 +1124,7 @@ static int client_ensure_iaid(sd_dhcp6_client *client) { return 0; } -static int client_parse_message( +int client_parse_message( sd_dhcp6_client *client, DHCP6Message *message, size_t len, @@ -1261,35 +1261,35 @@ static int client_parse_message( case SD_DHCP6_OPTION_DNS_SERVERS: r = dhcp6_lease_add_dns(lease, optval, optlen); if (r < 0) - return r; + log_dhcp6_client_errno(client, r, "Failed to parse DNS server option, ignoring: %m"); break; case SD_DHCP6_OPTION_DOMAIN_LIST: r = dhcp6_lease_add_domains(lease, optval, optlen); if (r < 0) - return r; + log_dhcp6_client_errno(client, r, "Failed to parse domain list option, ignoring: %m"); break; case SD_DHCP6_OPTION_NTP_SERVER: r = dhcp6_lease_add_ntp(lease, optval, optlen); if (r < 0) - return r; + log_dhcp6_client_errno(client, r, "Failed to parse NTP server option, ignoring: %m"); break; case SD_DHCP6_OPTION_SNTP_SERVERS: r = dhcp6_lease_add_sntp(lease, optval, optlen); if (r < 0) - return r; + log_dhcp6_client_errno(client, r, "Failed to parse SNTP server option, ignoring: %m"); break; case SD_DHCP6_OPTION_CLIENT_FQDN: r = dhcp6_lease_set_fqdn(lease, optval, optlen); if (r < 0) - return r; + log_dhcp6_client_errno(client, r, "Failed to parse FQDN option, ignoring: %m"); break; diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c index 055b0c9de..bcd0134a8 100644 --- a/src/libsystemd-network/test-dhcp6-client.c +++ b/src/libsystemd-network/test-dhcp6-client.c @@ -37,7 +37,7 @@ static int test_client_message_num; static be32_t test_iaid = 0; static uint8_t test_duid[14] = { }; -static int test_client_basic(sd_event *e) { +static void test_client_basic(sd_event *e) { sd_dhcp6_client *client; int v; @@ -108,11 +108,9 @@ static int test_client_basic(sd_event *e) { assert_se(sd_dhcp6_client_detach_event(client) >= 0); assert_se(!sd_dhcp6_client_unref(client)); - - return 0; } -static int test_parse_domain(sd_event *e) { +static void test_parse_domain(void) { uint8_t *data; char *domain; char **list; @@ -154,11 +152,9 @@ static int test_parse_domain(sd_event *e) { data = (uint8_t []) { 0 , 0 }; r = dhcp6_option_parse_domainname_list(data, 2, &list); assert_se(r < 0); - - return 0; } -static int test_option(sd_event *e) { +static void test_option(void) { uint8_t packet[] = { 'F', 'O', 'O', 'H', 'O', 'G', 'E', 0x00, SD_DHCP6_OPTION_ORO, 0x00, 0x07, @@ -232,11 +228,9 @@ static int test_option(sd_event *e) { assert_se(*out == 'B'); assert_se(memcmp(packet, result, sizeof(packet)) == 0); - - return 0; } -static int test_option_status(sd_event *e) { +static void test_option_status(void) { uint8_t option1[] = { /* IA NA */ 0x00, 0x03, 0x00, 0x12, 0x1a, 0x1d, 0x1a, 0x1d, @@ -370,8 +364,56 @@ static int test_option_status(sd_event *e) { assert_se(r >= 0); assert_se(pd.addresses); dhcp6_lease_free_ia(&pd); +} - return 0; +static void test_client_parse_message_issue_22099(void) { + static const uint8_t msg[] = { + /* xid */ + 0x07, 0x7c, 0x4c, 0x16, + /* status code (zero length) */ + 0x00, 0x0e, 0x00, 0x00, + /* NTP servers (broken sub option and sub option length) */ + 0x00, 0x38, 0x00, 0x14, 0x01, 0x00, 0x10, 0x00, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xde, 0x15, 0xc8, 0xff, 0xfe, 0xef, 0x1e, 0x4e, + /* client ID */ + 0x00, 0x01, 0x00, 0x0e, 0x00, 0x02, 0x00, 0x00, 0xab, 0x11, 0x5c, 0x6b, 0x90, 0xec, 0xda, 0x95, + 0x15, 0x45, + /* server ID */ + 0x00, 0x02, 0x00, 0x0a, 0x00, 0x03, 0x00, 0x01, 0xdc, 0x15, 0xc8, 0xef, 0x1e, 0x4e, + /* preference */ + 0x00, 0x07, 0x00, 0x01, 0x00, + /* DNS servers */ + 0x00, 0x17, 0x00, 0x10, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0x15, 0xc8, 0xff, + 0xfe, 0xef, 0x1e, 0x4e, + /* v6 pcp server */ + 0x00, 0x56, 0x00, 0x10, 0x2a, 0x02, 0x81, 0x0d, 0x98, 0x80, 0x37, 0x00, 0xde, 0x15, 0xc8, 0xff, + 0xfe, 0xef, 0x1e, 0x4e, + /* IA_NA */ + 0x00, 0x03, 0x00, 0x28, 0xcc, 0x59, 0x11, 0x7b, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x0b, 0x40, + /* IA_NA (iaaddr) */ + 0x00, 0x05, 0x00, 0x18, 0x2a, 0x02, 0x81, 0x0d, 0x98, 0x80, 0x37, 0x00, 0x6a, 0x05, 0xca, 0xff, + 0xfe, 0xf1, 0x51, 0x53, 0x00, 0x00, 0x0e, 0x10, 0x00, 0x00, 0x1c, 0x20, + /* IA_PD */ + 0x00, 0x19, 0x00, 0x29, 0xcc, 0x59, 0x11, 0x7b, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x0b, 0x40, + /* IA_PD (iaprefix) */ + 0x00, 0x1a, 0x00, 0x19, 0x00, 0x00, 0x0e, 0x10, 0x00, 0x00, 0x1c, 0x20, 0x3a, 0x2a, 0x02, 0x81, + 0x0d, 0x98, 0x80, 0x37, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t duid[] = { + 0x00, 0x00, 0xab, 0x11, 0x5c, 0x6b, 0x90, 0xec, 0xda, 0x95, 0x15, 0x45, + }; + _cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL; + _cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL; + + log_debug("/* %s */", __func__); + + assert_se(sd_dhcp6_client_new(&client) >= 0); + assert_se(sd_dhcp6_client_set_iaid(client, 0xcc59117b) >= 0); + assert_se(sd_dhcp6_client_set_duid(client, 2, duid, sizeof(duid)) >= 0); + + assert_se(dhcp6_lease_new(&lease) >= 0); + + assert_se(client_parse_message(client, (DHCP6Message*) msg, sizeof(msg), lease) >= 0); } static uint8_t msg_advertise[198] = { @@ -434,7 +476,7 @@ static uint8_t fqdn_wire[16] = { 0x05, 'i', 'n', 't', 'r', 'a', 0x00 }; -static int test_advertise_option(sd_event *e) { +static void test_advertise_option(sd_event *e) { _cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL; DHCP6Message *advertise = (DHCP6Message *)msg_advertise; size_t len = sizeof(msg_advertise) - sizeof(DHCP6Message), pos = 0; @@ -455,8 +497,7 @@ static int test_advertise_option(sd_event *e) { assert_se(dhcp6_lease_new(&lease) >= 0); assert_se(advertise->type == DHCP6_MESSAGE_ADVERTISE); - assert_se((be32toh(advertise->transaction_id) & 0x00ffffff) == - 0x0fb4e5); + assert_se((be32toh(advertise->transaction_id) & 0x00ffffff) == 0x0fb4e5); while (pos < len) { DHCP6Option *option = (DHCP6Option *)&advertise->options[pos]; @@ -495,16 +536,14 @@ static int test_advertise_option(sd_event *e) { assert_se(optval == &msg_advertise[179]); assert_se(!memcmp(optval, &msg_advertise[179], optlen)); - assert_se(dhcp6_lease_set_serverid(lease, optval, - optlen) >= 0); + assert_se(dhcp6_lease_set_serverid(lease, optval, optlen) >= 0); break; case SD_DHCP6_OPTION_PREFERENCE: assert_se(optlen == 1); assert_se(!*optval); - assert_se(dhcp6_lease_set_preference(lease, - *optval) >= 0); + assert_se(dhcp6_lease_set_preference(lease, *optval) >= 0); break; case SD_DHCP6_OPTION_ELAPSED_TIME: @@ -538,26 +577,20 @@ static int test_advertise_option(sd_event *e) { assert_se(opt_clientid); sd_dhcp6_lease_reset_address_iter(lease); - assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, - <_valid) >= 0); + assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) >= 0); assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr))); assert_se(lt_pref == 150); assert_se(lt_valid == 180); - assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, - <_valid) == -ENOMSG); + assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG); sd_dhcp6_lease_reset_address_iter(lease); - assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, - <_valid) >= 0); + assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) >= 0); assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr))); - assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, - <_valid) == -ENOMSG); + assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG); sd_dhcp6_lease_reset_address_iter(lease); - assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, - <_valid) >= 0); + assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) >= 0); assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr))); - assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, - <_valid) == -ENOMSG); + assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG); assert_se(dhcp6_lease_get_serverid(lease, &opt, &len) >= 0); assert_se(len == 14); @@ -578,8 +611,6 @@ static int test_advertise_option(sd_event *e) { r = sd_dhcp6_lease_get_ntp_addrs(lease, &addrs); assert_se(r == 1); assert_se(!memcmp(addrs, &msg_advertise[159], r * 16)); - - return 0; } static int test_check_completed_in_2_seconds(sd_event_source *s, uint64_t usec, void *userdata) { @@ -615,7 +646,7 @@ static void test_client_solicit_cb(sd_dhcp6_client *client, int event, sd_event_exit(e, 0); } -static int test_client_send_reply(DHCP6Message *request) { +static void test_client_send_reply(DHCP6Message *request) { DHCP6Message reply; log_debug("/* %s */", __func__); @@ -629,13 +660,10 @@ static int test_client_send_reply(DHCP6Message *request) { memcpy(&msg_reply[44], &test_iaid, sizeof(test_iaid)); - assert_se(write(test_dhcp_fd[1], msg_reply, sizeof(msg_reply)) - == sizeof(msg_reply)); - - return 0; + assert_se(write(test_dhcp_fd[1], msg_reply, sizeof(msg_reply)) == sizeof(msg_reply)); } -static int test_client_verify_request(DHCP6Message *request, size_t len) { +static void test_client_verify_request(DHCP6Message *request, size_t len) { _cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL; bool found_clientid = false, found_iana = false, found_serverid = false, found_elapsed_time = false, found_fqdn = false; @@ -714,16 +742,13 @@ static int test_client_verify_request(DHCP6Message *request, size_t len) { pos += sizeof(*option) + optlen; } - assert_se(found_clientid && found_iana && found_serverid && - found_elapsed_time); + assert_se(found_clientid && found_iana && found_serverid && found_elapsed_time); sd_dhcp6_lease_reset_address_iter(lease); assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG); - - return 0; } -static int test_client_send_advertise(DHCP6Message *solicit) { +static void test_client_send_advertise(DHCP6Message *solicit) { DHCP6Message advertise; log_debug("/* %s */", __func__); @@ -737,13 +762,10 @@ static int test_client_send_advertise(DHCP6Message *solicit) { memcpy(&msg_advertise[26], &test_iaid, sizeof(test_iaid)); - assert_se(write(test_dhcp_fd[1], msg_advertise, sizeof(msg_advertise)) - == sizeof(msg_advertise)); - - return 0; + assert_se(write(test_dhcp_fd[1], msg_advertise, sizeof(msg_advertise)) == sizeof(msg_advertise)); } -static int test_client_verify_solicit(DHCP6Message *solicit, size_t len) { +static void test_client_verify_solicit(DHCP6Message *solicit, size_t len) { bool found_clientid = false, found_iana = false, found_elapsed_time = false, found_fqdn = false; size_t pos = 0; @@ -805,12 +827,9 @@ static int test_client_verify_solicit(DHCP6Message *solicit, size_t len) { assert_se(pos == len); assert_se(found_clientid && found_iana && found_elapsed_time); - - return 0; } -static void test_client_information_cb(sd_dhcp6_client *client, int event, - void *userdata) { +static void test_client_information_cb(sd_dhcp6_client *client, int event, void *userdata) { sd_event *e = userdata; sd_dhcp6_lease *lease; const struct in6_addr *addrs; @@ -843,18 +862,14 @@ static void test_client_information_cb(sd_dhcp6_client *client, int event, assert_se(sd_dhcp6_client_stop(client) >= 0); assert_se(sd_dhcp6_client_set_information_request(client, false) >= 0); - assert_se(sd_dhcp6_client_set_callback(client, - test_client_solicit_cb, e) >= 0); + assert_se(sd_dhcp6_client_set_callback(client, test_client_solicit_cb, e) >= 0); assert_se(sd_dhcp6_client_set_local_address(client, &address) >= 0); assert_se(sd_dhcp6_client_start(client) >= 0); - } -static int test_client_verify_information_request(DHCP6Message *information_request, - size_t len) { - +static void test_client_verify_information_request(DHCP6Message *information_request, size_t len) { _cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL; size_t pos = 0; bool found_clientid = false, found_elapsed_time = false; @@ -905,16 +920,12 @@ static int test_client_verify_information_request(DHCP6Message *information_requ sd_dhcp6_lease_reset_address_iter(lease); - assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, - <_valid) == -ENOMSG); - - return 0; + assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) == -ENOMSG); } int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address, const void *packet, size_t len) { - struct in6_addr mcast = - IN6ADDR_ALL_DHCP6_RELAY_AGENTS_AND_SERVERS_INIT; + struct in6_addr mcast = IN6ADDR_ALL_DHCP6_RELAY_AGENTS_AND_SERVERS_INIT; DHCP6Message *message; log_debug("/* %s */", __func__); @@ -955,7 +966,7 @@ int dhcp6_network_bind_udp_socket(int ifindex, struct in6_addr *local_address) { return test_dhcp_fd[0]; } -static int test_client_solicit(sd_event *e) { +static void test_client_solicit(sd_event *e) { sd_dhcp6_client *client; struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } }; int val; @@ -998,8 +1009,6 @@ static int test_client_solicit(sd_event *e) { assert_se(!sd_dhcp6_client_unref(client)); test_dhcp_fd[1] = safe_close(test_dhcp_fd[1]); - - return 0; } int main(int argc, char *argv[]) { @@ -1010,11 +1019,12 @@ int main(int argc, char *argv[]) { test_setup_logging(LOG_DEBUG); test_client_basic(e); - test_option(e); - test_option_status(e); + test_parse_domain(); + test_option(); + test_option_status(); + test_client_parse_message_issue_22099(); test_advertise_option(e); test_client_solicit(e); - test_parse_domain(e); return 0; } diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 94ea61cc8..b163a0fb6 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1392,7 +1392,7 @@ int device_read_db_internal_filename(sd_device *device, const char *filename) { _cleanup_free_ char *db = NULL; const char *value; size_t db_len; - char key; + char key = '\0'; /* Unnecessary initialization to appease gcc-12.0.0-0.4.fc36 */ int r; enum { diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 505e4f728..ef4c26109 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -2099,14 +2099,35 @@ static void chain_cache_put( ci->last_index = last_index; } +static int bump_array_index(uint64_t *i, direction_t direction, uint64_t n) { + assert(i); + + /* Increase or decrease the specified index, in the right direction. */ + + if (direction == DIRECTION_DOWN) { + if (*i >= n - 1) + return 0; + + (*i)++; + } else { + if (*i <= 0) + return 0; + + (*i)--; + } + + return 1; +} + static int generic_array_get( JournalFile *f, uint64_t first, uint64_t i, + direction_t direction, Object **ret, uint64_t *ret_offset) { - Object *o; - uint64_t p = 0, a, t = 0; + Object *o, *e; + uint64_t p = 0, a, t = 0, k; int r; ChainCacheItem *ci; @@ -2123,35 +2144,64 @@ static int generic_array_get( } while (a > 0) { - uint64_t k; - r = journal_file_move_to_object(f, OBJECT_ENTRY_ARRAY, a, &o); if (r < 0) return r; k = journal_file_entry_array_n_items(o); - if (i < k) { - p = le64toh(o->entry_array.items[i]); - goto found; - } + if (i < k) + break; i -= k; t += k; a = le64toh(o->entry_array.next_entry_array_offset); } + /* If we've found the right location, now look for the first non-corrupt entry object (in the right + * direction). */ + + while (a > 0) { + /* In the first iteration of the while loop, we reuse i, k and o from the previous while + * loop. */ + if (i == UINT64_MAX) { + r = journal_file_move_to_object(f, OBJECT_ENTRY_ARRAY, a, &o); + if (r < 0) + return r; + + k = journal_file_entry_array_n_items(o); + if (k == 0) + break; + + i = direction == DIRECTION_DOWN ? 0 : k - 1; + } + + do { + p = le64toh(o->entry_array.items[i]); + + r = journal_file_move_to_object(f, OBJECT_ENTRY, p, &e); + if (r >= 0) + goto found; + if (!IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) + return r; + + /* OK, so this entry is borked. Most likely some entry didn't get synced to + * disk properly, let's see if the next one might work for us instead. */ + log_debug_errno(r, "Entry item %" PRIu64 " is bad, skipping over it.", i); + } while (bump_array_index(&i, direction, k) > 0); + + t += k; + a = le64toh(o->entry_array.next_entry_array_offset); + i = UINT64_MAX; + } + return 0; found: /* Let's cache this item for the next invocation */ chain_cache_put(f->chain_cache, ci, first, a, le64toh(o->entry_array.items[0]), t, i); - r = journal_file_move_to_object(f, OBJECT_ENTRY, p, &o); - if (r < 0) - return r; - if (ret) - *ret = o; + *ret = e; if (ret_offset) *ret_offset = p; @@ -2164,16 +2214,18 @@ static int generic_array_get_plus_one( uint64_t extra, uint64_t first, uint64_t i, + direction_t direction, Object **ret, uint64_t *ret_offset) { Object *o; + int r; assert(f); if (i == 0) { - int r; - r = journal_file_move_to_object(f, OBJECT_ENTRY, extra, &o); + if (IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) + return generic_array_get(f, first, 0, direction, ret, ret_offset); if (r < 0) return r; @@ -2186,7 +2238,7 @@ static int generic_array_get_plus_one( return 1; } - return generic_array_get(f, first, i-1, ret, ret_offset); + return generic_array_get(f, first, i - 1, direction, ret, ret_offset); } enum { @@ -2710,25 +2762,6 @@ int journal_file_compare_locations(JournalFile *af, JournalFile *bf) { return CMP(af->current_xor_hash, bf->current_xor_hash); } -static int bump_array_index(uint64_t *i, direction_t direction, uint64_t n) { - - /* Increase or decrease the specified index, in the right direction. */ - - if (direction == DIRECTION_DOWN) { - if (*i >= n - 1) - return 0; - - (*i) ++; - } else { - if (*i <= 0) - return 0; - - (*i) --; - } - - return 1; -} - static bool check_properly_ordered(uint64_t new_offset, uint64_t old_offset, direction_t direction) { /* Consider it an error if any of the two offsets is uninitialized */ @@ -2777,24 +2810,9 @@ int journal_file_next_entry( } /* And jump to it */ - for (;;) { - r = generic_array_get(f, - le64toh(f->header->entry_array_offset), - i, - ret, &ofs); - if (r > 0) - break; - if (r != -EBADMSG) - return r; - - /* OK, so this entry is borked. Most likely some entry didn't get synced to disk properly, let's see if - * the next one might work for us instead. */ - log_debug_errno(r, "Entry item %" PRIu64 " is bad, skipping over it.", i); - - r = bump_array_index(&i, direction, n); - if (r <= 0) - return r; - } + r = generic_array_get(f, le64toh(f->header->entry_array_offset), i, direction, ret, &ofs); + if (r <= 0) + return r; /* Ensure our array is properly ordered. */ if (p > 0 && !check_properly_ordered(ofs, p, direction)) @@ -2810,7 +2828,6 @@ int journal_file_next_entry( int journal_file_next_entry_for_data( JournalFile *f, - Object *o, uint64_t p, uint64_t data_offset, direction_t direction, Object **ret, uint64_t *ret_offset) { @@ -2820,7 +2837,6 @@ int journal_file_next_entry_for_data( int r; assert(f); - assert(p > 0 || !o); r = journal_file_move_to_object(f, OBJECT_DATA, data_offset, &d); if (r < 0) @@ -2830,53 +2846,16 @@ int journal_file_next_entry_for_data( if (n <= 0) return n; - if (!o) - i = direction == DIRECTION_DOWN ? 0 : n - 1; - else { - if (o->object.type != OBJECT_ENTRY) - return -EINVAL; + i = direction == DIRECTION_DOWN ? 0 : n - 1; - r = generic_array_bisect_plus_one(f, - le64toh(d->data.entry_offset), - le64toh(d->data.entry_array_offset), - le64toh(d->data.n_entries), - p, - test_object_offset, - DIRECTION_DOWN, - NULL, NULL, - &i); - - if (r <= 0) - return r; - - r = bump_array_index(&i, direction, n); - if (r <= 0) - return r; - } - - for (;;) { - r = generic_array_get_plus_one(f, - le64toh(d->data.entry_offset), - le64toh(d->data.entry_array_offset), - i, - ret, &ofs); - if (r > 0) - break; - if (r != -EBADMSG) - return r; - - log_debug_errno(r, "Data entry item %" PRIu64 " is bad, skipping over it.", i); - - r = bump_array_index(&i, direction, n); - if (r <= 0) - return r; - } - - /* Ensure our array is properly ordered. */ - if (p > 0 && check_properly_ordered(ofs, p, direction)) - return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), - "%s data entry array not properly ordered at entry %" PRIu64, - f->path, i); + r = generic_array_get_plus_one(f, + le64toh(d->data.entry_offset), + le64toh(d->data.entry_array_offset), + i, + direction, + ret, &ofs); + if (r <= 0) + return r; if (ret_offset) *ret_offset = ofs; @@ -3819,7 +3798,8 @@ int journal_file_get_cutoff_monotonic_usec(JournalFile *f, sd_id128_t boot_id, u r = generic_array_get_plus_one(f, le64toh(o->data.entry_offset), le64toh(o->data.entry_array_offset), - le64toh(o->data.n_entries)-1, + le64toh(o->data.n_entries) - 1, + DIRECTION_UP, &o, NULL); if (r <= 0) return r; diff --git a/src/libsystemd/sd-journal/journal-file.h b/src/libsystemd/sd-journal/journal-file.h index b90e3a608..39e91d71c 100644 --- a/src/libsystemd/sd-journal/journal-file.h +++ b/src/libsystemd/sd-journal/journal-file.h @@ -214,7 +214,7 @@ void journal_file_save_location(JournalFile *f, Object *o, uint64_t offset); int journal_file_compare_locations(JournalFile *af, JournalFile *bf); int journal_file_next_entry(JournalFile *f, uint64_t p, direction_t direction, Object **ret, uint64_t *offset); -int journal_file_next_entry_for_data(JournalFile *f, Object *o, uint64_t p, uint64_t data_offset, direction_t direction, Object **ret, uint64_t *offset); +int journal_file_next_entry_for_data(JournalFile *f, uint64_t data_offset, direction_t direction, Object **ret, uint64_t *offset); int journal_file_move_to_entry_by_seqnum(JournalFile *f, uint64_t seqnum, direction_t direction, Object **ret, uint64_t *offset); int journal_file_move_to_entry_by_realtime(JournalFile *f, uint64_t realtime, direction_t direction, Object **ret, uint64_t *offset); diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c index f51ecbfc5..7a6cc4aca 100644 --- a/src/libsystemd/sd-journal/sd-journal.c +++ b/src/libsystemd/sd-journal/sd-journal.c @@ -611,9 +611,9 @@ static int find_location_for_match( /* FIXME: missing: find by monotonic */ if (j->current_location.type == LOCATION_HEAD) - return journal_file_next_entry_for_data(f, NULL, 0, dp, DIRECTION_DOWN, ret, offset); + return journal_file_next_entry_for_data(f, dp, DIRECTION_DOWN, ret, offset); if (j->current_location.type == LOCATION_TAIL) - return journal_file_next_entry_for_data(f, NULL, 0, dp, DIRECTION_UP, ret, offset); + return journal_file_next_entry_for_data(f, dp, DIRECTION_UP, ret, offset); if (j->current_location.seqnum_set && sd_id128_equal(j->current_location.seqnum_id, f->header->seqnum_id)) return journal_file_move_to_entry_by_seqnum_for_data(f, dp, j->current_location.seqnum, direction, ret, offset); if (j->current_location.monotonic_set) { @@ -624,7 +624,7 @@ static int find_location_for_match( if (j->current_location.realtime_set) return journal_file_move_to_entry_by_realtime_for_data(f, dp, j->current_location.realtime, direction, ret, offset); - return journal_file_next_entry_for_data(f, NULL, 0, dp, direction, ret, offset); + return journal_file_next_entry_for_data(f, dp, direction, ret, offset); } else if (m->type == MATCH_OR_TERM) { uint64_t np = 0; @@ -2303,8 +2303,8 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void ** p = le64toh(o->entry.items[i].object_offset); le_hash = o->entry.items[i].hash; r = journal_file_move_to_object(f, OBJECT_DATA, p, &d); - if (r == -EBADMSG) { - log_debug("Entry item %"PRIu64" data object is bad, skipping over it.", i); + if (IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) { + log_debug_errno(r, "Entry item %"PRIu64" data object is bad, skipping over it: %m", i); continue; } if (r < 0) @@ -2448,8 +2448,8 @@ _public_ int sd_journal_enumerate_data(sd_journal *j, const void **data, size_t p = le64toh(o->entry.items[j->current_field].object_offset); le_hash = o->entry.items[j->current_field].hash; r = journal_file_move_to_object(f, OBJECT_DATA, p, &o); - if (r == -EBADMSG) { - log_debug("Entry item %"PRIu64" data object is bad, skipping over it.", j->current_field); + if (IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) { + log_debug_errno(r, "Entry item %"PRIu64" data object is bad, skipping over it: %m", j->current_field); continue; } if (r < 0) diff --git a/src/locale/org.freedesktop.locale1.policy b/src/locale/org.freedesktop.locale1.policy index f12ca0970..ed98c4aa0 100644 --- a/src/locale/org.freedesktop.locale1.policy +++ b/src/locale/org.freedesktop.locale1.policy @@ -16,7 +16,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Set system locale diff --git a/src/login/org.freedesktop.login1.policy b/src/login/org.freedesktop.login1.policy index 80ebb39f3..df906b0e7 100644 --- a/src/login/org.freedesktop.login1.policy +++ b/src/login/org.freedesktop.login1.policy @@ -16,7 +16,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Allow applications to inhibit system shutdown diff --git a/src/machine/org.freedesktop.machine1.policy b/src/machine/org.freedesktop.machine1.policy index ddf5ec05c..5e43cb6e2 100644 --- a/src/machine/org.freedesktop.machine1.policy +++ b/src/machine/org.freedesktop.machine1.policy @@ -16,7 +16,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Log into a local container diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c index af91dc625..88f668753 100644 --- a/src/network/netdev/wireguard.c +++ b/src/network/netdev/wireguard.c @@ -895,13 +895,8 @@ int config_parse_wireguard_route_table( assert(data); assert(userdata); - if (isempty(rvalue)) { - *table = RT_TABLE_MAIN; - return 0; - } - - if (streq(rvalue, "off")) { - *table = 0; + if (isempty(rvalue) || parse_boolean(rvalue) == 0) { + *table = 0; /* Disabled. */ return 0; } @@ -952,7 +947,7 @@ int config_parse_wireguard_peer_route_table( return 0; } - if (streq(rvalue, "off")) { + if (parse_boolean(rvalue) == 0) { peer->route_table = 0; /* Disabled. */ peer->route_table_set = true; TAKE_PTR(peer); @@ -1061,7 +1056,6 @@ static void wireguard_init(NetDev *netdev) { assert(w); w->flags = WGDEVICE_F_REPLACE_PEERS; - w->route_table = RT_TABLE_MAIN; } static void wireguard_done(NetDev *netdev) { diff --git a/src/network/org.freedesktop.network1.policy b/src/network/org.freedesktop.network1.policy index 9e27f728b..c39f20655 100644 --- a/src/network/org.freedesktop.network1.policy +++ b/src/network/org.freedesktop.network1.policy @@ -16,7 +16,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Set NTP servers diff --git a/src/nss-mymachines/nss-mymachines.c b/src/nss-mymachines/nss-mymachines.c index 44715bb3e..c64e79bdf 100644 --- a/src/nss-mymachines/nss-mymachines.c +++ b/src/nss-mymachines/nss-mymachines.c @@ -22,14 +22,9 @@ #include "signal-util.h" #include "string-util.h" -static void setup_logging(void) { - /* We need a dummy function because log_parse_environment is a macro. */ - log_parse_environment(); -} - static void setup_logging_once(void) { static pthread_once_t once = PTHREAD_ONCE_INIT; - assert_se(pthread_once(&once, setup_logging) == 0); + assert_se(pthread_once(&once, log_parse_environment_variables) == 0); } #define NSS_ENTRYPOINT_BEGIN \ diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c index 6b0c762d0..e857d42db 100644 --- a/src/nss-resolve/nss-resolve.c +++ b/src/nss-resolve/nss-resolve.c @@ -22,7 +22,7 @@ static JsonDispatchFlags json_dispatch_flags = 0; static void setup_logging(void) { - log_parse_environment(); + log_parse_environment_variables(); if (DEBUG_LOGGING) json_dispatch_flags = JSON_LOG; diff --git a/src/nss-systemd/nss-systemd.c b/src/nss-systemd/nss-systemd.c index 36486b96e..e87f1d31b 100644 --- a/src/nss-systemd/nss-systemd.c +++ b/src/nss-systemd/nss-systemd.c @@ -116,14 +116,9 @@ static GetentData getsgent_data = { .mutex = PTHREAD_MUTEX_INITIALIZER, }; -static void setup_logging(void) { - /* We need a dummy function because log_parse_environment is a macro. */ - log_parse_environment(); -} - static void setup_logging_once(void) { static pthread_once_t once = PTHREAD_ONCE_INIT; - assert_se(pthread_once(&once, setup_logging) == 0); + assert_se(pthread_once(&once, log_parse_environment_variables) == 0); } #define NSS_ENTRYPOINT_BEGIN \ diff --git a/src/portable/org.freedesktop.portable1.policy b/src/portable/org.freedesktop.portable1.policy index 17e22b015..09f9028dc 100644 --- a/src/portable/org.freedesktop.portable1.policy +++ b/src/portable/org.freedesktop.portable1.policy @@ -7,7 +7,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Inspect a portable service image diff --git a/src/resolve/org.freedesktop.resolve1.policy b/src/resolve/org.freedesktop.resolve1.policy index 08615ec6a..2408bb9e3 100644 --- a/src/resolve/org.freedesktop.resolve1.policy +++ b/src/resolve/org.freedesktop.resolve1.policy @@ -16,7 +16,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Register a DNS-SD service diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c index 40bc2bff0..48dd4d800 100644 --- a/src/shared/cgroup-show.c +++ b/src/shared/cgroup-show.c @@ -89,7 +89,6 @@ static int show_cgroup_one_by_path( _cleanup_fclose_ FILE *f = NULL; _cleanup_free_ char *p = NULL; size_t n = 0; - pid_t pid; char *fn; int r; @@ -102,7 +101,18 @@ static int show_cgroup_one_by_path( if (!f) return -errno; - while ((r = cg_read_pid(f, &pid)) > 0) { + for (;;) { + pid_t pid; + + /* libvirt / qemu uses threaded mode and cgroup.procs cannot be read at the lower levels. + * From https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#threads, + * “cgroup.procs” in a threaded domain cgroup contains the PIDs of all processes in + * the subtree and is not readable in the subtree proper. */ + r = cg_read_pid(f, &pid); + if (IN_SET(r, 0, -EOPNOTSUPP)) + break; + if (r < 0) + return r; if (!(flags & OUTPUT_KERNEL_THREADS) && is_kernel_thread(pid) > 0) continue; @@ -113,9 +123,6 @@ static int show_cgroup_one_by_path( pids[n++] = pid; } - if (r < 0) - return r; - show_pid_array(pids, n, prefix, n_columns, false, more, flags); return 0; diff --git a/src/stdio-bridge/stdio-bridge.c b/src/stdio-bridge/stdio-bridge.c index b45f7912c..1a2099a8d 100644 --- a/src/stdio-bridge/stdio-bridge.c +++ b/src/stdio-bridge/stdio-bridge.c @@ -28,7 +28,7 @@ static bool arg_user = false; static int help(void) { printf("%s [OPTIONS...]\n\n" - "STDIO or socket-activatable proxy to a given DBus endpoint.\n\n" + "Forward messages between two D-Bus busses via a pipe or socket.\n\n" " -h --help Show this help\n" " --version Show package version\n" " -p --bus-path=PATH Path to the bus address (default: %s)\n" @@ -125,7 +125,7 @@ static int run(int argc, char *argv[]) { in_fd = SD_LISTEN_FDS_START; out_fd = SD_LISTEN_FDS_START; } else - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Illegal number of file descriptors passed."); + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "More than one file descriptor was passed."); is_unix = sd_is_socket(in_fd, AF_UNIX, 0, 0) > 0 && diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c index 57cd03e4e..071b39136 100644 --- a/src/test/test-string-util.c +++ b/src/test/test-string-util.c @@ -166,33 +166,33 @@ TEST(cellescape) { assert_se(streq(cellescape(buf, 1, "\020"), "")); assert_se(streq(cellescape(buf, 2, "\020"), ".")); assert_se(streq(cellescape(buf, 3, "\020"), "..")); - assert_se(streq(cellescape(buf, 4, "\020"), "…")); + assert_se(streq(cellescape(buf, 4, "\020"), is_locale_utf8() ? "…" : "...")); assert_se(streq(cellescape(buf, 5, "\020"), "\\020")); - assert_se(streq(cellescape(buf, 5, "1234\020"), "1…")); - assert_se(streq(cellescape(buf, 6, "1234\020"), "12…")); - assert_se(streq(cellescape(buf, 7, "1234\020"), "123…")); - assert_se(streq(cellescape(buf, 8, "1234\020"), "1234…")); + assert_se(streq(cellescape(buf, 5, "1234\020"), is_locale_utf8() ? "1…" : "1...")); + assert_se(streq(cellescape(buf, 6, "1234\020"), is_locale_utf8() ? "12…" : "12...")); + assert_se(streq(cellescape(buf, 7, "1234\020"), is_locale_utf8() ? "123…" : "123...")); + assert_se(streq(cellescape(buf, 8, "1234\020"), is_locale_utf8() ? "1234…" : "1234...")); assert_se(streq(cellescape(buf, 9, "1234\020"), "1234\\020")); assert_se(streq(cellescape(buf, 1, "\t\n"), "")); assert_se(streq(cellescape(buf, 2, "\t\n"), ".")); assert_se(streq(cellescape(buf, 3, "\t\n"), "..")); - assert_se(streq(cellescape(buf, 4, "\t\n"), "…")); + assert_se(streq(cellescape(buf, 4, "\t\n"), is_locale_utf8() ? "…" : "...")); assert_se(streq(cellescape(buf, 5, "\t\n"), "\\t\\n")); - assert_se(streq(cellescape(buf, 5, "1234\t\n"), "1…")); - assert_se(streq(cellescape(buf, 6, "1234\t\n"), "12…")); - assert_se(streq(cellescape(buf, 7, "1234\t\n"), "123…")); - assert_se(streq(cellescape(buf, 8, "1234\t\n"), "1234…")); + assert_se(streq(cellescape(buf, 5, "1234\t\n"), is_locale_utf8() ? "1…" : "1...")); + assert_se(streq(cellescape(buf, 6, "1234\t\n"), is_locale_utf8() ? "12…" : "12...")); + assert_se(streq(cellescape(buf, 7, "1234\t\n"), is_locale_utf8() ? "123…" : "123...")); + assert_se(streq(cellescape(buf, 8, "1234\t\n"), is_locale_utf8() ? "1234…" : "1234...")); assert_se(streq(cellescape(buf, 9, "1234\t\n"), "1234\\t\\n")); - assert_se(streq(cellescape(buf, 4, "x\t\020\n"), "…")); - assert_se(streq(cellescape(buf, 5, "x\t\020\n"), "x…")); - assert_se(streq(cellescape(buf, 6, "x\t\020\n"), "x…")); - assert_se(streq(cellescape(buf, 7, "x\t\020\n"), "x\\t…")); - assert_se(streq(cellescape(buf, 8, "x\t\020\n"), "x\\t…")); - assert_se(streq(cellescape(buf, 9, "x\t\020\n"), "x\\t…")); + assert_se(streq(cellescape(buf, 4, "x\t\020\n"), is_locale_utf8() ? "…" : "...")); + assert_se(streq(cellescape(buf, 5, "x\t\020\n"), is_locale_utf8() ? "x…" : "x...")); + assert_se(streq(cellescape(buf, 6, "x\t\020\n"), is_locale_utf8() ? "x…" : "x...")); + assert_se(streq(cellescape(buf, 7, "x\t\020\n"), is_locale_utf8() ? "x\\t…" : "x\\t...")); + assert_se(streq(cellescape(buf, 8, "x\t\020\n"), is_locale_utf8() ? "x\\t…" : "x\\t...")); + assert_se(streq(cellescape(buf, 9, "x\t\020\n"), is_locale_utf8() ? "x\\t…" : "x\\t...")); assert_se(streq(cellescape(buf, 10, "x\t\020\n"), "x\\t\\020\\n")); assert_se(streq(cellescape(buf, 6, "1\011"), "1\\t")); diff --git a/src/timedate/org.freedesktop.timedate1.policy b/src/timedate/org.freedesktop.timedate1.policy index c4e71b075..4a770c08e 100644 --- a/src/timedate/org.freedesktop.timedate1.policy +++ b/src/timedate/org.freedesktop.timedate1.policy @@ -16,7 +16,7 @@ The systemd Project - http://www.freedesktop.org/wiki/Software/systemd + https://systemd.io Set system time diff --git a/src/xdg-autostart-generator/xdg-autostart-service.c b/src/xdg-autostart-generator/xdg-autostart-service.c index 241a5b3cf..c60a9d81a 100644 --- a/src/xdg-autostart-generator/xdg-autostart-service.c +++ b/src/xdg-autostart-generator/xdg-autostart-service.c @@ -485,7 +485,7 @@ static int xdg_autostart_generate_desktop_condition( log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r, "%s not found: %m", test_binary); fprintf(f, "# ExecCondition using %s skipped due to missing binary.\n", test_binary); - return r; + return 0; } e_autostart_condition = cescape(condition);