Commit Graph
71065 Commits
Author SHA1 Message Date
Yu Watanabe 18d4e475c7 journal-file-util: use COPY_VERIFY_LINKED
As the main thread may call journal_directory_vacuum() ->
unlinkat_deallocate() while another thread is copying the file.

Fixes #24150 and #31222.
2024-02-16 03:48:18 +09:00
Yu Watanabe 72ef2a617f copy: introduce COPY_VERIFY_LINKED flag
If the flag is set, then copy_file() and friends check if the source
file still exists when the copy operation finished.
2024-02-16 03:48:18 +09:00
Yu Watanabe cb0d5f73e6 sd-journal: use stat_verify_linked() 2024-02-16 03:48:18 +09:00
Yu Watanabe a6d0cf939c stat-util: introduce {stat,fd}_verify_linked() 2024-02-16 03:48:18 +09:00
Yu Watanabe dd7fa015a6 stat-util: rebreak comment 2024-02-16 03:48:18 +09:00
Yu Watanabe f0455cec53 bsod: fix -c/--continuous support
Fixes a bug introduced by f7f062bf9f.

Fixes #31334.
2024-02-16 02:21:11 +09:00
Yu Watanabe 3900255ac1 Merge pull request #31331 from yuwata/xopenat
tree-wide: several cleanups related to xopenat()
2024-02-16 01:32:21 +09:00
Yu Watanabe f73ad0a9fb journal-file-util: use the file descriptor of journal file on copy
No effective functionality changed, just refactoring.
2024-02-16 00:25:37 +09:00
Yu Watanabe 0f938a024e test: add test for copying symlink with copy_tree_at() 2024-02-16 00:25:37 +09:00
Yu Watanabe d1553bfd20 copy: use xopenat() to make 'from' argument optional 2024-02-16 00:25:37 +09:00
Yu Watanabe e40b11be04 fs-util: rename xopenat() -> xopanat_full() 2024-02-16 00:25:37 +09:00
Yu Watanabe 6383abd62c loop-util: fix error handling
Follow-up for 972c8db589.
2024-02-16 00:25:37 +09:00
Yu Watanabe 59a4e17249 chattr-util: fix error code
Follow-up for cf91b9155c.
2024-02-16 00:25:37 +09:00
Yu Watanabe bec1383623 chase: do not wrap xopenat() with RET_NERRNO()
Follow-up for 47f0e1b5e0.
2024-02-16 00:25:37 +09:00
Yu Watanabe e4c094c055 fs-util: readlinkat() supports an empty string
From readlinkat(2):
Since Linux 2.6.39, pathname can be an empty string, in which case the
call operates on the symbolic link referred to by dirfd (which should
have been obtained using open(2) with the O_PATH and O_NOFOLLOW flags).
2024-02-16 00:25:37 +09:00
Luca Boccassi 55d37de121 Merge pull request #30910 from YHNdnzj/logind-followup
logind-user: switch tracking logic to user-runtime-dir@.service
2024-02-15 14:32:48 +00:00
Michael Biebl 50b68cff54 systemctl: drop chain invocation of telinit
This functionality relied on telinit being available in a different path
then the compat symlink shipped by systemd itself. This is no longer the
case for any known distro, so remove that code.

Fixes: #31220
Replaces: #31249
2024-02-15 14:29:20 +00:00
Luca Boccassi e07e7017bb man: enchance sd_bus_set_watch_bind() example to handle one more failure
In case the D-Bus policy is not set up correctly the example just
loops forever. Check the return of sd_bus_request_name_async() in
a callback and exit if the error is not temporary.

Follow-up for 34bbda18a5
2024-02-15 14:19:39 +00:00
Mike Yuan 0ba24952f5 core/manager: don't propagate manager session env to children
Follow-up for 4cb4e6cf6d

Fixes #31287
2024-02-15 19:23:53 +08:00
Mike Yuan 9128fd553c env-util: minor modernization 2024-02-15 19:23:52 +08:00
Mike Yuan 52bcc872b5 logind-session: use Requires= for user{,-runtime-dir}@.service
Since we do require these basic user services, let's make
the dependency stronger. Note that logind should enqueue
start jobs for these already in user_start(), so mostly
just paranoia.
2024-02-15 19:23:52 +08:00
Mike Yuan e2a42c0c43 logind-user: track user started/stopping state through user-runtime-dir@.service
Before #30884, the user state is tied to user@.service (user service
manager). However, #30884 introduced sessions that need no manager,
and we can no longer rely on that.

Consider the following situation:

1. A 'background-light' session '1' is created (i.e. no user service manager
   is needed)
2. Session '1' scope unit pulls in user-runtime-dir@.service
3. Session '1' exits. A stop job is enqueued for user-runtime-dir@.service
   due to StopWhenUnneeded=yes
4. At the same time, another session '2' which requires user manager is started.
   However, session scope units have JobMode=fail, therefore the start job
   for user-runtime-dir@.service that was pulled in by session '2' scope job
   is deleted as it conflicts with the stop job.

We want session scope units to continue using JobMode=fail, but we still need
the dependencies to be started correctly, i.e. explicitly requested by logind
beforehand. Therefore, let's stop using StopWhenUnneeded=yes for
user-runtime-dir@.service, and track users' `started` and `stopping` state
based on that when user@.service is not needed. Then, for every invocation
of user_start(), we'll recheck if we need the service manager and start it
if so.

Also, the dependency type on user-runtime-dir@.service from user@.service
is upgraded to `BindsTo=`, in order to ensure that when logind stops the
former, the latter is stopped as well.
2024-02-15 19:23:44 +08:00
Mike Yuan 5518b72ba8 login/logind-session-dbus: some follow-ups for 'user-incomplete' (#30226)
We don't usually say ", refusing" in bus error messages.
Also, make use of unref_and_replace_full.
2024-02-15 19:23:44 +08:00
Adrian Vovk d0aef638ac keyring-util: Use reported key size to resize buf
According to keyctl(2), the return value for KEYCTL_READ is:

    The amount of data that is available in the key,
    irrespective of the provided buffer size

So, we could pass in a NULL buffer to query the size, then allocate the
exact right amount of space, then call keyctl again to get the key data.
However, we must still keep the for loop to avoid TOCTOU issues: the key
might have been replaced with something bigger while we're busy
allocating the buffer to store it.

Thus, we can actually save a syscall by picking some reasonable default
buffer size and skipping the NULL call to keyctl. If our default is big
enough, we're done and have saved a syscall! If not, then the first call
behaves essentially the same as the NULL call, and we use the size it
returns to reallocate the buffer appropriately.
2024-02-15 11:13:34 +00:00
Benjamin Franzke 614d09a37d nspawn: add support for owneridmap bind option
owneridmap bind option will map the target directory owner from inside the
container to the owner of the directory bound from the host filesystem.
This will ensure files and directories created in the container will be owned
by the directory owner of the host filesystem. All other users will remain
unmapped. Files to be written as other users in the container will not be
allowed.

Resolves: #27037
2024-02-15 11:49:54 +01:00
Yu Watanabe 4dcfdd210c log: reorder arguments of internal macro
To make the order matches with log_internal().

No functional change. Hopefully silence coverity issues like
CID#1534478, CID#1534479, CID#1534480, CID#1534482.
2024-02-15 18:16:33 +09:00
Yu Watanabe 7774a7ca79 test: fix cleanup function
Follow-up for 8349bbdfd8.
2024-02-15 09:37:10 +01:00
Adrian Vovk 058a84d113 homed: Pass in username and uid as Polkit details
This lets the Javascript polkit policies to decide whether to
allow/deny/authenticate based on the user that's being operated on.
2024-02-15 09:12:37 +01:00
Yu Watanabe 8c3f988880 vmspawn: fix alignment of merged initrd
Follow-up for 811ad9e6b2.

Fixes CID#1534481.
2024-02-15 09:11:55 +01:00
Daan De Meyer 9a07df3bcd Merge pull request #31330 from yuwata/sd-journal-trivial-cleanups
sd-journal: trivial cleanups
2024-02-15 08:56:56 +01:00
Yu Watanabe 0984c3d021 copy: rebreak comment and fix typo 2024-02-15 10:19:02 +09:00
Yu Watanabe a9c2e0f426 sd-journal: fix potential memory leak
Though, hopefully, the memory leak is hypothetical, as we always close
journal file with the timer by journal_file_offline_close().
2024-02-15 09:50:18 +09:00
Yu Watanabe da96afcd6c journal-file-util: drop unused template argument for journal_file_open_reliably()
I understand that the original motivation to introduce the template
argument here is to make journal_file_open() and _reliabrly() take the
same arguments. But, yeah, that's completely unused, not necessary to
complicate the code even the difference is not big.
2024-02-15 09:50:18 +09:00
Yu Watanabe 36c6b26c37 sd-journal: use -EBADF for journal_file_open() 2024-02-15 09:50:18 +09:00
Yu Watanabe 3f6c529cde sd-journal: shorten code a bit 2024-02-15 09:50:18 +09:00
Yu Watanabe 6854322483 test-network: show interface status again when wait-online failed
Fixes a bug in 10d670a3c1.

This also makes wait_online() show a short message when a requested
interface not found.
2024-02-15 00:37:03 +00:00
Yu Watanabe d5ff4b6d4c Merge pull request #31173 from yuwata/network-route-check-conflict
network/route: check if existing route can be updated
2024-02-15 08:12:42 +09:00
Yu Watanabe 4931b8e471 login: fix typo
Follow-up for 6e9bf0ad29.
2024-02-15 05:38:47 +09:00
Luca Boccassi 76995e7dc4 Merge pull request #31286 from poettering/bootctl-varlink
bootctl: add simple varlink IPC interface
2024-02-14 18:59:33 +00:00
Luca Boccassi 32243272ff Merge pull request #31317 from fbuihuu/update-tests-for-suse
Update tests for SUSE
2024-02-14 17:31:40 +00:00
Winterhuman 6c6ec5f728 Improve IgnoreSIGPIPE description
Reword the description of the `IgnoreSIGPIPE=` service option to be more grammatical.
2024-02-14 17:31:18 +00:00
Mike Yuan 3725766266 systemctl: don't warn unit needs reload if --no-warn 2024-02-15 00:37:19 +08:00
Lennart Poettering a0437868d8 Merge pull request #30226 from poettering/homed-fallback-shell
homed: allow logging into home areas via ssh without unlocking them locally first
2024-02-14 17:08:04 +01:00
Yu Watanabe 29fbbb1389 test-network: add test for advertised hop limit
For issue #28437.
2024-02-15 00:43:12 +09:00
Matt MuggeridgeandYu Watanabe b15ed2be2f network/ndisc: also set sysctl hop_limit value
Otherwise, the hop limit set to the routes may not be used in some
situations.

Fixes #28437.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2024-02-15 00:43:12 +09:00
Yu Watanabe 9fbab82bef test-network: add test case for removing conflicting routes
For issue #28439.
2024-02-15 00:43:12 +09:00
Yu Watanabe e3cc2bd9c6 test-network: drop unnecessary IPv6SendRA=yes setting 2024-02-15 00:43:12 +09:00
Yu Watanabe 972f1d17ab network/ndisc: remove conflicting routes on configuring routes based on newly received RA
The linux kernel does not update several parameters, e.g. RTA_PREF.
Hence, when we configure routes based on a RA, we need to remove
existing conflicting routes.

Fixes #28426 and #28439.
2024-02-15 00:43:12 +09:00
Yu Watanabe 7027cdbd79 network/route: remove existing route if some property conflict with requested ones
Fixes #28853.
2024-02-15 00:43:12 +09:00
Yu Watanabe e09b758876 network: rename link_drop_managed_xyz() -> link_drop_static_xyz()
As networkd does not configure nexthops, neighbors, or routing policy rules
dynamically, this only changes link_drop_managed_addresses(). Previously
it also removed dynamic addresses, but with this commit, now it only
removes static addresses. Note, link_drop_managed_routes() has removed
only static routes, so this commit only changes its name.

Note. as commented in the code, the dynamic addresses will be removed
on lease expiration or stopping client, and link_drop_managed_xyz() are
called on reconfiguration or so, and at that time, all dynamic
addressing clients are stopped or restarted, so this should not
effective behavior change.
2024-02-15 00:43:12 +09:00