Commit Graph

49199 Commits

Author SHA1 Message Date
Luca Boccassi
da77ea5c63 Merge pull request #32523 from cgzones/inaccessible_label
shared: create inaccessible files with correct security label
2024-04-30 16:20:49 +02:00
Daan De Meyer
123450e58e journal: Add journal.storage credential
In mkosi CI, we want persistent journals when running interactively
and runtime journals when running in CI, so let's add a credential
that allows us to configure which one to use.
2024-04-30 14:19:55 +02:00
Yu Watanabe
8719a65003 test-journal-flush: use archived journal if possible
Workaround for #32436.

The test may fail if the journal is vacuumed or rotated during the test is running.
Let's use the newest archive file for safety.
2024-04-30 10:50:43 +02:00
Daan De Meyer
132f6cfcfe machine: Add PIDFDs= fallback
In some environments, systemd-machined might not be restarted on
downgrade. For safety, let's add the usual PIDFDs= fallback here
as well.
2024-04-29 22:56:49 +02:00
Ronan Pigott
d840783db5 resolved: always progress DS queries
If we request a DS and the resolver offers an unsigned SOA, a new
auxiliary transaction for the DS will be rejected as a loop, and we
might not make any progress toward finding the DS we need. Let's ensure
that we at least always check the parent in this case.

Fixes: 47690634f1 ("resolved: don't request the SOA for every dns label")
2024-04-29 19:04:11 +02:00
Christian Göttsche
b9a05e860c shared: create inaccessible files with correct security label 2024-04-29 18:17:46 +02:00
Christian Göttsche
4be62f821c basic: add open_mkdir_at_full()
Add helper for open_mkdir_at() which accepts xopen flags, e.g. to pass
XO_LABEL to create the target with the correct security context.
2024-04-29 18:16:58 +02:00
Christian Göttsche
22b768d127 basic: add mknodat_label()
Add helper for mknodat(2) which creates the destination with the correct
security label.
2024-04-29 18:14:41 +02:00
Mike Yuan
f193fcbce9 Merge pull request #32547 from YHNdnzj/minor-cleanup
Some cleanups prompted during review
2024-04-29 21:08:06 +08:00
Antonio Alvarez Feijoo
c355b6af19 boot: fix argument name mismatch in two functions 2024-04-29 14:34:37 +02:00
Daan De Meyer
7a66f21556 core: Add systemd.crash_action= kernel command line argument
Required for integration tests to power off on PID 1 crashes. We
deprecate systemd.crash_reboot and related options by removing them
from the documentation but still parsing them.
2024-04-29 14:34:22 +02:00
Mike Yuan
821bf13b6e journalctl: also check arg_file_stdin with other journal location
options

Prompted by #32491
2024-04-29 14:18:38 +02:00
Daan De Meyer
ba4c69a0c6 core: Pass NULL error in dump_impl()
If mac_selinux_access_check() or bus_verify_bypass_dump_ratelimit_async()
fail, we goto "ratelimited" where we set a custom D-BUS error. In
"ratelimited", we call sd_bus_error_setf() which eventually hits an
assert_return(!bus_error_is_dirty()). Avoid hitting this assertion by
passing NULL as the error to mac_selinux_access_check() and
bus_verify_bypass_dump_ratelimit_async() since we will override the error
immediately anyway if either fails.

We modify both functions as well to allow passing a NULL error and fix
the argument name as well while we're at it.
2024-04-29 14:14:40 +02:00
Daan De Meyer
4eae58b3d3 pam: Setup logging to syslog
We already log to syslog using pam_syslog() for logs generated directly
within our pam plugins. However, any logs generated by our generic logging
macros that are invoked within a pam plugin will log to the console. Let's
make sure our generic logging macros are set up to log to syslog as well.
2024-04-29 12:17:18 +02:00
Mike Yuan
f0fb294369 fs-util: modernize touch_file a bit 2024-04-29 16:33:17 +08:00
Mike Yuan
973464ad0e fs-util: try AT_EMPTY_PATH first for futimens_opath 2024-04-29 16:33:17 +08:00
Mike Yuan
cce82462a1 efivars: drop unneeded UTIME_NOW
futimens(2) defaults to current time if 'times' is NULL.
2024-04-29 16:33:17 +08:00
Mike Yuan
767d817895 pam_systemd_loadkey: add missing PAM_EXTERN 2024-04-29 16:33:17 +08:00
Mike Yuan
39a8ef05cd various: drop unnecessary DISABLE_WARNING_FORMAT_NONLITERAL
We use _printf_ for these functions, so there shouldn't
be a warning in the first place.
2024-04-28 13:33:17 +02:00
Sebastian Pucilowski
e6c4b5dc52 network: DHCP version logging typos
Some DHCP client log messages report "DHCP4" or "DHCP6" instead of
"DHCPv4" or "DHCPv6" as used within the rest of the codebase. Typos
fixed.
2024-04-28 11:47:55 +09:00
Luca Boccassi
ff30e7e3af Merge pull request #32520 from YHNdnzj/sd-daemon-followup
sd-daemon: minor cleanup and follow-up
2024-04-27 15:22:35 +02:00
Mike Yuan
119bc912a8 Merge pull request #32516 from YHNdnzj/core-cleanup
core: several cleanups
2024-04-27 19:43:27 +08:00
Mike Yuan
3baab23b25 sd-daemon: downgrade log level for library code, use correct errno
Follow-up for 13b67b61b3
2024-04-27 19:38:16 +08:00
Mike Yuan
3e9fcc2163 sd-daemon: minor modernization, use assert_return 2024-04-27 19:26:49 +08:00
Dmitry V. Levin
c309b9e9c3 treewide: fix a few typos in NEWS, docs, comments, and log messages 2024-04-27 12:11:13 +02:00
Mike Yuan
66825795b4 core/namespace: modernize mount_private_dev 2024-04-27 17:23:18 +08:00
Mike Yuan
6117dda8de core/namespace: modernize clone_device_node 2024-04-27 17:14:03 +08:00
Luca Boccassi
ec361ea9ce Fix spelling errors found by Lintian 2024-04-27 10:58:35 +02:00
Mike Yuan
16871b608e core/namespace: use FOREACH_ARRAY at one more place 2024-04-27 14:30:29 +08:00
Mike Yuan
0afd4d214f core/execute: switch mount_apivfs to tristate
No functional change, just refactoring.
2024-04-27 14:30:29 +08:00
Mike Yuan
b0c49dbcd7 core/manager-serialize: deserialize handoff-timestamp fds
Follow-up for 817062e621

Fixes #32512
2024-04-27 14:30:29 +08:00
Mike Yuan
0541d2959a core: use close_and_replace more when deserializing
Addresses https://github.com/systemd/systemd/pull/32441#discussion_r1579149873
2024-04-27 14:30:28 +08:00
Mike Yuan
00dc018fa6 core/load-fragment: add one missing assertion 2024-04-27 14:28:53 +08:00
Luca Boccassi
89d53001da Merge pull request #32504 from bluca/test_failure
test: do not fail if mknod() fails in a build system
2024-04-26 19:55:24 +02:00
Luca Boccassi
e86e9ebf60 test: modernize test-dirent-util
Follow-up for 6a57d86bf9
2024-04-26 17:20:04 +01:00
Luca Boccassi
7d967aacce test: do not fail if mknod() fails in a build system
mknod fails in a Salsa container when building Debian packages, skip the check

Follow-up for 6a57d86bf9
2024-04-26 17:20:04 +01:00
Frantisek Sumsal
6a68270c97 import: skip the whole subdir when building with -Dimportd=false
Resolves: #32501
2024-04-26 17:14:07 +02:00
Frantisek Sumsal
fea14ca15e mountfsd: drop explicit dependencies for systemd-mountwork
As the executables are automagically linked against libshared.
2024-04-26 17:14:07 +02:00
Daan De Meyer
13b67b61b3 sd-daemon: Replace SO_LINGER with shutdown() + recv()
Let's shutdown the write end and wait for EOF from the other side
before continuing to make sure that the receiver has received all
data we sent on the socket.
2024-04-26 15:11:38 +02:00
Mike Yuan
01a0896f3c core/exec-invoke: use FOREACH_ARRAY more, drop unnecessary initialization
for some fields
2024-04-26 10:24:39 +08:00
Mike Yuan
e2663cbd39 core/namespace: check error first, add missing assertion 2024-04-26 10:24:38 +08:00
Mike Yuan
a0a09da45e mount-setup: fix typo 2024-04-26 10:24:38 +08:00
Luca Boccassi
ffd8149bc0 sd-radv: remove unnecessary check
in6_addr_prefix_intersect() returns a bool, so the check < 0 is
dead code. Flagged by codeql.

Follow-up for c7c56724a5
2024-04-26 07:03:27 +09:00
Lennart Poettering
b24c384b5d varlink: make errors returned by verify_unix_socket() systematic
Previously, if we encountered a non-socket fd we'd return ENOTSOCK the
first time, but the subsequent times we'd return ENOMEDIUM, due to
caching. Let's make sure we return the same errors all the the time.
2024-04-25 22:17:30 +02:00
Daan De Meyer
74e07b33b0 sd-daemon: Set SO_LINGER on AF_VSOCK notify socket fds
We're still seeing problems in mkosi CI where we lose notify messages
sent over vsock from virtual machines because the virtual machine shuts
down before the socket buffers are flushed.

Let's try setting SO_LINGER on vsock sockets so that the kernel waits
until the buffers are flushed when we close the file descriptor.

To make sure it works, let's get rid of our previous workaround that
sends EXIT_STATUS earlier to reduce the chance of it not arriving.
This way, if it doesn't work, we'll notice it immediately due to CI
failures.
2024-04-25 21:29:34 +02:00
Łukasz Stelmach
e85be4983d Fix _do_log conditions in log_exec_* macros
The expression for calculation of the _do_log values in the log_exec_*
macros need to be the same as the unit_log_level_test() function, used
to calculate _do_log in unit.h. The only difference between execute.h
and unit.h is the lack of the Unit structure.

Fixes: b646fc324a ("core: ensure execute/spawn functions can work without Unit object")
Fixes: 210ca71cb5 ("core/execute: clean up log_exec_full_errno and friends")
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
2024-04-25 18:24:36 +02:00
Daan De Meyer
2541f28e4b Merge pull request #32477 from DaanDeMeyer/fixes
Various fixes
2024-04-25 18:24:09 +02:00
Luca Boccassi
8e0bd955fe Merge pull request #32474 from poettering/varlink-no-pidfd
varlink: tweak fallback for SO_PEERPIDFD on old kernels
2024-04-25 17:27:18 +02:00
Luca Boccassi
c929c6a987 Merge pull request #32467 from yuwata/network-radv-cleanup
undefined
2024-04-25 17:10:27 +02:00
Antonio Alvarez Feijoo
5cef6b5393 cryptsetup-tokens: fix pin asserts
If a user only presses ENTER when the PIN is requested (without actually typing
the PIN), an assertion is reached and no other unlock method is requested.

```
sh-5.2# systemctl status systemd-cryptsetup@cr_root
× systemd-cryptsetup@cr_root.service - Cryptography Setup for cr_root
     Loaded: loaded (/etc/crypttab; generated)
    Drop-In: /etc/systemd/system/systemd-cryptsetup@.service.d
             └─pcr-signature.conf
     Active: failed (Result: core-dump) since Thu 2024-04-25 08:44:30 UTC; 10min ago
       Docs: man:crypttab(5)
             man:systemd-cryptsetup-generator(8)
             man:systemd-cryptsetup@.service(8)
    Process: 559 ExecStartPre=/usr/bin/pcr-signature.sh (code=exited, status=0/SUCCESS)
    Process: 604 ExecStart=/usr/bin/systemd-cryptsetup attach cr_root /dev/disk/by-uuid/a8cbd937-6975-4e61-9120-ce5c03138700 none x-initrd.attach,tpm2-device=auto (code=dumped, signal=ABRT)
   Main PID: 604 (code=dumped, signal=ABRT)
        CPU: 19ms

Apr 25 08:44:29 localhost systemd[1]: Starting Cryptography Setup for cr_root...
Apr 25 08:44:30 localhost systemd-cryptsetup[604]: Assertion '!pin || pin_size > 0' failed at src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c:60, function cryptsetup_token_open_pin(). Aborting.
Apr 25 08:44:30 localhost systemd[1]: systemd-cryptsetup@cr_root.service: Main process exited, code=dumped, status=6/ABRT
Apr 25 08:44:30 localhost systemd[1]: systemd-cryptsetup@cr_root.service: Failed with result 'core-dump'.
Apr 25 08:44:30 localhost systemd[1]: Failed to start Cryptography Setup for cr_root.
```

In this case, `cryptsetup_token_open_pin()` receives an empty (non-NULL) `pin`
with `pin_size` equals to 0.

```
🔐 Please enter LUKS2 token PIN:

Breakpoint 3, cryptsetup_token_open_pin (cd=0x5555555744c0, token=0, pin=0x5555555b3cc0 "", pin_size=0, ret_password=0x7fffffffd380,
    ret_password_len=0x7fffffffd378, usrptr=0x0) at ../src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c:42
42	                void *usrptr /* plugin defined parameter passed to crypt_activate_by_token*() API */) {
(gdb) continue
Assertion '!pin || pin_size > 0' failed at src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c:60, function cryptsetup_token_open_pin(). Aborting.
```
2024-04-25 17:07:11 +02:00