]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
4 years agoudev-node: do not ignore unexpected errors on removing symlink in stack directory 20715/head
Yu Watanabe [Sun, 12 Sep 2021 07:14:27 +0000 (16:14 +0900)] 
udev-node: do not ignore unexpected errors on removing symlink in stack directory

Only acceptable error here is -ENOENT.

4 years agoudev-node: simplify the example of race
Yu Watanabe [Sun, 12 Sep 2021 07:05:51 +0000 (16:05 +0900)] 
udev-node: simplify the example of race

4 years agosd-boot: Fix assertion fail
Jan Janssen [Sat, 11 Sep 2021 09:14:06 +0000 (11:14 +0200)] 
sd-boot: Fix assertion fail

The UEFI Platform Initialization Specification says that both
parameters may be NULL.

4 years agotpm-util: fix TPM parameter handling
Anatol Pomozov [Fri, 10 Sep 2021 18:52:55 +0000 (11:52 -0700)] 
tpm-util: fix TPM parameter handling

cryptenroll allows to specify a custom TPM driver separated from
parameters with colon e.g. `systemd-cryptenroll --tpm2-device=swtpm:`
tells to load swtpm tss driver and use it as a device.

Unfortunately it does not work, swtpm driver init() fails with

```
debug:tcti:src/tss2-tcti/tcti-swtpm.c:570:Tss2_Tcti_Swtpm_Init() Dup'd conf string to: 0x562f91cbc000
debug:tcti:src/util/key-value-parse.c:85:parse_key_value_string() parsing key/value: swtpm:
WARNING:tcti:src/util/key-value-parse.c:50:parse_key_value() key / value string is invalid
Failed to initialize TCTI context: tcti:A parameter has a bad value
```

It turns out that cryptenroll suppose to use the driver name internally
and strip it before passing the rest of parameters to init() function.
Without doing it swtpm receives incorrect key-value property and gets
confused.

Fix it by passing the correct parameter (without driver name) to the
init() function.

Fixes #20708

4 years agoMerge pull request #20699 from yuwata/network-drop-foreign
Luca Boccassi [Fri, 10 Sep 2021 20:10:58 +0000 (21:10 +0100)] 
Merge pull request #20699 from yuwata/network-drop-foreign

network: do not drop foreign configs when carrier of unmanaged interface is lost

4 years agoMerge pull request #20702 from yuwata/network-trivial-cleanups
Luca Boccassi [Fri, 10 Sep 2021 20:10:40 +0000 (21:10 +0100)] 
Merge pull request #20702 from yuwata/network-trivial-cleanups

network: several trivial cleanups

4 years agonetwork: fix handling of network interface renaming
Yu Watanabe [Thu, 9 Sep 2021 23:09:56 +0000 (08:09 +0900)] 
network: fix handling of network interface renaming

Fixes #20657.

4 years agoMerge pull request #20703 from poettering/gpt-dissect-tweaks
Lennart Poettering [Fri, 10 Sep 2021 18:48:31 +0000 (20:48 +0200)] 
Merge pull request #20703 from poettering/gpt-dissect-tweaks

dissect: various small tweaks/tougher checks/refactoring of GPT dissection code

4 years agocore: Parse log environment settings again after applying manager environment
Daan De Meyer [Tue, 7 Sep 2021 15:13:56 +0000 (16:13 +0100)] 
core: Parse log environment settings again after applying manager environment

Currently, SYSTEMD_LOG_LEVEL set in the ManagerEnvironment property in system.conf
or user.conf doesn't affect the manager's logging level. Parsing the logging environment
variables again after pushing the manager environment into the process environment
block makes sure any new environment changes also get taken into account for logging.

4 years agodissect-image: replace redundant if check by assert() 20703/head
Lennart Poettering [Thu, 9 Sep 2021 09:41:52 +0000 (11:41 +0200)] 
dissect-image: replace redundant if check by assert()

We know that the designator can only be USR or ROOT (or negative), hence
let's test that with an assert here, instead of doing an if check.

4 years agodissect-image: insist that if a verity partition designator is specified the partitio...
Lennart Poettering [Thu, 9 Sep 2021 09:38:52 +0000 (11:38 +0200)] 
dissect-image: insist that if a verity partition designator is specified the partition exists

Let's tighten our checks further.

4 years agodissect-image: tighten checks on root + /usr/ combinations
Lennart Poettering [Thu, 9 Sep 2021 09:33:03 +0000 (11:33 +0200)] 
dissect-image: tighten checks on root + /usr/ combinations

Our code logic doesn't support images with two verity partitions at the
moment, hence refuse this early (with ENOTUNIQ)

Also, go even further and refuse any combinations of verity enabled root
with verity-less /usr, simplify because that is unsafe and defeats the
point of verity. (i.e. we want to give the guarantee that for
auto-discovered verity magic we guarantee that the data afterwards
available in /usr is safe).

4 years agodissect-image: drop redundant check
Lennart Poettering [Thu, 9 Sep 2021 09:29:19 +0000 (11:29 +0200)] 
dissect-image: drop redundant check

We already check whether we discovered a /usr verity partition without a
/usr partition when initially mangling the partitions, a bunch of lines
further up, no need to repeat this here.

4 years agodissect-image: don't do generic root partition fallback if verity is requested for...
Lennart Poettering [Thu, 9 Sep 2021 09:18:47 +0000 (11:18 +0200)] 
dissect-image: don't do generic root partition fallback if verity is requested for /usr

4 years agodissect-image: insist that the architecture matches if both root and /usr partitions...
Lennart Poettering [Thu, 9 Sep 2021 09:24:44 +0000 (11:24 +0200)] 
dissect-image: insist that the architecture matches if both root and /usr partitions are found

4 years agodissect-image: mangle discovered /usr/ partition data, even if we found a root partition
Lennart Poettering [Thu, 9 Sep 2021 09:12:23 +0000 (11:12 +0200)] 
dissect-image: mangle discovered /usr/ partition data, even if we found a root partition

Previously, we'd clean up discovered /usr/ partition data only if we did
not find a root partition. Given that we allow combinations of root and
/usr partitions clean things up in both cases however.

4 years agodissect-image: refuse external verity data in partitioned mode
Lennart Poettering [Wed, 8 Sep 2021 15:30:33 +0000 (17:30 +0200)] 
dissect-image: refuse external verity data in partitioned mode

Our code doesn't support setting up verity with an external verity data
file unless we operate in non-partitioned mode. Let's refuse this
clearly and early if attempted anyway.

4 years agodissect-image: also derive read-only mode from fstype in non-partitioned mode
Lennart Poettering [Wed, 8 Sep 2021 15:29:06 +0000 (17:29 +0200)] 
dissect-image: also derive read-only mode from fstype in non-partitioned mode

For the GPT partitioned logic we also consult the fstype to determine whether
a partition is read-only (i.e. squashfs is already read-only). For the
non-partitioned mode we didn't do that so far. Fix that.

4 years agodissect-image: tighten assertion checks on verity data
Lennart Poettering [Wed, 8 Sep 2021 15:28:37 +0000 (17:28 +0200)] 
dissect-image: tighten assertion checks on verity data

4 years agodissect-image: rename dissected_image_has_verity()/_can_do_verity()
Lennart Poettering [Wed, 8 Sep 2021 15:26:32 +0000 (17:26 +0200)] 
dissect-image: rename dissected_image_has_verity()/_can_do_verity()

Let's also pick more precise names for these helpers that are used for
the tabular output: one checks whether a partition is candidate for
verity at all, and the other checks if it is ready to be used for it.
Let's make this clearer in the name.

4 years agodissect-image: rename verity flag booleans
Lennart Poettering [Wed, 8 Sep 2021 14:56:42 +0000 (16:56 +0200)] 
dissect-image: rename verity flag booleans

Let's make the booleans indicating verity state a bit more descriptive.

Let's rename:

    can_verity → has_verity: because that's really what this about
    whether verity data is included in the image. Whether we actually
    can use it is a different story.

    verity → verity_ready: this one should tell us if we have everything
    need to actually set it up, hence explicitly say "ready to use" in
    the name.

No change in behaviour. Just a bit of renaming.

4 years agoid128: clarify that the "well-known" IDs are about GPT partition types
Lennart Poettering [Fri, 10 Sep 2021 08:32:25 +0000 (10:32 +0200)] 
id128: clarify that the "well-known" IDs are about GPT partition types

At least for now they are all GPT partition types, and we should mention
that.

4 years agonetwork: drop unused "after_configure" feature for nexthops, neighbors, and routing... 20699/head
Yu Watanabe [Thu, 15 Jul 2021 04:21:59 +0000 (13:21 +0900)] 
network: drop unused "after_configure" feature for nexthops, neighbors, and routing policy rules

4 years agonetwork: do not try to drop addresses or routes of unmanaged interfaces on carrier...
Yu Watanabe [Sun, 5 Sep 2021 08:14:36 +0000 (17:14 +0900)] 
network: do not try to drop addresses or routes of unmanaged interfaces on carrier lost

Currently, link_stop_engines(), link_drop_config(), and link_drop_foreign_config()
do nothing when the interface is unmanaged. So this does not change anything.
But returning earlier should be clear and safer for protecting configs
on unmanaged interfaces.

4 years agonetwork: introduce route_by_kernel() helper function 20702/head
Yu Watanabe [Wed, 8 Sep 2021 06:26:27 +0000 (15:26 +0900)] 
network: introduce route_by_kernel() helper function

And drop "FIXME" from comment, as there is nothing we need to fix.

4 years agonetwork: introduce ipv4acd_set_ifname()
Yu Watanabe [Wed, 8 Sep 2021 05:08:13 +0000 (14:08 +0900)] 
network: introduce ipv4acd_set_ifname()

4 years agonetwork: use sd_netlink_message_read_string_strdup()
Yu Watanabe [Thu, 15 Jul 2021 04:20:04 +0000 (13:20 +0900)] 
network: use sd_netlink_message_read_string_strdup()

4 years agosd-boot: Support installing new devicetree
Emil Renner Berthing [Sat, 24 Apr 2021 23:38:28 +0000 (23:38 +0000)] 
sd-boot: Support installing new devicetree

The Bootloader Specification says "devicetree refers to the binary
device tree to use when executing the kernel..", but systemd-boot
didn't actually do anything when encountering this stanza until now.

Add support for loading, applying fixups if relevant, and installing the
new device tree before executing the kernel.

4 years agobasic/linux: Sync if_arp.h with Linux 5.14
Chris Packham [Thu, 9 Sep 2021 21:51:36 +0000 (09:51 +1200)] 
basic/linux: Sync if_arp.h with Linux 5.14

ARPHRD_MCTP was added in 5.14. Sync if_arp.h to pick up the definition

Fixes #20694

4 years agoshared: Extract common LogControl CLI code to verb-log-control.h
Daan De Meyer [Tue, 7 Sep 2021 12:35:49 +0000 (13:35 +0100)] 
shared: Extract common LogControl CLI code to verb-log-control.h

Let's reduce duplication by sharing common logic between all
log-target/log-level verbs.

4 years agoMerge pull request #20693 from mcatanzaro/mcatanzaro/nss-buffers
Yu Watanabe [Thu, 9 Sep 2021 23:43:32 +0000 (08:43 +0900)] 
Merge pull request #20693 from mcatanzaro/mcatanzaro/nss-buffers

nss-systemd: ensure returned strings point into provided buffer

4 years agonss-systemd: ensure returned strings point into provided buffer 20693/head
Michael Catanzaro [Wed, 8 Sep 2021 21:51:16 +0000 (16:51 -0500)] 
nss-systemd: ensure returned strings point into provided buffer

Jamie Bainbridge found an issue where glib's g_get_user_database_entry()
may crash after doing:

```
error = getpwnam_r (logname, &pwd, buffer, bufsize, &pw);
// ...
pw->pw_name[0] = g_ascii_toupper (pw->pw_name[0]);
```

in order to uppercase the first letter of the user's real name. This is
a glib bug, because there is a different codepath that gets the pwd from
vanilla getpwnam instead of getpwnam_r as shown here. When the pwd
struct is returned by getpwnam, its fields point to static data owned by
glibc/NSS, and so it must not be modified by the caller. After much
debugging, Jamie Bainbridge has fixed this in https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2244
by making a copy of the data before modifying it, and that resolves all
problems for glib. Yay!

However, glib is crashing even when getpwnam_r is used instead of
getpwnam! According to getpwnam_r(3), the strings in the pwd struct are
supposed to be pointers into the buffer passed by the caller, so glib
should be able to safely edit it directly in this case, so long as it
doesn't try to increase the size of any of the strings.

Problem is various functions throughout nss-systemd.c return synthesized
records declared at the top of the file. These records are returned
directly and so contain pointers to static strings owned by
libsystemd-nss. systemd must instead copy all the strings into the
provided buffer.

This crash is reproducible if nss-systemd is listed first on the passwd
line in /etc/nsswitch.conf, and the application looks up one of the
synthesized user accounts "root" or "nobody", and finally the
application attempts to edit one of the strings in the returned struct.
All our synthesized records for the other struct types have the same
problem, so this commit fixes them all at once.

Fixes #20679

4 years agocryptsetup-tokens: fix typo in tpm2 token dump output
Anssi Hannula [Thu, 9 Sep 2021 11:58:13 +0000 (14:58 +0300)] 
cryptsetup-tokens: fix typo in tpm2 token dump output

cryptsetup_token_dump() gets called when the user calls
"cryptsetup luksDump"  for a volume and it prints the token-specific
data.

The tpm2 cryptsetup_token_dump() function misspells tpm2 as tmp2 on two
lines of its output.

Fix that.

4 years agoMerge pull request #20681 from weblate/weblate-systemd-master
Zbigniew Jędrzejewski-Szmek [Thu, 9 Sep 2021 07:20:00 +0000 (09:20 +0200)] 
Merge pull request #20681 from weblate/weblate-systemd-master

Translations update from Weblate

4 years agopo: Translated using Weblate (Finnish) 20681/head
Jan Kuparinen [Thu, 9 Sep 2021 03:04:59 +0000 (05:04 +0200)] 
po: Translated using Weblate (Finnish)

Currently translated at 64.5% (122 of 189 strings)

Co-authored-by: Jan Kuparinen <copper_fin@hotmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/fi/
Translation: systemd/main

4 years agopo: Translated using Weblate (Japanese)
Takuro Onoue [Thu, 9 Sep 2021 03:04:59 +0000 (05:04 +0200)] 
po: Translated using Weblate (Japanese)

Currently translated at 100.0% (189 of 189 strings)

Co-authored-by: Takuro Onoue <kusanaginoturugi@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/ja/
Translation: systemd/main

4 years agopo: Translated using Weblate (Indonesian)
Andika Triwidada [Thu, 9 Sep 2021 03:04:58 +0000 (05:04 +0200)] 
po: Translated using Weblate (Indonesian)

Currently translated at 90.4% (171 of 189 strings)

Co-authored-by: Andika Triwidada <andika@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/id/
Translation: systemd/main

4 years agonss-systemd: pack pw_passwd result into supplied buffer
Michael Catanzaro [Wed, 8 Sep 2021 18:42:16 +0000 (13:42 -0500)] 
nss-systemd: pack pw_passwd result into supplied buffer

getpwnam_r() guarantees that the strings in the struct passwd that it
returns are pointers into the buffer allocated by the application and
passed to getpwnam_r(). This means applications may choose to modify the
strings in place, as long as the length of the strings is not increased.
So it's wrong for us to return a static string here, we really do have
to copy it into the application-provided buffer like we do for all the
other strings.

This is only a theoretical problem since it would be very weird for an
application to modify the pw_passwd field, but I spotted this when
investigating a similar crash caused by glib editing a different field.
See also:

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2244

4 years agoanalyze: ignore dependencies with security --offline
Luca Boccassi [Wed, 8 Sep 2021 14:15:00 +0000 (15:15 +0100)] 
analyze: ignore dependencies with security --offline

We don't care about validating dependencies here, the security verb is
only checking the unit(s) under test.

4 years agosd-event: take ref on event loop object before dispatching event sources
Michal Sekletar [Wed, 8 Sep 2021 13:42:11 +0000 (15:42 +0200)] 
sd-event: take ref on event loop object before dispatching event sources

Idea is that all public APIs should take reference on objects that get
exposed to user-provided callbacks. We take the reference as a
protection from callbacks dropping it. We used to do this also here in
sd_event_loop(). However, in cleanup portion of f814c871e6 this was
accidentally dropped.

4 years agocore: fix free undefined pointer when strdup failed in the first loop
xujing [Wed, 8 Sep 2021 06:26:20 +0000 (14:26 +0800)] 
core: fix free undefined pointer when strdup failed in the first loop

4 years agotest: rename `dracut_install` to `image_install`
Frantisek Sumsal [Wed, 8 Sep 2021 11:33:34 +0000 (13:33 +0200)] 
test: rename `dracut_install` to `image_install`

The `dracut_install` is a misnomer, since the systemd integration test
suite is based on the original dracut's test suite, and not all the
references to dracut has been edited out. Let's fix that.

4 years agoexplicitly close FIDO2 devices
pedro martelletto [Wed, 8 Sep 2021 08:42:56 +0000 (10:42 +0200)] 
explicitly close FIDO2 devices

FIDO2 device access is serialised by libfido2 using flock().
Therefore, make sure to close a FIDO2 device once we are done
with it, or we risk opening it again at a later point and
deadlocking. Fixes #20664.

4 years agoMerge pull request #20667 from keszybz/portable-docs
Luca Boccassi [Wed, 8 Sep 2021 12:41:44 +0000 (13:41 +0100)] 
Merge pull request #20667 from keszybz/portable-docs

Tweaks to documentation about portable services

4 years agodocs: polish the text about Portable Services a bit 20667/head
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 17:14:19 +0000 (19:14 +0200)] 
docs: polish the text about Portable Services a bit

No semantic changes, just removal of repetitions and unnecessary words, and
some more formatting.

4 years agodocs: portablectl is in bin/
Zbigniew Jędrzejewski-Szmek [Tue, 7 Sep 2021 16:43:58 +0000 (18:43 +0200)] 
docs: portablectl is in bin/

Follow-up for 80f39b81f3876ed3816061f1093db991f72269ec.

4 years agotest: rename TEST-63-ANALYZE to solve conflict
Luca Boccassi [Tue, 7 Sep 2021 15:27:28 +0000 (16:27 +0100)] 
test: rename TEST-63-ANALYZE to solve conflict

Two PRs adding TEST-63-* were merged more or less at the
same time, and we missed the conflict.

4 years agotest: udev storage tests
Frantisek Sumsal [Fri, 30 Jul 2021 14:56:10 +0000 (16:56 +0200)] 
test: udev storage tests

4 years agonetwork: fix wrong flag: manage_foreign_routes -> manage_foreign_rules
Yu Watanabe [Tue, 7 Sep 2021 12:46:50 +0000 (21:46 +0900)] 
network: fix wrong flag: manage_foreign_routes -> manage_foreign_rules

Fixes a bug in d94dfe7053d49fa62c4bfc07b7f3fc2227c10aff.

4 years agoMerge pull request #20618 from yuwata/path-find-component
Lennart Poettering [Tue, 7 Sep 2021 08:02:44 +0000 (10:02 +0200)] 
Merge pull request #20618 from yuwata/path-find-component

use path_find_{first,last}_component() at more several places

4 years agotest: do not try to remove /dev 20618/head
Yu Watanabe [Fri, 3 Sep 2021 15:29:11 +0000 (00:29 +0900)] 
test: do not try to remove /dev

4 years agofs-util: rewrite rmdir_parents() with path_find_last_component()
Yu Watanabe [Thu, 2 Sep 2021 04:41:15 +0000 (13:41 +0900)] 
fs-util: rewrite rmdir_parents() with path_find_last_component()

4 years agomkdir: rewrite mkdir_parents() with path_find_{first,last}_component()
Yu Watanabe [Thu, 2 Sep 2021 07:12:16 +0000 (16:12 +0900)] 
mkdir: rewrite mkdir_parents() with path_find_{first,last}_component()

4 years agoMerge pull request #20465 from bluca/portable_validate_sysext
Lennart Poettering [Mon, 6 Sep 2021 19:10:15 +0000 (21:10 +0200)] 
Merge pull request #20465 from bluca/portable_validate_sysext

portabled: validate SYSEXT_LEVEL when attaching

4 years agoMerge pull request #20527 from systemd/wip/hadess/usb-analysers-uaccess
Lennart Poettering [Mon, 6 Sep 2021 19:06:40 +0000 (21:06 +0200)] 
Merge pull request #20527 from systemd/wip/hadess/usb-analysers-uaccess

hwdb: Allow end-users root-less access to USB analysers

4 years agosystemd-analyze: add new option to generate JSON output of security analysis table
Maanya Goenka [Thu, 26 Aug 2021 07:17:32 +0000 (00:17 -0700)] 
systemd-analyze: add new option to generate JSON output of security analysis table

The new option --json= works with the 'security' verb and takes in one of three format flags.
These are off which is the default, pretty and short which use JSON format flags for output.
When set to true, it generates a JSON formatted output of the security analysis table. The
format is a JSON array with objects containing the following fields: set which indicates if
the id has been set or not, name which is what is used to refer to the id, json_field
which is the equivalent JSON formatted id name only used for JSON outputs, description which
is an outline of the id state, and exposure which is an unsigned integer in the range 0.0..10.0,
where a higher value corresponds to a higher security threat. The JSON version of the table is
printed on the standard output file.

Example Run:

The unit file testfile.service was created to test the --json= option

maanya-goenka@debian:~/systemd (json-security)$ cat <<EOF >testfile.service

> [Service]
> ExecStart = echo hello
> PrivateNetwork = yes
> PrivateMounts = yes
> PrivateDevices = yes
> EOF

Both the JSON output and the security analysis table below have been truncated to increase readability.
1. Testing for when --json=off

maanya-goenka@debian:~/systemd (json-security)$ sudo build/systemd-analyze security --json=off --root= --offline=true
testfile.service --no-pager

/usr/lib/systemd/system/plymouth-start.service:15: Unit configured to use KillMode=none. This is unsafe, as it disables systemd's
process lifecycle management for the service. Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'.
Support for KillMode=none is deprecated and will eventually be removed.
/usr/lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating
/var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
/usr/lib/systemd/system/gdm.service:30: Standard output type syslog is obsolete, automatically updating to journal. Please update your
unit file, and consider removing the setting altogether.
/home/maanya-goenka/systemd/foo.service:2: Unknown key name 'foo' in section 'Unit', ignoring.

    NAME                                                      DESCRIPTION                                                       EXPOSURE
✓   PrivateNetwork=                                           Service has no access to the host's network
✗   User=/DynamicUser=                                        Service runs as root user                                              0.4
✗   CapabilityBoundingSet=~CAP_SET(UID|GID|PCAP)              Service may change UID/GID identities/capabilities                     0.3
✗   CapabilityBoundingSet=~CAP_NET_ADMIN                      Service has administrator privileges                                   0.3

→ Overall exposure level for testfile.service: 8.3 EXPOSED 🙁

2. Testing for when --json=pretty

maanya-goenka@debian:~/systemd (json-security)$ sudo build/systemd-analyze security --json=pretty --root= --offline=true
testfile.service

/usr/lib/systemd/system/plymouth-start.service:15: Unit configured to use KillMode=none. This is unsafe, as it disables systemd's
process lifecycle management for the service. Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'.
Support for KillMode=none is deprecated and will eventually be removed.
/usr/lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating
/var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
/usr/lib/systemd/system/gdm.service:30: Standard output type syslog is obsolete, automatically updating to journal. Please update your
unit file, and consider removing the setting altogether.
/home/maanya-goenka/systemd/foo.service:2: Unknown key name 'foo' in section 'Unit', ignoring.

[
        {
                "set" : true,
                "name" : "PrivateNetwork=",
"json-field" : "PrivateNetwork",
                "description" : "Service has no access to the host's network",
                "exposure" : null
        },
        {
                "set" : false,
                "name" : "User=/DynamicUser=",
"json-field" : "UserOrDynamicUser",
                "decsription" : "Service runs as root user",
                "exposure" : "0.4"
        },
        {
                "set" : false,
                "name" : "CapabilityBoundingSet=~CAP_SET(UID|GID|PCAP)",
"json_field" : "CapabilityBoundingSet_CAP_SET_UID_GID_PCAP",
                "description" : "Service may change UID/GID identities/capabilities",
                "exposure" : "0.3"
        },
        {
                "set" : false,
                "name" : "CapabilityBoundingSet=~CAP_NET_ADMIN",
"json_field" : "CapabilityBoundingSet_CAP_NET_ADMIN",
                "description" : "Service has administrator privileges",
                "exposure" : "0.3"
        },
        ...
]

3. Testing for when --json=short

maanya-goenka@debian:~/systemd (json-security)$ sudo build/systemd-analyze security --json=short --root= --offline=true
testfile.service

/usr/lib/systemd/system/plymouth-start.service:15: Unit configured to use KillMode=none. This is unsafe, as it disables systemd's
process lifecycle management for the service. Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'.
Support for KillMode=none is deprecated and will eventually be removed.
/usr/lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating
/var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
/usr/lib/systemd/system/gdm.service:30: Standard output type syslog is obsolete, automatically updating to journal. Please update your
unit file, and consider removing the setting altogether.
/home/maanya-goenka/systemd/foo.service:2: Unknown key name 'foo' in section 'Unit', ignoring.

[{"set":true,"name":"PrivateNetwork=", "json_field":"PrivateNetwork", "description":"Service has no access to the host's network","exposure":null}, ...]

4 years agosystemd-analyze: use config value in RestrictNamespaces id (#20645)
Kyle Laker [Mon, 6 Sep 2021 15:33:16 +0000 (11:33 -0400)] 
systemd-analyze: use config value in RestrictNamespaces id (#20645)

For most fields, the text shown by `.id` is the value that should be set
in the unit file; however, for RestrictNamespaces, it is not. Changing
this to show the actual text makes it more clear to a user what the
actual change that needs to be made to the unit file is.

4 years agoFix volume control keys for LG Gram (#20644)
Ross Jennings [Mon, 6 Sep 2021 14:55:11 +0000 (10:55 -0400)] 
Fix volume control keys for LG Gram (#20644)

Fix volume control keys for LG Gram

4 years agoportabled: refactor extraction/validation into a common helper 20465/head
Luca Boccassi [Mon, 6 Sep 2021 12:19:47 +0000 (13:19 +0100)] 
portabled: refactor extraction/validation into a common helper

4 years agoportabled: validate SYSEXT_LEVEL when attaching
Luca Boccassi [Wed, 4 Aug 2021 14:00:06 +0000 (15:00 +0100)] 
portabled: validate SYSEXT_LEVEL when attaching

When attaching a portable service with extensions, immediately validate
that the os-release and extension-release metadata values match, rather
than letting it fail when the units are started

4 years agoportabled: error out if there are no units only after parsing all images
Luca Boccassi [Wed, 18 Aug 2021 15:37:13 +0000 (16:37 +0100)] 
portabled: error out if there are no units only after parsing all images

It's ok if the OS image doesn't have matching units, if we find them
in the extensions. Tidies up the parsing logic a bit.

4 years agodissect-image: add extension-specific validation flag
Luca Boccassi [Wed, 18 Aug 2021 15:08:14 +0000 (16:08 +0100)] 
dissect-image: add extension-specific validation flag

Allows callers to specify which image type they are looking for

4 years agoFix esc, volume control keys and Fn+F1 for Samsung Galaxy Book
lainahai [Sun, 5 Sep 2021 16:48:08 +0000 (19:48 +0300)] 
Fix esc, volume control keys and Fn+F1 for Samsung Galaxy Book

4 years agoFix volume control keys for Lenovo Ideapad Flex 5
saikat0511 [Sat, 4 Sep 2021 18:24:34 +0000 (23:54 +0530)] 
Fix volume control keys for Lenovo Ideapad Flex 5

Fixes the keys not creating release events

4 years agotmpfiles: minor modernization
Yu Watanabe [Sat, 4 Sep 2021 20:46:21 +0000 (05:46 +0900)] 
tmpfiles: minor modernization

4 years agohome: 'secret' argument of handle_generic_user_record_error may be null
Yu Watanabe [Sun, 5 Sep 2021 02:16:26 +0000 (11:16 +0900)] 
home: 'secret' argument of handle_generic_user_record_error may be null

When RefHome() bus method is called in acquire_home(), secret is NULL.

Fixes #20639.

4 years agotree-wide: fix typo
Yu Watanabe [Sat, 4 Sep 2021 22:12:50 +0000 (07:12 +0900)] 
tree-wide: fix typo

4 years agoMerge pull request #20626 from yuwata/network-keep-master
Luca Boccassi [Sat, 4 Sep 2021 14:08:56 +0000 (15:08 +0100)] 
Merge pull request #20626 from yuwata/network-keep-master

network: introduce KeepMaster= setting

4 years agomeson.build: change operator combining bools from + to and
Dan Streetman [Fri, 3 Sep 2021 16:43:33 +0000 (12:43 -0400)] 
meson.build: change operator combining bools from + to and

upstream meson stopped allowing combining boolean with the plus
operator, and now requires using the logical and operator

reference:
https://github.com/mesonbuild/meson/commit/43302d3296baff6aeaf8e03f5d701b0402e37a6c

Fixes: #20632
4 years agonetwork: add 80-container-vb.network 20626/head
Yu Watanabe [Thu, 2 Sep 2021 23:47:49 +0000 (08:47 +0900)] 
network: add 80-container-vb.network

4 years agotest-network: add tests for KeepMaster=
Yu Watanabe [Fri, 3 Sep 2021 15:23:55 +0000 (00:23 +0900)] 
test-network: add tests for KeepMaster=

4 years agoMerge pull request #20629 from keszybz/mkosi-host-distro-by-default
Zbigniew Jędrzejewski-Szmek [Fri, 3 Sep 2021 15:46:35 +0000 (17:46 +0200)] 
Merge pull request #20629 from keszybz/mkosi-host-distro-by-default

mkosi: build for the host distro by default

4 years agonetwork: introduce KeepMaster= setting
Yu Watanabe [Thu, 2 Sep 2021 21:10:07 +0000 (06:10 +0900)] 
network: introduce KeepMaster= setting

Closes #20624.

4 years agonetwork: assume enslaved when master ifindex is positive
Yu Watanabe [Thu, 2 Sep 2021 23:04:29 +0000 (08:04 +0900)] 
network: assume enslaved when master ifindex is positive

4 years agonetwork: use master ifindex to check if the interface is enslaved
Yu Watanabe [Thu, 2 Sep 2021 22:24:15 +0000 (07:24 +0900)] 
network: use master ifindex to check if the interface is enslaved

4 years agoman: drop unnecessary white space
Yu Watanabe [Thu, 2 Sep 2021 21:09:54 +0000 (06:09 +0900)] 
man: drop unnecessary white space

4 years agoformat-table: allow to explicitly override JSON field names
Lennart Poettering [Fri, 3 Sep 2021 09:11:18 +0000 (11:11 +0200)] 
format-table: allow to explicitly override JSON field names

In some cases it's useful to explicitly generate the JSON field names to
generate for table columns, instead of auto-mangling them from table
header names that are intended for human consumption.

This adds the infra and a test for it.

It's intended to be used by #20544, for the first column, which in text
mode should have an empty header field, but have an explicit name in
json output mode.

4 years agomkosi: move distro files to mkosi.default.d/ 20629/head
Zbigniew Jędrzejewski-Szmek [Thu, 2 Sep 2021 12:39:37 +0000 (14:39 +0200)] 
mkosi: move distro files to mkosi.default.d/

With this change, "mkosi build" will automatically build systemd for the
current distro without any further configuration. If people want to do a
cross-distro build by default, they can still create mkosi.default, but I
assume that this is relatively rare.

If people have symlinked mkosi.default to one of the files in .mkosi/, they'll
need to adjust the symlink.

(Building without configuration would always fail, since systemd has many many
required dependencies. I think it's nicer to do the most commonly expected
thing by default, i.e. rebuild for the current distro.)

Mkosi is nowadays packaged for most distros, so recommend installing of distro
packages as the primary installation mechanism.

4 years agogitignore: only ignore *local*.conf" under mkosi.default.d/
Zbigniew Jędrzejewski-Szmek [Thu, 2 Sep 2021 12:33:55 +0000 (14:33 +0200)] 
gitignore: only ignore *local*.conf" under mkosi.default.d/

The pattern was added in 6242cda99d9194efec20997697d703c0c005dbd4, with the
idea that users will have local configuration files for mkosi and git should
not bother them about those. But let's make this narrower, and only match
files with "local". This way we reduce the risk that some unrelated file
will be ignored by accident.

.gitignore in the parent directory is used, because mkosi apparently tries
to load all files under mkosi.default.d/, without looking at the extension.
This is probably something to fix in mkosi too.

4 years agojournalctl: Use constants in some more places
Jan Janssen [Thu, 2 Sep 2021 11:28:55 +0000 (13:28 +0200)] 
journalctl: Use constants in some more places

4 years agomkosi: make mkosi.build shellcheck-clean
Zbigniew Jędrzejewski-Szmek [Thu, 2 Sep 2021 12:22:19 +0000 (14:22 +0200)] 
mkosi: make mkosi.build shellcheck-clean

Also remove the space after redirection operators. (Some redirections
were with, some without, and I think it's nicer without.)

4 years agomkosi: drop the code to determine nobody user name
Zbigniew Jędrzejewski-Szmek [Thu, 2 Sep 2021 12:19:19 +0000 (14:19 +0200)] 
mkosi: drop the code to determine nobody user name

The comments were outdated: at least "nfsnobody" is not used in Fedora since a
few years. So I hope we don't need this anymore. The meson build scripts do
autodetection on their own.

4 years agoMerge pull request #20603 from yuwata/udev-node-cleanups
Yu Watanabe [Thu, 2 Sep 2021 20:33:06 +0000 (05:33 +0900)] 
Merge pull request #20603 from yuwata/udev-node-cleanups

udev: cleanups for creating/removing device node symlinks

4 years agohwdb: Allow end-users root-less access to USB analyzers 20527/head
Bastien Nocera [Tue, 24 Aug 2021 11:54:02 +0000 (13:54 +0200)] 
hwdb: Allow end-users root-less access to USB analyzers

Procotol analyzers are external devices used to capture traffic over a
wire so that it could be analysed. End-users at the console should be
able to access those devices without requiring root access.

This change obsoletes the need to install Total Phase's "Linux drivers",
which are really just udev rules and hotplug usermap files to do that:
https://www.totalphase.com/products/usb-drivers-linux/

4 years agosd-journal: use FILE streams to buffer write_uint64()
Vito Caputo [Tue, 31 Aug 2021 01:20:53 +0000 (18:20 -0700)] 
sd-journal: use FILE streams to buffer write_uint64()

journal_file_verify() uses a set of tmpfs files to create lists
of object positions by type.

The existing code used a bare write() call for every object
position written, incurring a syscall per listed object.

This commit encapsulates the bare file descriptors in FILE *'s
and replaces the bare write with fwrite, buffering the writes so
there's less syscalls.

Cached `journalctl --verify` tests showed a ~8% faster runtime
with this change on a release build, verifying 1.3GiB of
production journals across 16 files.

4 years agoxattr-util: drop unused path_getcrtime()
Yu Watanabe [Thu, 2 Sep 2021 03:10:59 +0000 (12:10 +0900)] 
xattr-util: drop unused path_getcrtime()

4 years agofs-util: use futimens_opath() helper function
Yu Watanabe [Thu, 2 Sep 2021 03:05:33 +0000 (12:05 +0900)] 
fs-util: use futimens_opath() helper function

4 years agofs-util: drop unnecessary initialization
Yu Watanabe [Thu, 2 Sep 2021 03:05:14 +0000 (12:05 +0900)] 
fs-util: drop unnecessary initialization

4 years agoudev-node: drop redundant trial of devlink creation 20603/head
Yu Watanabe [Wed, 1 Sep 2021 00:29:42 +0000 (09:29 +0900)] 
udev-node: drop redundant trial of devlink creation

Previously, the devlink was created based on the priority saved in udev
database. So, we needed to reevaluate devlinks after database is saved.

But now the priority is stored in the symlink under /run/udev/links, and
the loop of devlink creation is controlled with the timestamp of the
directory. So, the double evaluation is not necessary anymore.

4 years agoudev-node: add random delay on conflict in updating device node symlink
Yu Watanabe [Tue, 31 Aug 2021 19:34:48 +0000 (04:34 +0900)] 
udev-node: add random delay on conflict in updating device node symlink

To make multiple workers not update the same device node symlink
simultaneously.

4 years agoudev-node: shorten code a bit and update log message
Yu Watanabe [Wed, 1 Sep 2021 23:23:35 +0000 (08:23 +0900)] 
udev-node: shorten code a bit and update log message

4 years agoudev-node: check stack directory change even if devlink is removed
Yu Watanabe [Wed, 1 Sep 2021 00:44:26 +0000 (09:44 +0900)] 
udev-node: check stack directory change even if devlink is removed

Otherwise, when multiple device additions and removals occur
simultaneously, symlink to unexisting devnode may be created.

Hopefully fixes #19946.

4 years agoudev-node: always atomically create symlink to device node
Yu Watanabe [Tue, 31 Aug 2021 17:20:33 +0000 (02:20 +0900)] 
udev-node: always atomically create symlink to device node

By the previous commit, it is not necessary to distinguish if the devlink
already exists. Also, I cannot find any significant advantages of the
previous complecated logic, that is, first try to create directly, and then
fallback to atomically creation. Moreover, such logic increases the chance
of conflicts between multiple udev workers.

This makes devlinks always created atomically. Hopefully, this reduces the
conflicts between the workers.

4 years agoudev-node: assume no new claim to a symlink if /run/udev/links is not updated
Yu Watanabe [Wed, 1 Sep 2021 21:58:59 +0000 (06:58 +0900)] 
udev-node: assume no new claim to a symlink if /run/udev/links is not updated

During creating a symlink to a device node, if another device node which
requests the same symlink is added/removed, `stat_inode_unmodified()`
should always detects that. We do not need to continue the loop
unconditionally.

4 years agoudev-node: always update timestamp of stack directory
Yu Watanabe [Wed, 1 Sep 2021 03:57:40 +0000 (12:57 +0900)] 
udev-node: always update timestamp of stack directory

Please see the comments in the code.

4 years agoudev-node: save information about device node and priority in symlink
Yu Watanabe [Tue, 31 Aug 2021 19:16:21 +0000 (04:16 +0900)] 
udev-node: save information about device node and priority in symlink

Previously, we only store device IDs in /run/udev/links, and when
creating/removing device node symlink, we create sd_device object
corresponds to the IDs and read device node and priority from the
object. That requires parsing uevent and udev database files.

This makes link_find_prioritized() get the most prioritzed device node
without parsing the files.

4 years agoudev-node: stack directory must exist when adding device node symlink
Yu Watanabe [Tue, 31 Aug 2021 19:14:42 +0000 (04:14 +0900)] 
udev-node: stack directory must exist when adding device node symlink

4 years agoudev-node: split out permission handling from udev_node_add()
Yu Watanabe [Wed, 1 Sep 2021 00:24:15 +0000 (09:24 +0900)] 
udev-node: split out permission handling from udev_node_add()

And then merge udev_node_add() and udev_node_update_old_links().

4 years agosd-device: introduce device_has_devlink()
Yu Watanabe [Wed, 1 Sep 2021 00:22:15 +0000 (09:22 +0900)] 
sd-device: introduce device_has_devlink()

4 years agoMerge pull request #20614 from poettering/efi-clean-ups
Yu Watanabe [Wed, 1 Sep 2021 23:30:07 +0000 (08:30 +0900)] 
Merge pull request #20614 from poettering/efi-clean-ups

two minor clean-ups for the efi code