1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-03 05:18:09 +03:00
Commit Graph

75871 Commits

Author SHA1 Message Date
Yu Watanabe
1b8a74678c run: use sd_bus_set_allow_interactive_authorization() 2024-08-19 11:36:32 +09:00
Yu Watanabe
04834552ed mount: use sd_bus_set_allow_interactive_authorization() 2024-08-19 11:36:32 +09:00
Yu Watanabe
335608593c timedatectl: drop unnecessary temporal variables
Also drop unnecessary spaces.
2024-08-19 11:36:32 +09:00
Yu Watanabe
f3cf6167ef tree-wide: voidify polkit_agent_open_if_enabled() 2024-08-19 11:36:32 +09:00
Yu Watanabe
69e7d2efdf timedatectl: enable interactive authentication for DBus methods 2024-08-19 11:36:32 +09:00
Yu Watanabe
470cea62da resolve: inherit server userdata
No functional change, just refactoring.
2024-08-19 11:36:32 +09:00
Yu Watanabe
cf01bbb7a4 resolve: support polkit authentication for io.systemd.Resolve.Monitor
Then, non-privilege user can call e.g. 'resolvectl monitor' with
authentication.
2024-08-19 11:36:32 +09:00
Yu Watanabe
302cc03cc8 sd-varlink: allow to dispatch method again on pending-method-more state
Otherwise, polkit authentication does not work for methods that require
the MORE flag.
2024-08-19 11:36:32 +09:00
Yu Watanabe
614a6770f9 resolvectl: acquire DBus connection only when necessary
When e.g. `resolvectl monitor` is called, it is not necessary to acquire
DBus connection.
2024-08-19 11:36:32 +09:00
Yu Watanabe
f75ecb9f8b resolvectl: several coding style cleanups
Use RET_GATHER(), FOREACH_ARRAY(), and strv_skip().
2024-08-19 11:36:32 +09:00
Yu Watanabe
5703301ada resolvectl: introduce --no-ask-password option 2024-08-19 11:36:22 +09:00
Yu Watanabe
1d7fa67789 resolvectl: enable interactive authentication for dbus method call
Even the server side supports polkit authentication, previously
the client side did not support polkit authentication.
2024-08-19 11:29:40 +09:00
Yu Watanabe
21f31f23cc networkctl: introduce --no-ask-password option 2024-08-19 11:28:22 +09:00
Yu Watanabe
67899e3e6b networkctl: enable interactive authentication for dbus method call
Previously, e.g. 'networkctl reload' did not ask password through
polkit.
2024-08-19 11:27:53 +09:00
Daan De Meyer
c4e809b6ad
Merge pull request #34026 from DaanDeMeyer/tests
Handle unprivileged user namespaces gracefully in tests
2024-08-18 23:31:10 +02:00
Daan De Meyer
ef31767ed7 test: Gracefully handle running within user namespace with single user
Unprivileged users often make themselves root by unsharing a user namespace
and then mapping their current user to root which does not require privileges.
Let's make sure our tests don't fail in such an environment by adding checks
where required to see if we're not running in a user namespace with only a
single user.
2024-08-18 21:53:52 +02:00
Yu Watanabe
dff27ce65a
Merge pull request #34025 from YHNdnzj/edit-util-wrong-place
edit-util: catch and warn about edits outside of markers
2024-08-19 04:33:56 +09:00
Yu Watanabe
dc64f66756
Merge pull request #34022 from YHNdnzj/unit-is-filtered
core/unit: two trivial cleanups
2024-08-19 04:29:54 +09:00
Yu Watanabe
871b0ee995
Merge pull request #34020 from YHNdnzj/cred-no-mountover
core/dbus-service: refuse bind mounting over /run/credentials/
2024-08-19 04:29:42 +09:00
Yu Watanabe
6e4918a944 analyze: introduce --instance= option to control instance name for template units
Note, `systemd-analyze foo@.service --instance=hoge` is equivalent to
`systemd-analyze foo@hoge.service`. But, the option may be useful when
e.g. passing multiple template units that have restriction on their
instance name:
```
$ ls
template_aaa@.service   template_bbb@.service   template_ccc@.service
$ systemd-analyze ./template_* --instance=hoge
```
Without the option, we need to embed an instance name into each unit
name, so cannot use globs.

Prompted by #33681.
2024-08-19 04:29:23 +09:00
Mike Yuan
e65b07293c
edit-util: catch and warn about edits outside of markers
The users still periodically come back to #24208.
Let's add a detection for this hence.
2024-08-18 16:42:29 +02:00
Mike Yuan
f0f044a456
string-util: update ptr declaration to match our coding style 2024-08-18 16:41:44 +02:00
Mike Yuan
f32538e1cc basic/process-util: modernize setpriority_closest()
Before this commit, the "Cannot raise nice level" branch
is rather confusing, as we're actually lowering the nice.
Also, it's better to log about the final nice value
for both cases, no matter whether we need to set to limit
or not.
2024-08-18 15:16:03 +02:00
Daan De Meyer
d098b8df6e test-netlink: Gracefully handle the loopback interface being down 2024-08-18 13:19:30 +02:00
Mike Yuan
6e0f959360
core/unit: unit_is_filtered() -> unit_passes_filter() and invert logic
Follow-up for 6d2984d21b

The current semantics of "filtered" in unit_is_filtered()
are actually the contrary of ListUnitsFiltered(). Let's
make things consistent, i.e. return true when the unit
shall be included.
2024-08-17 20:09:51 +02:00
Mike Yuan
6c8ade3066
core/unit: rename set_unit_path() -> setenv_unit_path()
The previous name is quite vague on what this precisely
do.
2024-08-17 18:52:42 +02:00
Mike Yuan
ae5c4aa66e
core/dbus-service: refuse bind mounting over /run/credentials/
The credential mounts should be managed singlehandedly by pid1.
Preparation for the future introduction of RefreshOnReload=credential,
where refreshing creds will be properly supported on reload.
2024-08-17 18:16:20 +02:00
Mike Yuan
f31906ff0b
core/dbus-service: some modernization for bus_service_method_mount()
Perform some checks earlier to avoid pointless polkit auth.

Plus, the missing unit_get_exec_context() shall not be
a formalized error. As it's our internal representation
and in the normal operation should never happen.
2024-08-17 18:09:54 +02:00
Yu Watanabe
c53a28cea1 network: refuse files under API VFS specified in PrivateKeyFile= and friends
Addresses https://github.com/systemd/systemd/pull/34013#discussion_r1719890231.
2024-08-17 03:20:26 +09:00
Yu Watanabe
08779d7c55 test: add test case that 'nspawn --network-veth' enables IP forwarding 2024-08-17 02:11:15 +09:00
Yu Watanabe
4bf1a2c383 network/wireguard: introduce [WireGuardPeer] PublicKeyFile=
Similar to PresharedKeyFile=, but for public key.

Closes #34012.
2024-08-17 01:58:02 +09:00
Yu Watanabe
7908e1d459 test: allow to skip matrix_run_one() if $TEST_MATCH_TESTCASE is set 2024-08-17 01:47:33 +09:00
Yu Watanabe
0b695febb2 network: make IPMasquerade= imply global IP forwarding settings again
After 3976c43092 (#31423), IPMasquerade=
implies only per-interface IP forwarding. That means, nspawn users need
to manually enable IPv4/IPv6Forwarding= in networkd.conf when
--network-veth or friend is used. Even the change was announced in NEWS,
the change itself breaks backward compatibility and extremely reduces
usability.

Let's make the setting imply the global setting again.

Fixes #34010.
2024-08-17 00:13:06 +09:00
Yu Watanabe
8ceca83141 network/lldp-tx: introduce link_lldp_tx_update_capabilities()
Currently it is unused, but it will be used later.
2024-08-16 23:30:05 +09:00
Yu Watanabe
fbcd7e054b sd-lldp-tx: insert missing empty line 2024-08-16 23:29:36 +09:00
rindeal
374aa1be7c kernel-install: discard comments in cmdline files
It was quite a surprise to find my comments in a booted kernel cmdline.
2024-08-16 17:15:39 +09:00
Daan De Meyer
2701c2f67d Add $SYSTEMD_IN_CHROOT to override chroot detection
When running unprivileged, checking /proc/1/root doesn't work because
it requires privileges. Instead, let's add an environment variable so
the process that chroot's can tell (systemd) subprocesses whether
they're running in a chroot or not.
2024-08-16 10:11:29 +02:00
Yu Watanabe
f689f57c1e test: fix typo
Follow-up for 538766ddf4.
2024-08-16 09:44:21 +09:00
bryango
3ceb4d2438 shell-completion: zsh: fix incorrect unescaping
Previously the `_filter_units_by_property` completion function
outputs with a [zsh parameter expansion flag] `g`. This means
that the returned result is unescaped as the zsh builtin `echo`,
except that octal escapes don’t take a leading zero. This seemed to
have worked back in the days when it was first introduced:

  6c9414a700

But it now leads to incorrect over-unescaping; for example,

  system-systemd\\x2djournald.slice (correct)

is incorrectly completed by zsh in commands such as
`systemctl kill`:

  system-systemd-journald.slice (incorrect)

This commit fixes such problems by removing the `g` flag.

See:
[zsh parameter expansion flag]: https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion-Flags
2024-08-15 20:28:12 +02:00
Matthias Schiffer
24c2e04e9a udev-builtin-net_id: add NAMING_DEVICETREE_PORT_ALIASES to check of_node of netdevs before their parents
The net_id builtin only checked the of_node of a netdev's parent device,
not that of the netdev itself. While it is common that netdevs don't have
an OF node assigned themselves, as they are derived from some parent
device, this is not always the case. In particular when a single
controller provides multiple ports that can be referenced indiviually in
the Device Tree (both for aliases/MAC address assignment and phandle
references), the correct of_node will be that of the netdev itself, not
that of the parent, so it needs to be checked, too.

A new naming scheme flag NAMING_DEVICETREE_PORT_ALIASES is added to
allow selecting the new behavior.
2024-08-15 18:20:49 +02:00
Yu Watanabe
98b86d294a
Merge pull request #34000 from yuwata/test-remove-temporary-directories
test: remove temporary directories
2024-08-15 18:54:16 +09:00
Yu Watanabe
22862288c8 test: sync journal after all invocations finished
Otherwise, several messages for the last invocation have not been
stored to journal yet.

Hopefully fixes the following race:
===
[  603.037765] H systemd-run[10503]: Running as unit: invocation-id-test-26448.service; invocation ID: 1a49edeb05a641aaa2def72411134822
[  603.099587] H bash[10504]: invocation 10 1a49edeb05a641aaa2def72411134822
[  603.212069] H systemd[1]: invocation-id-test-26448.service: Deactivated successfully.
[  603.225092] H systemd-run[10503]: Finished with result: success
[  603.225163] H TEST-04-JOURNAL.sh[10506]: + journalctl --list-invocation -u invocation-id-test-26448.service
[  603.225318] H systemd-run[10503]: Main processes terminated with: code=exited, status=0/SUCCESS
[  603.225357] H TEST-04-JOURNAL.sh[10507]: + tee /tmp/tmp.UzSmYamXyg/10
[  603.225357] H TEST-04-JOURNAL.sh[10507]: IDX INVOCATION ID                    FIRST ENTRY                 LAST ENTRY
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -9 d6efabb546014027b6bd7ee3a78386d6 Wed 2024-08-14 22:12:16 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -8 3e402b81c28d4a8fa2c5e8e31dffd9ee Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -7 5ebd0ba07d4f4f52bc84275f55a3ee2e Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -6 bc53c49d6ce24bb7acd438c3e61cfb23 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -5 24680907919e4839a75378117bb5a816 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -4 ec364ed7673c4a1fa22929f95ce7047b Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -3 2e8a4dea43044d1a9faf922f7a2f3d42 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -2 ac610b6e6c9c4a29bf8947890685478b Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:  -1 9b7d52c3620948f9831e323910f605f5 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225357] H TEST-04-JOURNAL.sh[10507]:   0 1a49edeb05a641aaa2def72411134822 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.225823] H systemd-run[10503]: Service runtime: 174ms
[  603.225866] H TEST-04-JOURNAL.sh[10508]: + journalctl --list-invocation -u invocation-id-test-26448.service --reverse
[  603.226110] H systemd-run[10503]: CPU time consumed: 12ms
[  603.226142] H TEST-04-JOURNAL.sh[10509]: + tee /tmp/tmp.UzSmYamXyg/10-r
[  603.226378] H systemd-run[10503]: Memory peak: 1.4M (swap: 0B)
[  603.230161] H TEST-04-JOURNAL.sh[10509]: IDX INVOCATION ID                    FIRST ENTRY                 LAST ENTRY
[  603.230161] H TEST-04-JOURNAL.sh[10509]:   0 1a49edeb05a641aaa2def72411134822 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:18 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -1 9b7d52c3620948f9831e323910f605f5 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -2 ac610b6e6c9c4a29bf8947890685478b Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -3 2e8a4dea43044d1a9faf922f7a2f3d42 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -4 ec364ed7673c4a1fa22929f95ce7047b Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -5 24680907919e4839a75378117bb5a816 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -6 bc53c49d6ce24bb7acd438c3e61cfb23 Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -7 5ebd0ba07d4f4f52bc84275f55a3ee2e Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -8 3e402b81c28d4a8fa2c5e8e31dffd9ee Wed 2024-08-14 22:12:17 UTC Wed 2024-08-14 22:12:17 UTC
[  603.230161] H TEST-04-JOURNAL.sh[10509]:  -9 d6efabb546014027b6bd7ee3a78386d6 Wed 2024-08-14 22:12:16 UTC Wed 2024-08-14 22:12:17 UTC
===
2024-08-15 18:52:38 +09:00
Luca Boccassi
ddc91af4ea test: add TEST_SKIP to mkosi integration test wrapper
Takes a space-separate list of test names, allows to skip one or more tests
2024-08-15 10:39:51 +02:00
Ronan Pigott
3d2157e707 units: drop "-p" flag from agetty's login options
This flag was added in db6aedab92 with the justification that locale
environment variables should be preserved by the user session. However,
the companion patch to drop the UnsetEnvironment= directive blocking
these variables was never merged, so the intended change was never
effected.

While the patch was ineffective toward its stated goal, the "-p" option
does have material negative consequences for the user session in
systemd — environment variables to support the use of
credentials and memory pressure directives, such as
$CREDENTIALS_DIRECTORY and $MEMORY_PRESSURE_WATCH, which are now
directly used by agetty and login, get leaked into the user session
potentially breaking applications that rely on these values.

E.g. systemd-ask-password fails from the tty when $CREDENTIALS_DIRECTORY
has been leaked from agetty, because it expects to be able to access
credentials in $CREDENTIALS_DIRECTORY.

This effectively reverts db6aedab92.

References: db6aedab92 (units: Tell login to preserve environment (#6023), 2017-05-24)
2024-08-15 16:49:02 +09:00
Yu Watanabe
e9a5b4a10e test: remove temporary directory for test-ukify on success 2024-08-15 16:19:27 +09:00
Yu Watanabe
63be834db8 test: remove temporary directory on success
Also use mkdtemp_open() with specific template.

Follow-up for e7e52ff9b6.
2024-08-15 16:19:27 +09:00
Daan De Meyer
0409213cbc mkosi: Fix debian/not-installed build logic
- Expand globs
- Filter out directories
- Append to the list of packaged files, not the list of installed files

Fixes the issue in https://github.com/systemd/systemd/pull/32363
2024-08-15 15:48:12 +09:00
Chengen Du
6bd12be3fa udev: Handle PTP device symlink properly on udev action 'change'
PTP device symlink creation rules are currently executed only when the
udev action is 'add'. If a user reloads the rules and runs the udevadm
trigger command to reapply changes, the symlink may be deleted, which
can prevent the chronyd service from restarting properly.

Signed-off-by: Chengen Du <chengen.du@canonical.com>
2024-08-15 15:38:46 +09:00
Yu Watanabe
6ddf879ce8
Merge pull request #33955 from yuwata/sd-journal-fix-sd_journal_seek_monotonic_usec
sd-journal: fix sd_journal_seek_monotonic_usec()
2024-08-15 15:38:19 +09:00
Thorsten Scherer
932cc94436 repart: Fix misleading typo in GPT partition flag
Bit 60 is the one corresponding to ReadOnly, not 50.  Fix this.
2024-08-15 05:59:58 +09:00