Commit Graph

73819 Commits

Author SHA1 Message Date
Mike Yuan
d73a47d259
man/systemd-run: beef up info regarding interaction between --pty, --pipe, and --wait 2024-05-21 21:40:01 +08: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
Andika Triwidada
688b701168 po: Translated using Weblate (Indonesian)
Currently translated at 100.0% (233 of 233 strings)

Co-authored-by: Andika Triwidada <andika@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/id/
Translation: systemd/main
2024-05-21 22:14:23 +09: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
Luca Boccassi
1bfa83e77d
Merge pull request #32942 from yuwata/test-journal-sync-more
test: sync journal before read
2024-05-20 22:55:54 +02: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
Yu Watanabe
702fdd3135 test: sync journal before read
Similar to recent commits, e.g. f961f0e47c2caf9af735a22e7f23210e746d0c8b.

Fixes #32926.
2024-05-21 02:00:08 +09:00
Yu Watanabe
123acb2560 test: call journalctl --sync just before reading journals
Otherwise, journal entries comes during sleep may not be read.

Follow-up for c22a112883.
2024-05-21 01:53:07 +09: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
a56ffe2ca9
Merge pull request #32934 from bluca/logind_regression_main
logind: do not fail creating a session when request is not from a unit
2024-05-20 17:50:26 +02:00
Yu Watanabe
fe816c23cf test: wait for partition device rather than the whole disk
Fixes #32931.
2024-05-20 15:05:47 +02:00
Luca Boccassi
30633afcb8
Merge pull request #32927 from yuwata/test-network-netdevsim
test-network: workaround for netdevsim bug
2024-05-20 15:03:53 +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
5002b576d8 semaphore: use variable for Salsa repo URL
Makes it easier to switch for debuggin
2024-05-20 13:14:50 +01:00
drewbug
2fa7626e18
man: fix grammar for Name= option in systemd.link 2024-05-20 11:11:22 +01:00
Yu Watanabe
90fe8cf209 test: install more kernel modules for Fedora image
Otherwise, several tests for networkd are skipped.

Follow-up for #32666.
2024-05-20 18:38:45 +09:00
Yu Watanabe
f1f1be71fe test-network: also set custom altternative name for netdevsim interface
Due to the bug in kernel 6.9 caused by
8debcf5832,
the net_id udev builtin does not work for netdevsim interface.
So, eni99np1 cannot be used with kernel 6.9 anymore.

Workaround for #32910.
2024-05-20 18:33:47 +09:00
Yu Watanabe
12e0d6ed38 test-network: split out setup_netdevsim() 2024-05-20 10:42:01 +09: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
bb84142513 test: sync journal before starting test
Follow-up for c22a112883.

Hopefully fixes #32712.
2024-05-19 22:56:37 +02:00
Luca Boccassi
290766d72b
Merge pull request #32907 from yuwata/image-fix
several fixes for os image handling
2024-05-19 21:10:40 +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
Luca Boccassi
d4d6a9e4ae
Merge pull request #32917 from YHNdnzj/ptyfwd-cleanup
ptyfwd: a few fixes/cleanups
2024-05-19 14:44:54 +02:00
Yu Watanabe
a610ba00d9 test: sync journal before read
Workaround for #32834 and #32890.
2024-05-19 13:54:28 +02: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
Luca Boccassi
68ca50d3ae
Merge pull request #32914 from yuwata/test-64-storage
test: several follow-ups for TEST-64-STORAGE
2024-05-19 02:50:36 +02:00
Yu Watanabe
301d7ee611 test: wipe filesystem before moving to the next test case 2024-05-19 05:10:28 +09:00
Yu Watanabe
2569e790f6 test: install modinfo to test image
Follow-up for 6c2d47d6d3.

Fixes the following unexpected skip:
```
[    6.163670] TEST-64-UDEV-STORAGE.sh[596]: + modinfo btrfs
[    6.164102] TEST-64-UDEV-STORAGE.sh[726]: /usr/lib/systemd/tests/testdata/units/TEST-64-UDEV-STORAGE.sh: line 726: modinfo: command not found
[    6.164683] TEST-64-UDEV-STORAGE.sh[727]: + echo 'This test requires the btrfs kernel module but it is not installed, skipping the test'
[    6.165069] TEST-64-UDEV-STORAGE.sh[728]: + tee --append /skipped
[    6.166801] TEST-64-UDEV-STORAGE.sh[728]: This test requires the btrfs kernel module but it is not installed, skipping the test
[    6.167177] TEST-64-UDEV-STORAGE.sh[596]: + exit 77
```
2024-05-19 05:08:31 +09: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
e579017872
Merge pull request #32909 from arthurzam/bash-v256
shell-completion: add more missing args for bash
2024-05-18 16:30:03 +09:00
Arthur Zamarin
27e49748ca
shell-completion: add systemd-vmspawn to meson.build
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
2024-05-18 09:38:53 +03:00
Arthur Zamarin
02132022b0
shell-completion: add missing args to bash systemd-nspawn
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
2024-05-18 09:34:38 +03:00
Arthur Zamarin
030b2c8490
shell-completion: add missing args to bash systemd-run
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
2024-05-18 09:34:38 +03:00
Yu Watanabe
f3c5ea7111 install-file: make fs_make_very_read_only() static 2024-05-17 23:06:48 +02:00
Yu Watanabe
6da7485176 man: refer FailureAction= and SuccessAction= for explaining allowed values in JobTimeoutAction=
The allowed values are explained in FailureAction= and SuccessAction=,
rather than StartLimitAction=.
2024-05-18 02:51:34 +09:00