Commit graph

49615 commits

Author SHA1 Message Date
Yu Watanabe caebda361e cryptsetup: use TPM2_FLAGS_USE_PCRLOCK at one more place
Follow-up for 404aea7815.
2024-05-26 04:29:18 +09:00
Yu Watanabe 3148edb254 journald: always unset flushed flag when the runtime journal is opened
If the runtime journal is opened, we will anyway write journal entries
to the runtime journal, even if the persistent journal is writable.
Hence, we need to flush the runtime journal file later.
2024-05-26 03:11:24 +09:00
Yu Watanabe 349fa06134 journald: log removal of runtime journal directories 2024-05-26 03:11:24 +09:00
Yu Watanabe 672a9ac7d0 journald: close runtime journal earlier
Then, we can use SD_JOURNAL_ASSUME_IMMUTABLE flag, and the performance
of reading runtime journal should be improved.
2024-05-26 03:11:14 +09:00
Yu Watanabe d2a11fd3ff machine-id-setup: update comment
If an initrd has an empty or uninitialized /etc/machine-id file,
then PID1 write a valid machine ID. So, the logic is important only on
soft-reboot. Let's mention that explicitly.

Follow-up for 16718dcf78.
2024-05-25 02:13:22 +09:00
Yu Watanabe 9ab78ad109 machine-id-setup: use isempty() instead of empty_or_root()
This effectively reverts ba540e9f1c.

https://github.com/systemd/systemd/pull/32915#discussion_r1608258136
> In many cases we allow --root=/ as a mechanism for forcing an "offline" mode,
> while still operating on the root dir. if we do the getenv_for_pid() thing
> below I'd claim this is very much an "online" operation, and hence --root=/
> should really disable that.
2024-05-25 01:45:10 +09:00
Luca Boccassi e67129e5e4
Merge pull request #32994 from keszybz/kernel-install-parsing
Improve parsing of kernel/install.conf
2024-05-24 11:25:26 +02:00
Zbigniew Jędrzejewski-Szmek 600a7405a9 shared/conf-parser: do not print "(null)" as section name
Before:
/etc/kernel/install.conf:6: Unknown key name 'asdf' in section '(null)', ignoring.
After:
/etc/kernel/install.conf:6: Unknown key 'asdf', ignoring.

Also make the message a bit better.
2024-05-23 16:15:24 +02:00
Zbigniew Jędrzejewski-Szmek 3f5196ffb8 kernel-install,bootctl: unify the config parsing procedure
Fixes https://github.com/systemd/systemd/issues/32992.
2024-05-23 16:15:24 +02:00
Lennart Poettering b3efb67ddc tpm2-util: improve compat with older unlocking tools
Let's only generate the pin and pcrlock booleans if they are enabled, in
order to not unnecessarily confuse older unlocking tools.
2024-05-23 15:38:37 +02:00
Lennart Poettering 360198efc3 tpm2-util: do not serialize tpm2 bank if none is specified
If both literal and signed PCR bindings are not used then we won't
determine a PCR bank to use, and hence we shouldnt attempt to serialize
it either.

Hence, if the bank is zero, skip serialization.

(And while we are at it, also skip serialization of the primary
algorithm if not set, purely to make things systematic).

[This effectively results in little change, as previously we'd then
seralize a json "null", while now we simply won't genreate the field]
2024-05-23 15:38:37 +02:00
Lennart Poettering 96bf8aa051 cryptenroll: explicitly pick PCR bank if literal PCR binding is off, but signed PCR binding is on
We so far derived the PCR bank to use from the PCR values specified fr
literal PCR binding. However, when that's not used then we left the bank
uninitialized – which will break if signed PCR binds are used (where we
need to pick a bank too after all).

Hence, let's explicitly pick a bank to use if literal PCR values are not
used, to make things just work.

Fixes: #32946
2024-05-23 13:53:22 +02:00
Christian Göttsche 9fb2db89e3 sd-bus: close peer pidfd
Do not leak the pidfd of the peer.

Fixes: 71be64064c ("sd-bus: add pidfd to the sd_bus_creds structure")
2024-05-22 22:08:44 +02:00
Lennart Poettering f5faf4ec5b varlinkctl: when operating in --more mode, fail correcly on Varlink method error
In varlink.c we generally do not make failing callback functions fatal,
since that should be up to the app. Hence, in case of varlinkctl (where
we want failures to be fatal), make sure to propagate the error back
explicitly.

Before this change a failing call to "varlinkctl --more call …" would result in
a zero exit code. With this it will correctly exit with a non-zero exit
code.
2024-05-22 22:08:28 +02:00
Yu Watanabe a925620f5f sd-ndisc: do not print "(null)" in the log message
If we received RA with no flags set, or with an invalid preference,
previously "(null)" was printed.

Follow-up for 238ed432c3.

Fixes https://github.com/systemd/systemd/pull/32308#discussion_r1600940289.
2024-05-22 22:07:58 +02:00
Luca Boccassi 6ab21f20bd test: do not fail network namespace test with permission issues
When running in LXC with AppArmor we'll most likely get an error when creating
a network namespace due to a kernel regression in < v6.2 affecting AppArmor,
resulting in denials. Like other tests, avoid failing in case of permission
issues and handle it gracefully.
2024-05-22 16:51:38 +01:00
Luca Boccassi 06384eb3c5 lock-util: do not expect EACCES when it cannot happen
As per the documentation, EACCES is only returned when F_SETLK is
used, and only on some platforms, which doesn't seem to include
Linux:

https://github.com/torvalds/linux/blob/master/fs/locks.c

F_OFD_SETLK is documented to only return EAGAIN, and F_SETLKW/F_OFD_SETLKW
are blocking operations so this logic doesn't apply to them in the
first place.

Hence, only automatically convert EACCES into EAGAIN for F_SETLK
operations, and propagate the original error in the other cases.

This is important because in some cases we catch permission errors
and gracefully fallback, which is not possible if the original error
is lost.

This is an issue in practice because, due to a kernel bug present
before v6.2, AppArmor denies locking on file descriptors to LXC
containers. We support all currently maintained LTS kernels,
including v6.1, where despite a lot of effort and attempts over almost
a year, the bugfix still hasn't been backported, as it is complex and
requires large changes to AppArmor.
On affected kernels, all services running with PrivateNetwork=yes
fail and do not recover, instead of the normal behaviour of gracefully
downgrading to PrivateNetwork=no.

The integration tests in the Debian CI fail due to this issue:

https://ci.debian.net/packages/s/systemd/testing/arm64/46828037/
2024-05-22 13:25:44 +01:00
Zbigniew Jędrzejewski-Szmek ab0137b44a shared/btrfs-util: simplify return conditions
Coverity has trouble undertanding this function, so let's get rid of the
redundant return branch to simplify the code.
2024-05-22 13:55:45 +02:00
Mike Yuan f781292d6c
core/service: try to query for new main process's starttime
Currently, when service_set_main_pidref() is called
without specifying start_timestamp, exec_status_start()
always uses dual_timestamp_now(). This is not ideal,
though, as when the main pid changes halfway due to
e.g. sd_notify + MAINPID=, it's definitely spurious.
2024-05-22 19:03:13 +08:00
Mike Yuan 6fb97a85c7
process-util: make pid*_get_start_time return usec_t 2024-05-22 18:47:16 +08:00
Zbigniew Jędrzejewski-Szmek cbd8fc859a core: simplify variable declaration
It doesn't matter much, but right below there is a second declaration
which already uses this style, and the mismatch was grating.
2024-05-22 11:55:26 +02:00
Zbigniew Jędrzejewski-Szmek 4f43cbe66c nspawn: use FOREACH_ARRAY() in one more place 2024-05-22 11:55:26 +02:00
Luca Boccassi 5e30e6e281 btrfs-util: add assert to fix Coverity warning
Coverity gets confused since the iterator change, so add an
assert to indicate that this is allocated if n_old_groups is > 0

CID#1545922

Follow-up for 125cca1b51
2024-05-21 22:17:09 +02:00
Luca Boccassi 27b5ac39d1
Merge pull request #32954 from YHNdnzj/run-forwarder-exit
run: when disconnected from PTY forwarder, exit event loop if not --wait
2024-05-21 20:37:17 +02:00
Mike Yuan c675851d5f
fs-util: try AT_EMPTY_PATH for access_fd() first 2024-05-22 00:50:44 +08:00
Mike Yuan 94d94f0c0a
fs-util: if /proc/ is mounted, return -EBADF when appropriate for link_fd() 2024-05-22 00:50:44 +08:00
Mike Yuan d19b3c5d99
fd-util: introduce proc_fd_enoent_errno helper
Currently, if proc_mounted() != 0, some functions
propagate -ENOENT while others return -EBADF.
Let's make things consistent, by introducing
a static inline helper responsible for finding out
the appropriate errno.
2024-05-22 00:50:44 +08:00
Mike Yuan 69baf0cb91
fs-util: use RET_GATHER at one more place 2024-05-22 00:48:51 +08:00
Mike Yuan 6548f0dab1
fs-util: add missing assertions 2024-05-22 00:48:51 +08:00
Mike Yuan 88873231c8
mountpoint-util: add missing assertions, make mount_fd static 2024-05-22 00:48:51 +08:00
Zbigniew Jędrzejewski-Szmek 9280b08664 logind: use SD_BUS_ERROR_ACCESS_DENIED
As requested in post-merge review
https://github.com/systemd/systemd/pull/32869#pullrequestreview-2068161094:
> NotInControl error is really about session controllers, but this here really
> is different.
2024-05-21 18:32:36 +02:00
Mike Yuan 2b4a691c32
run: when disconnected from PTY forwarder, exit event loop if not --wait
Follow-up for ade0789fab

The change in behavior was partly intentional, as I think
if both --wait and --pty are used, manually disconnecting
from PTY forwarder should not result in systemd-run exiting
with "Finished with ..." log. But we should check for
--wait here.

Closes #32953
2024-05-21 21:30:32 +08:00
Mike Yuan d735753256
ptyfwd: add missing assertions for pty_forward_new 2024-05-21 21:30:32 +08:00
Zbigniew Jędrzejewski-Szmek 055b465a3f shared/mountpoint-util: for old kernels, assume "norecovery" is supported by btrfs
Fixup for e3828d7103, as requested in
https://github.com/systemd/systemd/pull/32892#issuecomment-2117903328.
2024-05-21 15:13:42 +02:00
Zbigniew Jędrzejewski-Szmek 72192b6cc9
Merge pull request #32869 from keszybz/dbus-release-session
Allow pam stack to call ReleaseSession
2024-05-21 09:01:17 +02:00
Mike Yuan f2c2fa87b6
shutdown: rename initrd to exitrd
Nowadays the tmpfs where the final shutdown phase
is initiated has got its own name.
Plus, "Returning to initrd" sounds spurious anyway,
as we're not returning to the initial root tmpfs
as seen by the kernel.
2024-05-21 11:39:57 +08:00
Mike Yuan a2d4451e64
shutdown: don't freeze() if not executed by pid1 2024-05-21 11:39:29 +08:00
Mike Yuan 2e4da5e08c
shutdown: use execl where appropriate 2024-05-21 11:39:28 +08:00
Mike Yuan 4fbe2bfc51
shutdown: downgrade log level of ignored errors to warning 2024-05-21 11:39:28 +08:00
Mike Yuan 942b2f3b84
shutdown: explicitly initialize static variables, make arg_verb const 2024-05-21 11:39:28 +08:00
Yu Watanabe f8ef1df3d1 test: extend timeout for DHCP/NDisc tests
Fixes https://github.com/systemd/systemd/pull/32932#issuecomment-2120424121.
2024-05-20 22:55:07 +02:00
Yu Watanabe 125cca1b51 btrfs-util: check current offset before read
Fixes #32936.
2024-05-20 22:53:14 +02:00
Zbigniew Jędrzejewski-Szmek fc0bb7ccc7 logind: make ReleaseSession "unprivileged" and allow closing of own session
Fixes https://github.com/systemd/systemd/issues/28514.

Quoting https://github.com/systemd/systemd/issues/28514#issuecomment-1831781486:
> Whenever PAM is enabled for a service, we set up the PAM session and then
> fork off a process whose only job is to eventually close the PAM session when
> the service dies. That services we run with service privileges, both to
> minimize attack surface and because we want to use PR_SET_DEATHSIG to be get
> a notification via signal whenever the main process dies. But that only works
> if we have the same credentials as that main process.
>
> Now, if pam_systemd runs inside the PAM stack (which it normally does) it's
> session close hook will ask logind to synchronously end the session via a bus
> call. Currently that call is not accessible to unprivileged clients. And
> that's the part we need to relax: allow users to end their own sessions.

The check is implemented in a way that allows the kill if the sender is in
the target session.

I found 'sudo systemctl --user -M "zbyszek@" is-system-running' to
be a convenient reproducer.

Before:
May 16 16:25:26 x1c systemd[1]: run-u24754.service: Deactivated successfully.
May 16 16:25:26 x1c dbus-broker[1489]: A security policy denied :1.24757 to send method call /org/freedesktop/login1:org.freedesktop.login1.Manager.ReleaseSession to org.freedesktop.login1.
May 16 16:25:26 x1c (sd-pam)[3036470]: pam_systemd(login:session): Failed to release session: Access denied
May 16 16:25:26 x1c systemd[1]: Stopping session-114.scope...
May 16 16:25:26 x1c systemd[1]: session-114.scope: Deactivated successfully.
May 16 16:25:26 x1c systemd[1]: Stopped session-114.scope.
May 16 16:25:26 x1c systemd[1]: session-c151.scope: Deactivated successfully.
May 16 16:25:26 x1c systemd-logind[1513]: Session c151 logged out. Waiting for processes to exit.
May 16 16:25:26 x1c systemd-logind[1513]: Removed session c151.
After:
May 16 17:02:15 x1c systemd[1]: run-u24770.service: Deactivated successfully.
May 16 17:02:15 x1c systemd[1]: Stopping session-115.scope...
May 16 17:02:15 x1c systemd[1]: session-c153.scope: Deactivated successfully.
May 16 17:02:15 x1c systemd[1]: session-115.scope: Deactivated successfully.
May 16 17:02:15 x1c systemd[1]: Stopped session-115.scope.
May 16 17:02:15 x1c systemd-logind[1513]: Session c153 logged out. Waiting for processes to exit.
May 16 17:02:15 x1c systemd-logind[1513]: Removed session c153.

Edit: this seems to also fix https://github.com/systemd/systemd/issues/8598.
It seems that with the call to ReleaseSession, we wait for the pam session
close hooks to finish. I inserted a 'sleep(10)' after the call to ReleaseSession
in pam_systemd, and things block on that, nothing is killed prematurely.
2024-05-20 20:59:15 +02:00
Zbigniew Jędrzejewski-Szmek 337f74d7c0 logind: group policy entries by interface 2024-05-20 20:59:15 +02:00
Zbigniew Jędrzejewski-Szmek 1d640a044f analyze: do not print timestamps before "start of userspace"
We have the following timestamp status:

  $ systemctl show systemd-fsck-root.service | grep InactiveExitTimestamp
  InactiveExitTimestamp=Thu 2023-11-02 12:27:24 CET
  InactiveExitTimestampMonotonic=15143158

  $ systemctl show | grep UserspaceTimestamp
  UserspaceTimestamp=Thu 2023-11-02 12:27:25 CET
  UserspaceTimestampMonotonic=15804273

i.e. UserspaceTimestamp is before InactiveExit of systemd-fsck-root.service.
This is fine, but on display, we'd subtract those values and print a huge
negative value bogusly:

  $ build/systemd-analyze critical-chain systemd-remount-fs.service
  The time when unit became active or started is printed after the "@" character.
  The time the unit took to start is printed after the "+" character.

  systemd-remount-fs.service +137ms
  └─systemd-fsck-root.service @584542y 2w 2d 20h 1min 48.890s +45ms
    └─systemd-journald.socket
      └─system.slice
        └─-.slice

In fact, list_dependencies_print() already had a branch where the check that
'times->activating > boot->userspace_time', but it didn't cover all cases. So
make it cover both branches, and also change to '>=', since it's fine if
something happened with the same timestamp.

With the patch:

  $ build/systemd-analyze critical-chain systemd-remount-fs.service
  The time when unit became active or started is printed after the "@" character.
  The time the unit took to start is printed after the "+" character.

  systemd-remount-fs.service +42ms
  └─systemd-fsck-root.service
    └─systemd-journald.socket
      └─system.slice
        └─-.slice

Fixes https://github.com/systemd/systemd/issues/17191.
2024-05-20 18:31:32 +02:00
Luca Boccassi eb56b564a0 logind: do not fail creating a session when request is not from a unit
When running inside an LXC container the 'su' process will not be part of
any unit or slice.

manager_get_user_by_pid() which was used until v255 (included) does not fail
if it cannot find a unit/slice, but simply returns 'not found'. Do the same
in manager_get_session_by_pidref().

This was not detected as Semaphore CI does not reboot the testbed before
the logind test, so the session is started by the old logind from the base
distro, instead of the one being tested.

Follow-up for 8494f562c8
Follow-up for 5099a50d43

Fixes https://github.com/systemd/systemd/issues/32929
2024-05-20 13:14:50 +01:00
Luca Boccassi c275e01d99 logind: add one more debug log
Helped track down issue with session tracking
2024-05-20 13:14:50 +01:00
Luca Boccassi eb0c2da89e
Merge pull request #32915 from yuwata/machine-id-setup
machine-id-setup: acquire machine ID from /run/machine-id if possible
2024-05-20 00:16:16 +02:00
Yu Watanabe 16718dcf78 machine-id-setup: acquire machine ID from /run/machine-id if possible
If machine ID is previously stored at /run/machine-id, then let's reuse
it. This is important on switching root and /etc/machine-id was previously
a mount point.

Fixes #32908.
2024-05-20 02:17:57 +09:00
Yu Watanabe ba540e9f1c machine-id-setup: use empty_or_root() 2024-05-20 01:05:23 +09:00
Yu Watanabe 3b1b2d4e3d machine: fix use-after-free in Rename() DBus method
Fixes a bug introduced by 1ddb263d21.

Note, this requires the previous two commits, and cannot backport without them.

Note, before the previous commit, the use-after-free could be triggered
only by Rename() DBus method, and could not by RenameImage(), as we did not
cache Image object when RenameImage() method is called. And machinectl
always uses RenameImage(). Hence, the issue could be triggered only when
Rename() DBus method is explicitly called by e.g. busctl.

With the previous commit, the Image object passed to the function is
always cached. Hence, the issue could be triggered even with machinectl
command, and this fix is important.
2024-05-20 01:03:14 +09:00
Yu Watanabe c6aeb9b596 machine: also acquire Image object from cache when a dbus method in the main interface is called
Previously, Image objects were only cached when reading properties or
methods in the org.freedesktop.machine1.Image interface are called.

This makes that, when a method in the main interface (org.freedesktop.machine1)
for an image is called, also acquire the Image object from the cache,
and if not cached, create Image object and put into the cache, like we
do for org.freedesktop.machine1.Image.

Otherwise, if some properties of an image are updated by methods in the main
interface, e.g. MarkImageReadOnly(), the changes do not applied to the cached
Image object, and subsequent read of proerties through the interface for the
image, e.g. ReadOnly property, may provide outdated values.

Follow-up for 1ddb263d21.

Fixes #32888.
2024-05-20 01:03:14 +09:00
Yu Watanabe 6d917da140 machine: split out manager_acquire_image() from image_object_find()
Preparation for the next commit. No functional change.
2024-05-20 01:03:14 +09:00
Yu Watanabe 96ac6d3fcc discover-image: also update Image.limit in image_set_limit()
Same as the previous commit, but for SetLimit DBus method vs Limit
property and friends.
2024-05-20 01:03:14 +09:00
Yu Watanabe 608c321f23 discover-image: update Image.read_only flag in image_read_only()
Otherwise, ReadOnly DBus property in org.freedesktop.machine1.Image or
org.freedesktop.portable1.Image will not be updated by MarkReadOnly DBus
method.
2024-05-20 01:03:14 +09:00
Mike Yuan 28459ba1f4
run: pass the pty slave fd to transient service
The rationale is similar to 40e1f4ea74.

Currently, we only pass TTYPath=/dev/pts/... to
the transient service spawned by systemd-run.
This is a bit problematic though, when ExecStartPre=
or ExecStopPost= is used. Since when these control
processes get to run, the main process is not yet
started/has already exited, hence the slave suffers
from the same vhangup problem as the mentioned commit.

By passing the slave fd in, the service manager will
hold the fd open as long as the service is alive.

Fixes #32916
2024-05-19 09:18:48 +08:00
Mike Yuan ade0789fab
run: do not log "Error on PTY forwarding logic" when disconnected due to user operation 2024-05-19 09:18:48 +08:00
Mike Yuan 6d2a26a136
vmspawn: use openpt_allocate where appropriate 2024-05-19 09:18:48 +08:00
Mike Yuan 2153899d96
ptyfwd: trivial coding style and log cleanups 2024-05-19 09:18:48 +08:00
Yu Watanabe 762412f2bb
Merge pull request #32902 from yuwata/emergency-action-fixes
several fixes for emergency actions and document update
2024-05-18 16:32:36 +09:00
Yu Watanabe f3c5ea7111 install-file: make fs_make_very_read_only() static 2024-05-17 23:06:48 +02:00
Yu Watanabe 2a2d9539f0 core: refuse invalid emergency actions for SuccessAction= and friends in user service manager
Especially, soft-reboot is not supported by user service manager.

Fixes a bug in 13ffc60749 and
3cf848f6cd.
2024-05-18 02:51:34 +09:00
Mike Yuan de12b8d163 core/execute: do not use format str for log_object_internal
This reverts part of 210ca71cb5.

Another fallout from that commit...

Fixes #32877
2024-05-17 15:15:21 +02:00
Daan De Meyer e3828d7103 mountpoint-util: Deal with kernel API breakage in "norecovery" mount option
"norecovery" was deprecated for btrfs in
74ef00185e
and removed in
a1912f7121.

Let's drop our assumption that btrfs supports "norecovery" and first query for the
new name of the option followed by querying for the old name.
2024-05-17 14:29:09 +02:00
Yu Watanabe d7769b4d8e network/route: fix unexpected removal of routes for wireguard
Fixes a bug introduced by 8d01e44c1f.

If a .netdev file for a wireguard interface requests to configure
routes for the interface, the routes were removed during configuring
another interface.

Fixes #32859.
2024-05-17 06:40:43 +09:00
Zbigniew Jędrzejewski-Szmek 1cd53a1f91 repart: remove duplicate word in --help
My bad; follow-up for 4955d2e367.
2024-05-16 20:01:08 +02:00
Luca Boccassi aa4644882e
Merge pull request #32863 from YHNdnzj/switch-root-followup
Two minor followups
2024-05-16 15:53:18 +02:00
Daan De Meyer 11b706178c
Merge pull request #32842 from DaanDeMeyer/cryptsetup
test: Enable TEST-24-CRYPTSETUP for mkosi
2024-05-16 15:50:55 +02:00
Daan De Meyer 2540036979 journal-importer: Consider ECONNRESET as EOF
Otherwise we log a noisy error when we get ECONNRESET.
2024-05-16 19:23:56 +08:00
Mike Yuan 4eec099db8
switch-root: update comment regarding dropped mounts
Follow-up for 07c5c2ab8b
2024-05-16 19:18:59 +08:00
Mike Yuan 2599b32e72
fd-util: check and log error properly for fd_reopen_propagate_append_and_position
Follow-up for b8e25bff38
2024-05-16 19:17:25 +08:00
Yu Watanabe 2e93331605 pe-binary: .initrd section is optional for UKI
.osrel is also optional, but sd-boot and bootctl requires it.
So, let's keep .osrel section at least now.

Fixes #32774.
2024-05-16 12:56:22 +02:00
Zbigniew Jędrzejewski-Szmek b3aa88a475
Merge pull request #32800 from YHNdnzj/preserve-cred-mounts
switch-root: preserve the whole cred mount tree (/run/credentials/)
2024-05-16 12:45:40 +02:00
Daan De Meyer 0b6891abf5 repart: Improve error message 2024-05-16 12:34:28 +02:00
Luca Boccassi b410d2dcab
Merge pull request #32857 from dtardon/drop-assert
Drop invalid asserts
2024-05-16 12:04:51 +02:00
Daan De Meyer 452f91d846 core: Skip private /tmp for generators in manager test runs
For manager test runs, the generator output paths are located in
/tmp, which means that if we mount a private /tmp for generators,
we lose all the generated units (actually the generators will just
fail because the directories don't exist, but if they did exist,
we'd still lose all the units).

Let's avoid the problem by skipping the private /tmp for manager
test runs. This also avoids any possible privilege issues with
mounting a private /tmp that might happen in this scenario.
2024-05-16 10:17:00 +02:00
David Tardon 119f22526e journald-server: drop another invalid assert()
config_parse_forward_to_socket() is not used for parsing unit files
either.

Follow-up-for: f31cff849d
2024-05-16 10:10:25 +02:00
David Tardon 2ef7cdc425 journald-server: drop invalid assert()
config_parse_compress() is not used for parsing unit files, hence unit
is always NULL.

Fixes #32856

Follow-up-for: 6813be2eba
2024-05-16 10:10:19 +02:00
Yu Watanabe 60dbecff27 systemctl: fix "applying zero offset to null pointer" UBSan error
Fixes #32837.
2024-05-15 20:24:03 +02:00
Mike Yuan 07c5c2ab8b
switch-root: preserve the whole cred mount tree (/run/credentials/)
Currently, during soft-reboot, some services may survive,
but their associated credential mounts are dropped.
Let's instead preserve them, as discussed.
2024-05-16 00:48:16 +08:00
Luca Boccassi 0403065876
Merge pull request #32844 from YHNdnzj/mount-defaultdep-followup
core/mount: correctly set DefaultDependencies=no for mounts from mountinfo
2024-05-15 18:23:26 +02:00
Luca Boccassi 5de20f5619
Merge pull request #32818 from keszybz/libsystemd-network-size-check
Check packet size in libsystemd-network
2024-05-15 17:33:22 +02:00
Mike Yuan bb5f3e6410
core/mount: correctly set DefaultDependencies=no for mounts from mountinfo
Follow-up for 3c0a1b1e70

Before this commit, DefaultDependencies=no is set in
mount_add_extras(). However, when generating mount units
from /proc/self/mountinfo, we don't have a unit in memory
yet, and mount_setup_new_unit() doesn't call into
mount_add_extras().

Fixes #32838
2024-05-15 22:02:32 +08:00
Mike Yuan bb33c5da87
core/swap: rename variable 'new' -> 'new_unit'
Follow-up for ba31a5018f

'new' is already used as a macro for memory allocation.
Let's avoid the confusion here.

Addresses https://github.com/systemd/systemd/pull/31902#discussion_r1557672858
2024-05-15 21:54:21 +08:00
Daan De Meyer d02a41a9d4 core: Fix assertion in parse_smbios_strings() 2024-05-15 13:30:35 +02:00
Luca Boccassi e0d13e719e
Merge pull request #32830 from yuwata/home-skel
home: fix ownership of files copied from skelton directory
2024-05-15 01:26:15 +02:00
Yu Watanabe 05e64ea45d home: fix ownership of files copied from skelton directory
Fixes #32808.
2024-05-15 06:38:41 +09:00
Zbigniew Jędrzejewski-Szmek e9bdbb6bbc core,vconsole-setup: treat locking failure as non-fatal
Locking of the tty device and then /dev/console was added to synchronize
vconsole-setup with other writers to the console. But it turns out that often
the locking doesn't work and we carved out various cases where we ignore
failure:
- lack of permissions (in the user manager)
- missing device node

It turns out that there's at least one more failure mode: we get -EIO when the
console is (mis-)configured to point to an invalid device. E.g. in
rhbug#2273069 the reporter has a VM in Proxmox without a virtual console
configured and has 'console=tty console=ttyS0' on the kernel cmdline. I
couldn't reproduce this under libvirt, but failure with EIO has been reported
by at least four users in #30501.

Note that in systemd-vconsole-setup we report this is a hard failure, while
in the manager, we only do a debug line. So it's possible that the failure
also occured there, causing the rest of the setup of the tty to be skipped
without further notice.

Ignore the locking failure, since there's just too many ways it can fail. If we
proceed without a lock, we're back to the situation before we started locking,
which wasn't too bad. OTOH, skipping setup of the console is problematic for
users, and it seems better to try to do the setup without locking.

Fixes https://github.com/systemd/systemd/issues/30501,
https://bugzilla.redhat.com/show_bug.cgi?id=2273069.
2024-05-14 23:22:41 +02:00
Luca Boccassi 76fe0035df
Merge pull request #32817 from YHNdnzj/core-varlink
core/core-varlink: trivial cleanups
2024-05-14 22:40:01 +02:00
Luca Boccassi c7bee5b5d2
Merge pull request #32816 from bluca/chores
Chores for RC2
2024-05-14 22:07:40 +02:00
Zbigniew Jędrzejewski-Szmek 1743b8bad1 core/exec-credential: downgrade warning about missing cred to debug
Follow-up for 6b34871f5d.

The general idea is that the list of credentials to load can and will specify
credentials which actually aren't provided, so a warning is too much. Let's
downgrade this to "info". If it turns out to be too noisy, we can downgrade
further in the future.
2024-05-14 20:13:57 +02:00
Zbigniew Jędrzejewski-Szmek 8e41e460e0 test: rename file with stub functions
icmp6-util-linux.c sounds like a specialized implementation of the functions in
icmp6-util.c. But it's just a set of stub versions used in tests. Rename the
file to make this more obvious.
2024-05-14 18:56:41 +02:00
Zbigniew Jędrzejewski-Szmek b17b91db80 libsystemd-network: use normal style for error checking
We generally use a flat list. The switch stmt was generating excessive
indentation.
2024-05-14 18:56:41 +02:00
Zbigniew Jędrzejewski-Szmek caa4bfd468 libsystemd-network: check size of icmpv6 packets
Coverity was complaining that we use the received packet size as a loop bound
without checking. This is indeed a bit iffy, because depending on how the host
is configured, the packet could be rather large. Let's refuse anything more
than the standard size early to prevent suspicious activity.

Resolves coverity CID#1534892, CID#1543949.
2024-05-14 18:56:35 +02:00
Zbigniew Jędrzejewski-Szmek f7a6418d47 libsystemd-network: remove double initialization 2024-05-14 18:55:34 +02:00
Mike Yuan cd711b6ec9
core/varlink: make manager_setup_varlink_server static
Follow-up for 6906c028e8

Also, use correct log level for varlink_server_add_interface_many().
2024-05-15 00:46:06 +08:00
Mike Yuan e28501fee2
core/varlink: use FOREACH_ELEMENT more 2024-05-15 00:44:27 +08:00
Luca Boccassi 93df5217b9 tree-wide: 'allows to' -> 'allows one to'
As flagged by Lintian
2024-05-14 18:33:27 +02:00
Luca Boccassi efcbf3e670 Update syscalls table
ninja -C build update-syscall-tables update-syscall-header
2024-05-14 17:01:08 +01:00
Timo Rothenpieler 00f1714311 cgroup-util: allow cg_read_pid() to skip unmapped (zero) pids 2024-05-14 16:12:20 +02:00
Radoslav Kolev 19614a08d1 libsystemd-network: skip dhcp server test in case of EAFNOSUPPORT
We want to eanble running tests as part of the build, but
our builds run in VMs with networking disabled.
2024-05-14 15:00:29 +02:00
Mike Yuan 2c41722995
Merge pull request #32804 from YHNdnzj/bootspec-modernization
shared/bootspec: some fixes/modernizations
2024-05-14 20:55:52 +08:00
Daan De Meyer 3c0a1b1e70 core: Imply DefaultDependencies=no for credential mounts
Currently, on soft-reboot, /run/credentials/@system is unmounted
because it has DefaultDependencies=yes and as such will have
Conflicts=umount.target and Before=umount.target. Let's make sure
credential mounts survive soft-reboot by implying DefaultDependencies=no
for credential mounts.
2024-05-14 12:42:45 +02:00
Mike Yuan 97dfed142d
shared/bootspec: use FOREACH_ARRAY more 2024-05-14 18:19:19 +08:00
Mike Yuan 4ea554e681
shared/bootspec: use isempty where appropriate 2024-05-14 18:19:19 +08:00
Mike Yuan 94e9ae6f53
shared/bootspec: use path_make_absolute where appropriate 2024-05-14 18:19:19 +08:00
Mike Yuan 73a8d8b0ca
shared/bootspec: inline iterator var
Also, do not bump 'line' until the end of the loop.
Otherwise, log_syntax() below logs about the wrong
line number.
2024-05-14 18:18:48 +08:00
Mike Yuan 19cb99e74a
shared/bootspec: add missing assertions 2024-05-14 18:18:47 +08:00
Radoslav Kolev 381c3b64d0 sd-event: increase test-event timeout to 120s
The test-event test seems to be taking quite a bit more time than
the other 'simple tests', which usually complete in < 1s. In case
of a slower or loaded machine the default 30s timeout is not enough.
2024-05-14 11:34:22 +02:00
Yu Watanabe 171f8d7ba7 dlfcn-util: fix typo
Follow-up for 2f6bd11c1a.
2024-05-14 18:10:46 +09:00
Luca Boccassi c98f2b8167 bootctl: fix crash when parsing addon without .cmdline section
Follow-up for 706ca67d30
2024-05-14 14:50:58 +08:00
Matt Muggeridge 68adffed02 network: IPv6 Compliance RFC4862: Address Lifetime Expiry (Hosts Only) [v6LC.3.2.2]
RFC 4862 Section 5.5.3, bullet e, sub-bullet 3 applies to existing
addresses, i.e. when address_get() returns success. If the address is
new (i.e. address_get() fails), then we should not be adding 2 hours to
the lifetime_valid_usec. Instead, use the valid_lifetime from the RA's
Prefix Information Option.

This change allows v6LC.3.2.2 to pass. Also verified all v6LC3.2.* tests
pass. This covers all the v6LC tests from Group2: Router Advertisement
Processing and Address Lifetime.

Fixes #32652.
2024-05-14 07:08:43 +09:00
Matt Muggeridge 2d393b1b6d
network: IPv6 Compliance: Router Advertisement Processing, Reachable Time [v6LC.2.2.15] (#32792)
Previously, RA option fields were being ignored when the Router Lifetime
value was zero. Remove this logic to be compliant with RFC4861.

Extract from: https://www.ietf.org/rfc/rfc4861.html#section-4.2, p.21,
first paragraph:

    The Router Lifetime applies only to
    the router's usefulness as a default router; it
    does not apply to information contained in other
    message fields or options.

This affected IPv6 Conformance test:
    v6LC.2.2.15: Router Advertisement Processing, Reachable Time.

Fixes #31842.

Co-authored-by: Matt Muggeridge <Matt.Muggeridge@hpe.com>
2024-05-14 06:50:51 +09:00
Lennart Poettering c5ecf09494 curl-glue: catch libcurl attempting to change timeout handler when we destroy a curl context on exit
If we destroy both an event loop and a curl contect object at the same
time, then we get into this weird situation where curl wants us to
reconfigure a timout event source right before destruction, which
sd-event will refuse however, since it is already being shutdown.

Hence, catch that and simply don't bother adjusting the timeout, since
we cannot get back from there anyway.
2024-05-14 05:29:15 +09:00
Lennart Poettering ddbfc4d17e machined: return recognizable error when we try to register the same machine name twice 2024-05-13 12:25:22 -06:00
Mike Yuan d9b8d86bcd core/service: remove unnecessary reset of notify_access_override
This already gets reset in service_enter_dead()
and service_start().
2024-05-14 00:49:59 +08:00
Lennart Poettering 13d6c5de41 varlink: rename vsockCid → vSockCid field 2024-05-14 00:49:45 +08:00
Yu Watanabe 0e2e3fa35a journal-rate-limit: replace in-house management of JournalRateLimitGroup with OrderedHashmap
No functional change, just refactoring.
2024-05-13 19:21:23 +09:00
Yu Watanabe 8df477675d journal-rate-limit: split out journal_ratelimit_group_acquire()
No functional change, just refactoring.
2024-05-12 10:32:14 +09:00
Yu Watanabe bab044b94b journal-rate-limit: introduce cleanup function for JournalRateLimitGroup
This also makes journal_ratelimit_group_new() use structured initializer.
2024-05-12 10:32:14 +09:00
Yu Watanabe 88c434f75c journal-rate-limit: rename variables
'r' is usually used for storing return value.
2024-05-12 10:32:14 +09:00
Yu Watanabe 1bdaad997d journal-rate-limit: use FOREACH_ELEMENT() and usec_add() 2024-05-12 10:32:14 +09:00
Yu Watanabe bba23ba47f journal-rate-limit: make journal_ratelimit_group_free() return NULL
To make it follow our recent coding style.
2024-05-12 10:32:14 +09:00
Yu Watanabe 1cb1538f78 journal-rate-limit: add trailing comma in table 2024-05-12 10:32:14 +09:00
Yu Watanabe 78da0721c8 test: introduce test cases for journal_ratelimit_test() 2024-05-12 10:31:41 +09:00
Yu Watanabe c1db424db5 tree-wide: use LOG_PRI() and LOG_FAC() 2024-05-12 09:49:45 +09:00
Daan De Meyer 82c2214539 debug-generator: Allow specifying name of unit-dropin credential
A fixed name is too rigid, let's give users the ability to define
custom drop-in names which at the same time also allows defining
multiple dropins per unit.

We use ~ as the separator because:
- ':' is not allowed in credential names
- '=' is used to separate credential from value in mkosi's --credential
  argument.
- '-' is commonly used in filenames
- '@' already has meaning as the unit template specifier which might be
  confusing when adding dropins for template units
2024-05-11 19:46:15 +02:00
Yu Watanabe a937fa96ac libcrypt-util: fix wrong errno value assignment
Follow-up for 9de324c3c9.
2024-05-10 15:56:52 +02:00
Luca Boccassi cc65d63d6d
Merge pull request #32747 from YHNdnzj/tmpfiles-ret-gather
tmpfiles: some cleanups/follow-up
2024-05-10 15:04:30 +02:00
Mike Yuan 9bbe26bbf2
Merge pull request #32738 from yuwata/trivial-cleanups
Trivial follow-ups for recent changes
2024-05-10 19:07:42 +08:00
Luca Boccassi cf2b044c5e
Merge pull request #32491 from yuwata/journalctl-fix-boot
journalctl: several fixes and cleanups for --boot= option handling
2024-05-10 13:00:22 +02:00
Mike Yuan c2c162a636
tmpfiles: use RET_GATHER more, add missing assertions
Note that item_do() now aborts on OOM, since it's
pretty pointless to iterate further if memory allocation
doesn't work.
2024-05-10 18:50:05 +08:00
Mike Yuan d8f5a31022
tmpfiles: don't compare errno with negative value
Follow-up for 677430b3c7
2024-05-10 18:50:05 +08:00
Mike Yuan 570c940d42
tmpfiles: clean up hardlinks_vulnerable a bit
dangerous_hardlinks() -> hardlinks_protected(),
and the meaning of the function is now in line
with fs.protected_hardlinks value.

Plus, We ship 50-default.conf where the sysctl
is enabled. Mention it in the comment.
2024-05-10 18:50:05 +08:00
Luca Boccassi 1df2c9a597
Merge pull request #32741 from yuwata/network-dhcp4-route-to-dns
network/dhcp4: fix assignment of routes to DNS or NTP servers
2024-05-10 12:40:30 +02:00
Yu Watanabe 2b699c2362 core/unit: use FOREACH_ELEMENT() to add dependencies for journal namespace instances
Follow-up for 06c0f569e9.
2024-05-10 18:11:25 +09:00
Yu Watanabe 0f3116f039 network/dhcp4: do not set gateway if DNS server or friends is in the acquired prefix
Previously, even if a DNS server is in the acquired prefix, the route to the
server might have gateway address.
This makes the prefix route, which is always configured, is also handled
as same as static routes, and do not use any gateway if the prefix route
is the most suitable route to access the destination.
The same change is also applied to route to NTP servers and semi-static
routes.

Fixes a regression introduced by 0ce86f5eeb.

Fixes #32715.
2024-05-10 13:46:39 +09:00
Yu Watanabe 4591efffc0 test: add basic tests for in_addr_prefix_covers_full() 2024-05-10 13:46:39 +09:00
Yu Watanabe d0936a7266 journalctl: make --list-boots support -n/--lines= option
Also mention that -r/--reverse is supported by the command.
2024-05-10 11:43:57 +09:00
Yu Watanabe 5da5d848f9 journalctl: fail and show error message when no boot ID found
No boot ID in journal should be definitly spurious.
Let's warn about that and exit with failure.
2024-05-10 11:43:57 +09:00
Yu Watanabe 8f2bcb1fb2 logs-show: use GREEDY_REALLOC_APPEND() 2024-05-10 11:43:57 +09:00
Yu Watanabe afcd9c60fe logs-show: fix stored timestamp when advance_older is true
Currently, the parsed timestamp is only used when advance_older is
false. Hence, this does not change any behavior. But, let's fix it anyway.
2024-05-10 11:43:57 +09:00
Yu Watanabe a467515519 journalctl: fix support of --boot=ID±offset format
Fixes a regression introduced by e44f06065b.

After the offending commit, if a boot ID suffixed with an offset is
specified to --boot=, the boot ID was ignored.
This fixes the issue.

To fix the issue, this merges journal_find_boot_by_id() and
journal_find_boot_by_offset().
2024-05-10 11:43:57 +09:00
Yu Watanabe 87dfaba7e9 logs-show: flush matches before and after finding boots
Otherwise, if several matches already set, then the first seek to head
or tail may move the cursor to an invalid place, hence they provide
wrong ID(s). Also, reading journal after calling these function may
provide unexpected data.

Currently, the caller does not install any matches before calling the
functions, and does not read any journal entry after journal_get_boots()
succeeds or journal_find_boot_by_offset() succeeds with 0. Hence, this
should not change any behavior. Just for safety.
2024-05-10 11:43:57 +09:00
Yu Watanabe ae0e6de918 journalctl: fix --boot=0 with --file=- (from stdin)
Follow-up for 592855c318.
2024-05-10 11:43:57 +09:00
Yu Watanabe 781ddf1477 journalctl: split out journal_acquire_boot() from add_boot()
No functional change, just refactoring and prepration for later changes.
2024-05-10 11:43:53 +09:00
Yu Watanabe e8357737c6 vmspawn: fix finding systemd-journal-remote binary
Follow-up for 258d26940f.

Fixes https://github.com/systemd/systemd/pull/31218#discussion_r1596168449.
2024-05-10 11:37:24 +09:00
Yu Watanabe f607dd58bd vmspawn: trivial cleanups for start_systemd_journal_remote()
- prefix argument for storing result with 'ret_',
- align arguments for strv_new().
2024-05-10 11:37:24 +09:00
Yu Watanabe ae1cb17cef core/service: shorten code a bit
Follow-up for 026335e9aa.
2024-05-10 10:12:43 +09:00
Yu Watanabe c876cbdd19 time-util: define TIMESPEC_OMIT
Follow-up for 34c3d57474.
2024-05-10 10:11:06 +09:00
Yu Watanabe fdd325fbb8 journalctl: several cleanups for parse_boot_descriptor()
- rename to parse_id_descriptor(), to make it usable for other kind of
  ID later.
- add missing assertions,
- prefix arguments for storing results with 'ret_',
- drop unnecessary 'else'.
2024-05-10 09:35:24 +09:00
Yu Watanabe 131701d10a logs-show: add missing strempty()
Follow-up for 8e976dc920.
2024-05-10 09:35:24 +09:00
Yu Watanabe 8ac0810f6c logs-show: drop uid argument from add_matches_for_user_units()
It is always equivalent to getuid(). Let's call getuid() in the
function instead.
2024-05-10 09:35:24 +09:00
Florian Fainelli 41a94ae670 basic/linux: Copy netfilter.h to the source tree
This fixes build with old toolchains prior to Linux < 4.2 which do not
have a definition for NFPROTO_NETDEV.
2024-05-09 15:27:23 +02:00
Daan De Meyer 50e0509ccf network: Add missing IPv6AcceptRA to list of config sections 2024-05-09 13:22:42 +02:00
Luca Boccassi 7e10dfae96
Merge pull request #32689 from YHNdnzj/cred-missing
core/exec-credential: complain louder if inherited credential is missing
2024-05-09 13:21:44 +02:00
Mike Yuan d99511add4
core/namespace: take char* const* for strv, use FOREACH_ARRAY 2024-05-09 17:02:19 +08:00
Mike Yuan 63a0e57724
path-util: take char* const* for strv where appropriate 2024-05-09 17:02:19 +08:00
Mike Yuan 7b89efda6f
core/unit: use FOREACH_ARRAY at one more place 2024-05-09 17:02:19 +08:00
Mike Yuan d08070f4e9
core/unit: cast unused retval to void 2024-05-09 17:02:18 +08:00
Mike Yuan 696a8ec0ff
core/dbus-unit: correct argument alignment for SD_BUS_METHOD_WITH_ARGS 2024-05-09 17:02:18 +08:00
Sam Leonard 521e9286aa vmspawn: forward signals to VM PID 1 via D-BUS when available
Allow to gracefully shutdown by initiating the operation from
the guest
2024-05-08 23:25:02 +01:00
Sam Leonard 1e83cfff8d vmspawn: register with io.systemd.Machine.Register
When available, use varlink to register the VM, so that we can talk
over SSH to the guest. Enables 'machinectl shell' for vmspawn guests.
2024-05-08 23:24:54 +01:00
Sam Leonard 506aa3713b vmspawn: add a dropin override to sshd-vsock@.service 2024-05-08 23:24:54 +01:00
Mike Yuan 8f9acf8e10 systemctl-show: make show_memory_available cover memory_available itself
Follow-up for f380473edf

This cleans up the code a bit. Also, before this commit,
if MemoryAvailable is set but show_memory_available
is false, and we have nothing else to output, empty
parenthesis is shown. This can be easily reproduced
on -.slice:

> systemctl status -- -.slice
> ...
> Memory: 1.8G ()
> ...
2024-05-08 21:20:05 +02:00
Luca Boccassi d2fa7f1310
Merge pull request #32717 from keszybz/very-important-fixes
Whitespace adjustments and comments
2024-05-08 17:21:27 +02:00
Lennart Poettering d6bfc3d889 pidfd: properly detect if libc offers pidfd syscalls and make use of them then
We never updated the meson checks when glibc finally learned about these
syscalls, address that.
2024-05-08 15:36:40 +02:00
Zbigniew Jędrzejewski-Szmek 620682e675 nspawn: whitespace 2024-05-08 15:13:14 +02:00
Zbigniew Jędrzejewski-Szmek 4955d2e367 repart,measure: reword help descriptions
This is a follow-up/extension for ec361ea9ce.
2024-05-08 15:13:14 +02:00
Zbigniew Jędrzejewski-Szmek 0ca9c2c9b8 shared: fix comment
Follow-up for 90db1582a9.
2024-05-08 15:13:14 +02:00
Zbigniew Jędrzejewski-Szmek 3ea527d33c vmspawn: indentation 2024-05-08 15:13:14 +02:00
Mike Yuan 6724a0f0a3 firewall-util-iptables: update ELF note to mention "iptables"
Follow-up for cd7c207795
2024-05-08 15:00:39 +02:00
Luca Boccassi 867e2987a2
Merge pull request #32709 from bluca/machined_ssh
machined: add GetMachineSSHInfo method and varlink interface to register machines
2024-05-08 14:37:55 +02:00
Luca Boccassi 0a9ce6251d
Merge pull request #32708 from DaanDeMeyer/fix-race
Fix race conditions in tests
2024-05-08 14:21:37 +02:00
Luca Boccassi 667fe27e5d
Merge pull request #32705 from YHNdnzj/hibernate-error
hibernate-util: differentiate some errors from the generic ENOSPC; systemctl: adjust the fallback behavior for sleep operations
2024-05-08 14:19:07 +02:00
Daan De Meyer 1b35ea0cdf
Merge pull request #32710 from YHNdnzj/debug-generator-cleanup
debug-generator: several cleanups
2024-05-08 14:09:56 +02:00
Luca Boccassi 344ededcea
Merge pull request #32234 from poettering/dlopen-name-elf-note
Expose dlopen() dependencies in an ELF section, and add spec for it
2024-05-08 13:56:34 +02:00
Sam Leonard 5b44c81ff8 machined: add varlink interface for registering machines
This commit adds the new varlink interface io.systemd.Machine at
/run/systemd/machine/io.systemd.Machine with a single method Register

It supports all combinations of RegisterMachine[WithSSH,WithNetwork] all
under the same method.
2024-05-08 11:54:31 +01:00
Mike Yuan f9e2b42b16
debug-generator: clean up logging and such for units passed from creds 2024-05-08 18:43:50 +08:00
Mike Yuan a3816ea427
debug-generator: don't eat up error if we can't write drop-in
While at it, prepend the drop-in text with
our usual "Automatically generated by ...".
2024-05-08 18:43:50 +08:00
Mike Yuan 2997df9777
debug-generator: drop unneeded empty_to_root 2024-05-08 18:43:49 +08:00
Mike Yuan 221bad6007
debug-generator: use RET_GATHER where appropriate 2024-05-08 18:43:49 +08:00
Mike Yuan b5636a8f83
debug-generator: enclose function call in if statement when retval
is not used
2024-05-08 18:43:49 +08:00
Mike Yuan a688e5fefd
ssh-generator: fix pointer cast type 2024-05-08 18:20:59 +08:00
Lennart Poettering cd7c207795 tree-wide: add dlopen ELF notes to all dlopen() deps of ours
Use 'recommended' priority for the default compression library, to
indicate that it should be prioritized over the other ones, as it
will be used to compress journals/core files.
Also use 'recommended' for kmod, as systems will likely fail to boot
if it's missing from the initrd.
Use 'suggested' for everything else.

There is one dlopen'ed TPM library that has the name generated
at runtime (depending on the driver), so that cannot be added, as it
needs to be known at build time.
Also when we support multiple ABI versions list them all, as for the
same reason we cannot know which one will be used at build time.

$ dlopen-notes.py build/libsystemd.so.0.39.0 build/src/shared/libsystemd-shared-256.so
libarchive.so.13 suggested
libbpf.so.0 suggested
libbpf.so.1 suggested
libcryptsetup.so.12 suggested
libdw.so.1 suggested
libelf.so.1 suggested
libfido2.so.1 suggested
libgcrypt.so.20 suggested
libidn2.so.0 suggested
libip4tc.so.2 suggested
libkmod.so.2 recommended
liblz4.so.1 suggested
liblzma.so.5 suggested
libp11-kit.so.0 suggested
libpcre2-8.so.0 suggested
libpwquality.so.1 suggested
libqrencode.so.3 suggested
libqrencode.so.4 suggested
libtss2-esys.so.0 suggested
libtss2-mu.so.0 suggested
libtss2-rc.so.0 suggested
libzstd.so.1 recommended

Co-authored-by: Luca Boccassi <bluca@debian.org>
2024-05-08 11:07:36 +01:00
Lennart Poettering 2f6bd11c1a dlfcn: add macro for exporting dlopen() module names in ELF sections
This allows code to declare "weak" dlopen() style deps via an ELF
section following the just added specification.

The idea is that any user of dlopen() will place ELF_NOTE_DLOPEN(…)
somewhere close which will synthesize the note.

Tools such as rpm/dpkg package builders as well as initrd generators
(such as dracut) can then automatically pick up these weak deps of
suggested dependencies for their purposes.

Co-authored-by: Luca Boccassi <bluca@debian.org>
2024-05-08 11:07:36 +01:00
Daan De Meyer 677430b3c7 tmpfiles: Don't fail if file does not exist in item_do()
If the file was removed by some other program, we should just go
to the next one without failing. item_do() is only used for recursive
globs instead of fixed paths so skipping on missing files makes sense
(unlike if the path was fixed where we should probably fail).

Fixes #32691 (hopefully)
2024-05-08 12:01:37 +02:00
Sam Leonard 1f815bf164 machined: add GetMachineSSHInfo method
Also adds three properties:
- VsockCid: the VSOCK CID of the VM
- SshAddress: the address of the VM in a format SSH can connect to
- SshPrivateKeyPath: the path to the SSH private key to use to connect
  to the VM.

GetMachineSSHInfo is essentially a convenience method to query both the
SshAddress and SshPrivateKeyPath properties at once.
2024-05-08 09:56:42 +01:00
Sam Leonard 885317f1ab machined: split manager linking out of machine_new into machine_link 2024-05-08 09:52:15 +01:00
Sam Leonard 71a15f37af machined: expose machine_freep in machine.h 2024-05-08 09:52:15 +01:00
Sam Leonard 8fcf504b8c shared/json: add json_dispatch_absolute_path 2024-05-08 09:52:15 +01:00
Daan De Meyer b438ebd7bc TEST-07-PID1: Fix race in aux-scope subtest
Currently test-aux-scope.service can get killed by the test before
it's had a chance to setup its signal handler. Make it Type=notify
to fix the race.

Fixes #32670 (hopefully)
2024-05-08 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek a4f0e0da35 preset-all: continue on errors, report more errors
Firstly, if we encounter an error when iterating over the directory, gather
the error but continue. This is unlikely to happen, but if it happens, then
it doesn't seem very useful to break the preset processing at a random
point. If we can't process a unit — too bad, but since we already might
have processed some units earlier, we might as well try to process the
remaining ones.

Secondly, add missing error codes for units that are in a bad state to the
exclusion list. Those, we report them in the changes list, but consider the
whole operation a success. (-ETXTBSY and -ENOLINK were missing.)

Thirdly, add a message generator for -ENOLINK.

Fixes https://github.com/systemd/systemd/issues/21224.
2024-05-08 08:18:55 +02:00
Mike Yuan 4f344de792
systemctl: do not fall back to StartUnit automatically for sleep operations
In the majority of cases, this is caused by
sleep_supported() returning error. Hence it's
very likely that it would fail again, so
the fallback is not really useful. Instead,
honor the --force option for these verbs.
2024-05-08 13:45:49 +08:00
Mike Yuan 3fce141c1b
hibernate-util,logind: also differentiate the case of misconfigured resume 2024-05-08 12:55:25 +08:00
Mike Yuan 40eb83a8fe
hibernate-util,logind: emit a clear error if the specified resume dev is missing
Currently, SLEEP_NOT_ENOUGH_SWAP_SPACE (ENOSPC) is returned
on all sorts of error conditions. But one important case
that's worth differentiating from that is when the resume device
is manually specified yet missing.

Closes #32644
2024-05-08 12:54:13 +08:00
Mike Yuan 8aed85875d
repart: correct timespec_store usage too 2024-05-08 00:19:38 +08:00
Mike Yuan 158681f0f9
basic/mkdir: use timespec_store instead of _nsec for mkdir_p_root_full
Follow-up for 34c3d57474

O_RDONLY is dropped when O_DIRECTORY is specified, since
it's unnecessary and even arguably confusing here, as
the dir is modified.
2024-05-08 00:18:27 +08:00
Mike Yuan 026335e9aa
core/service: use switch for service_enter_start
Plus, add an assertion to ensure we're actually
using the start timestamp for the correct pid.
2024-05-08 00:17:54 +08:00
Mike Yuan dddc060286
core/execute: re-break function declaration of exec_spawn
Also rearrange some variable definitions. Note that
DECIMAL_STR_MAX() contains the size of NUL byte,
so +1 is dropped.
2024-05-08 00:16:54 +08:00