Commit Graph
9171 Commits
Author SHA1 Message Date
Luca Boccassi 184ce19841 gpt-auto: take timeout opts in rootflags= into account; hibernate-resume: always respect user-defined timeout (#35518) 2024-12-12 11:01:40 +00:00
Yu Watanabe 66d2c693ac tpm2-util: allow to control if legend and/or footer shown by tpm2_list_devices() 2024-12-12 15:21:16 +09:00
Yu Watanabe 46c26454bd exec-util: use strv_from_stdarg_alloca()
No functional change, just refactoring.
2024-12-12 08:35:16 +09:00
Yu Watanabe f0ace1655d exec-util: use open_terminal() in fork_agent() for safety 2024-12-12 08:35:16 +09:00
Yu Watanabe 90579fd0b3 exec-util: drop handling of ENXIO in opening /dev/tty
This effectively reverts 0bcf167900.

The handling is not necessary anymore after 61242b1f0f.
2024-12-12 08:35:16 +09:00
Yu Watanabe fc3691a70a exec-util: split out common checks before fork_agent() to can_fork_agent()
No functional change, just refactoring.
2024-12-12 08:32:42 +09:00
Yu Watanabe 388d6c5f37 polkit-agent: modernize code a bit
- Use _cleanup_close_pair_ attribute for the pipe FDs,
- Return earlier on failure in forking polkit agent.
2024-12-12 08:30:55 +09:00
Yu Watanabe 0f81c8406f exec-util: allow to invoke polkit/ask-password agent even if STDIN is not a tty
Closes #35018.
2024-12-12 08:30:55 +09:00
Yu Watanabe 4899255aa2 format-table: trivial cleanups (#35572) 2024-12-12 06:12:07 +09:00
Yu Watanabe 7e438055a6 pretty-print: don't use OSC 8 for incompatible URLs (#35223) 2024-12-12 05:43:36 +09:00
Yu Watanabe e53be91e5d libfido2-util: show also verity features when listing FIDO2 devices (#35295)
This way, users don't have to check those features using an external
program, or wait for later failure when trying to enroll using an
unsupported feature.

E.g.:

```
# systemd-cryptenroll --fido2-device list
PATH         MANUFACTURER PRODUCT               RK  CLIENTPIN UP  UV
/dev/hidraw2 Yubico       YubiKey OTP+FIDO+CCID yes no        yes no
```
2024-12-12 05:11:46 +09:00
Lennart Poettering 3c702e8210 condition: add new ConditionKernelModuleLoaded=
This introduces a new unit condition check: that matches if a specific
kmod module is allowed. This should be generally useful, but there's one
usecase in particular: we can optimize modprobe@.service with this and
avoid forking out a bunch of modprobe requests during boot for the same
kmods.

Checking if a kernel module is loaded is more complicated than just
checking if /sys/module/$MODULE/ exists, since kernel modules typically
take a while to initialize and we must check that this is complete (by
checking if the sysfs attr "initstate" is "live").
2024-12-12 05:03:52 +09:00
Mike Yuan 26c29eed53 format-table: drop pointless table_data_rgap_color() func
Follow-up for aab79f5278
2024-12-11 19:19:46 +01:00
Mike Yuan da7cd0f500 format-table: minor modernization 2024-12-11 19:14:28 +01:00
Antonio Alvarez Feijoo b31e63960d libfido2-util: show also verity features when listing FIDO2 devices
This way, users don't have to check those features using an external program, or
wait for later failure when trying to enroll using an unsupported feature.
2024-12-11 17:28:30 +01:00
Lennart Poettering 0823d96a0b pretty-print: don't use OSC 8 for incompatible URLs 2024-12-11 10:35:03 +01:00
Yu Watanabe c577fe65f3 systemctl: downgrade log level of ECONNREFUSED from system dbus.service
To suppress log message when 'systemctl poweroff' or friends invoked in
rescue shell, which does not have dbus.service.
2024-12-11 18:08:26 +09:00
Antonio Alvarez Feijoo d950f897d9 libfido2-util: reorder dl symbols alphabetically 2024-12-11 07:33:02 +01:00
Yu Watanabe 627d1a9ac1 core: Add ProtectHostname=private (#35447)
This PR allows an option for systemd exec units to enable UTS namespaces
but not restrict changing hostname via seccomp. Thus, units can change
hostname without affecting the host. This is useful for OS-like
containers running as units where they should have freedom to change
their container hostname if they want, but not the host's hostname.

Fixes: #30348
2024-12-11 10:17:25 +09:00
Yu Watanabe 17e6e4d6b6 tree-wide: replace ANSI_XYZ with ansi_xyz()
Continuation of f0484e096c.
2024-12-11 10:11:53 +09:00
Ryan Wilson 219a6dbbf3 core: Fix time namespace in RestrictNamespaces=
RestrictNamespaces= would accept "time" but would not actually apply
seccomp filters e.g. systemd-run -p RestrictNamespaces=time unshare -T true
should fail but it succeeded.

This commit actually enables time namespace seccomp filtering.
2024-12-10 20:55:26 +01:00
Lennart Poettering 641714cb30 discover-image: extend r/o check on images via path
If we have no path, let's check the parent's path.
2024-12-10 20:53:56 +01:00
Lennart Poettering e82677aa07 tree-wide: fd_get_path() already understands AT_FDCWD natively 2024-12-10 20:46:30 +01:00
Yu Watanabe edd0a3c5e9 copy: do not try to copy zero size data
Hopefully fixes the following sanitizer issue:
===
[ 3754.797377] systemd-journald[776]: ../src/src/shared/copy.c:463:37: runtime error: variable length array bound evaluates to non-positive value 0
[ 3755.101713] systemd-journald[776]: Received SIGTERM from PID 1 (systemd).
[ 3755.124580] systemd-journald[776]: Journal stopped
Found 1 sanitizer issues (0 internal, 0 asan, 0 ubsan, 0 msan).
===
2024-12-10 19:20:50 +00:00
Luca Boccassi 18d2d10c17 Cryptenroll pager and tweaks (#35517) 2024-12-10 14:07:26 +00:00
Zbigniew Jędrzejewski-Szmek 7b2ebd7040 cryptenroll: show which devices support "hmac secret"
We'd silently skip devices which don't have the feature in the list.
This looked wrong esp. if no devices were suitable. Instead, list them
and show which ones are usable.

$ build/systemd-cryptenroll --fido2-device=list
PATH          MANUFACTURER PRODUCT                HMAC SECRET
/dev/hidraw7  Yubico       YubiKey OTP+FIDO+CCID  ✓
/dev/hidraw10 Yubico       Security Key by Yubico ✗
/dev/hidraw5  Yubico       Security Key by Yubico ✗
/dev/hidraw9  Yubico       Yubikey 4 OTP+U2F+CCID ✗
2024-12-10 10:58:58 +01:00
Yu Watanabe fb35d775a7 seccomp-util: add getxattrat and friends
The new syscalls are added in kernel-6.13:
https://github.com/torvalds/linux/commit/6140be90ec70c39fa844741ca3cc807dd0866394
2024-12-10 11:16:44 +09:00
Mike Yuan 149e05c7e9 fstab-generator: move write_(mount_)timeout() to shared/generator 2024-12-09 19:25:59 +01:00
Mike Yuan 9a097eced6 shared/generator: clean up generator_write_device_timeout() a bit
- Rephrase a few log messages
- Remove unused where parameter
- Return 1 if we set something

No functional change, preparation for later commits.
2024-12-09 19:22:33 +01:00
Mike Yuan 1d8ce41318 shared/generator: rename generator_write_device_deps() to _network_device_deps
The previous name was awfully vague. Let's be specific that this
is about _netdev only.
2024-12-09 19:03:57 +01:00
Mike Yuan e82d4edd20 shared/generator: trivial coding style cleanups 2024-12-09 19:03:53 +01:00
Yu Watanabe fbee22c237 journalctl: show coredumps again when --unit= is specified
This is a revised version of cbd5f5d7d6,
which is reverted by 560412148f.

The filter condition for _UID= field was added by
fdcd37df3b. However, after
888e378da2, coredumps for system services are
stored by systemd-coredump user. Hence, _UID=0 does not match anything anymore.

When we are reading the system journal, let's set _UID=<systemd-coredump>,
then we can show coredumps for system services again. When we are reading
an external journal, then the uid of systemd-coredump may be different
from the one on the current system, so let's drop the filter condition
for _UID= in that case.
2024-12-09 15:18:55 +01:00
Ryan Wilson 6746f28854 core: Migrate ProtectHostname to use enum vs boolean
Migrating ProtectHostname to enum will set the stage for adding more
properties like ProtectHostname=private in future commits.

In addition, we add PrivateHostnameEx property to dbus API which uses
string instead of boolean.
2024-12-06 13:33:49 -08:00
Zbigniew Jędrzejewski-Szmek 560412148f Revert "journalctl: show coredumps again when --unit= is specified"
This reverts commit cbd5f5d7d6.
2024-12-07 02:21:51 +09:00
Yu Watanabe cbd5f5d7d6 journalctl: show coredumps again when --unit= is specified
This effectively reverts fdcd37df3b.

After 888e378da2, coredumps for system
services are stored by systemd-coredump user. Henve, _UID=0 does not
match anything anymore.

Before:
```
$ build/journalctl -u systemd-networkd.service -p2 -n1
-- No entries --
```

After:
```
$ build/journalctl -u systemd-networkd.service -p2 -n1
Dec 06 05:39:55 H systemd-coredump[4187]: [🡕] Process 4145 (systemd-network) of user 192 dumped core.
(snip)
```
2024-12-06 09:56:09 +00:00
Daan De Meyer 900ac3a76a ci: Implement coverage on top of mkosi (#35407) 2024-12-05 10:47:45 +01:00
Daan De Meyer eb11048744 creds-util: Improve one log message 2024-12-04 11:12:50 +01:00
Zbigniew Jędrzejewski-Szmek 444e9ba660 shared/tests: adjust error messages
Grammar is improved a bit and some messages are shortened.
2024-12-03 14:30:01 +01:00
Mike Yuan 9a1276e0a2 shared/bootspec: mark _to_string funcs as _const_
Addresses https://github.com/systemd/systemd/pull/34959#discussion_r1860451777
2024-11-27 14:49:09 +01:00
Mike Yuan 992852e24c shared/bootspec: use FOREACH_ELEMENT where appropriate, avoid unneeded memzero() 2024-11-27 14:49:08 +01:00
Mike Yuan 7d93fa7099 shared/bootspec: move boot_entry_addons_done() up, drop separate prototype
Follow-up for e2501a851e
2024-11-27 14:49:04 +01:00
Adrian Vovk f2751d757f bootspec: Look at /loader/addons in XBOOTLDR
The bootspec util-lib's handling of global addons didn't previously
match the behavior of sd-stub, and this commit corrects that.

First, bootspec didn't load global addons from the XBOOTLDR dir, but the
stub does. So, bootspec now enumerates addons in XBOOTLDR, not just ESP

Second, the stub only loads resources (including addons) from the
partition that it was found on. Thus, we must keep track of which
partition the global addons come from, and which partition each boot
entry comes from. In other words: global addons found on the ESP will
NOT apply to UKIs found in XBOOTLDR, and bootspec now reflects that.
2024-11-26 22:25:29 -05:00
Adrian Vovk ef370a3c30 bootspec: Fixup loading of local addons for UKIs
Follow-up for 59b3df9
2024-11-26 16:33:11 -05:00
Adrian Vovk e2501a851e bootspec: Fixup memory leak
This would previously leak memory: the array was deleted but contents
inside of the array were not
2024-11-26 16:33:10 -05:00
Luca Boccassi c4d7a13c06 cryptsetup: convert pkcs11/fido2 to iovec for key handling
key-data might be NULL. Fixes crash:

0  0x0000559c62120530 in attach_luks_or_plain_or_bitlk (cd=0x559c6b192830, name=0x7ffd57981dc4 "root", token_type=TOKEN_FIDO2, key_file=0x0, key_data=0x0, passwords=0x0, flags=524296, until=0)
    at ../src/cryptsetup/cryptsetup.c:2234
        pass_volume_key = false
        r = 1469577760
        __func__ = '\000' <repeats 29 times>
1  0x0000559c6212279c in run (argc=6, argv=0x7ffd5797fe98) at ../src/cryptsetup/cryptsetup.c:2597
        discovered_key_data = {iov_base = 0x0, iov_len = 0}
        key_data = 0x0
        token_type = TOKEN_FIDO2
        destroy_key_file = 0x0
        flags = 524296
        until = 0
        passphrase_type = PASSPHRASE_NONE
        volume = 0x7ffd57981dc4 "root"
        source = 0x7ffd57981dc9 "/dev/disk/by-uuid/8372fb39-9ba4-461a-a618-07dcaae66280"
        status = CRYPT_INACTIVE
        tries = 0
        key_file = 0x0
        config = 0x7ffd57981e05 "luks,discard,fido2-device=auto,x-initrd.attach"
        use_cached_passphrase = true
        try_discover_key = true
        discovered_key_fn = 0x7ffd5797fa70 "root.key"
        passwords = 0x0
        cd = 0x559c6b192830
        verb = 0x7ffd57981dbd "attach"
        r = 0
        __func__ = "\000\000\000"
2  0x0000559c621231e6 in main (argc=6, argv=0x7ffd5797fe98) at ../src/cryptsetup/cryptsetup.c:2674
        r = 32553
        __func__ = "\000\000\000\000"

Follow-up for 53b6c99018
2024-11-26 22:04:24 +09:00
Antonio Alvarez Feijoo 9ed090230e tpm2-util: fix parameter name 2024-11-22 16:04:16 +01:00
Lennart Poettering f6793bbcf0 killall: gracefully handle processes inserted into containers via nsenter -a
"nsenter -a" doesn't migrate the specified process into the target
cgroup (it really should). Thus the cgroup will remain in a cgroup
that is (due to cgroup ns) outside our visibility. The kernel will
report the cgroup path of such cgroups as starting with "/../". Detect
that and print a reasonably error message instead of trying to resolve
that.
2024-11-20 18:11:38 +00:00
Lennart Poettering ebe37f771c user-record: distinguish explicit and implicit empty modifiable lists case
We now distinguish two cases: where the list of self modifiable fields
is explicitly set to empty, and where the default is empty.

Let's display them differently in the output. When set explicitly to
empty let's mention the admin, otherwise just say "none".
2024-11-19 10:15:42 +01:00
Lennart Poettering ac8e381e26 user-record: only synthesize default list of self-modifiable fields for *regular* users
For system users we should lock things down, hence generate an empty
list.

This is mostly a safety precaution, but also hides really confusing
output of "userdbctl user" for an system user.

Follow-up for: a192250eda
2024-11-19 10:15:40 +01:00
Mike Yuan 7eaf5ded61 async: block SIGTERM in asynchronous_rm_rf()
See justifications at https://github.com/systemd/systemd/pull/32235#issuecomment-2062327783
2024-11-14 12:21:25 +00:00