Commit Graph

71043 Commits

Author SHA1 Message Date
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
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 Muggeridge
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
Yu Watanabe
a86763c70b network/ndisc: also drop SLAAC addresses and routes on reconfiguring
Especially, this is important for routes, as link_drop_managed_routes()
removes only static routes, rather than non-foreign routes.
2024-02-15 00:43:12 +09:00
Yu Watanabe
95e1fbbac4 test-network: allow to specify multiple interfaces to wait_online() without square bracket 2024-02-15 00:42:43 +09:00
Lennart Poettering
79ec39958d bootctl: add a Varlink interface
For now, just super basic functionality: return the list of boot menu
entries, and read/write the reboot to firmware flag
2024-02-14 16:15:19 +01:00
Lennart Poettering
f892954ba2 bootspec: split out helper that turns BootEntry into a JSON object
We can use that later for returning the boot loader entry list as JSON
via Varlink.
2024-02-14 16:12:43 +01:00
Lennart Poettering
2cda44c23e efi-loader: make efi_loader_get_entries() handling missing NUL termination gracefully
Our function so far assumed that the LoaderEntries's last string is or
is not NUL terminated. But if it was, then we'd debug log about this,
claiming there was an invalid id. sd-boot actually ends the list in a
properly NUL-terminated string, hence we should just accept that. Handle
that case gracefully, and add comments explaining why we have two ways
why we exit the loop.

This is cosmetic only, just suppresses a misleading debug log message.
2024-02-14 15:35:52 +01:00
Lennart Poettering
1c5d03c088 update TODO 2024-02-14 15:10:39 +01:00
Lennart Poettering
8349bbdfd8 test: add test that ensures homed logins via SSH work 2024-02-14 15:09:47 +01:00
Lennart Poettering
5c29111337 pam_systemd_home: make sure we handle RefUnit() returning HomeBusy properly
RefUnit() only succeeds it a home dir is fully up. We already dealt with
it not being up at all, but let's also cover the case where it is
currently busy with changing state, and in that case fall back to
RefUnrestricted(), with the usual implications.

This has the effect that two subsequent ssh logins one-after-the-other
will work correctly.
2024-02-14 15:08:55 +01:00
Lennart Poettering
955502121d man: update D-Bus docs with new calls 2024-02-14 15:08:03 +01:00
Lennart Poettering
5fb7b15133 homed: generate fallback data in user record, for inactive homes 2024-02-14 15:07:11 +01:00
Lennart Poettering
2518230d33 pam_systemd_home: in ssh logins and similar, ask via fallback shall for home password
ssh runs PAM session hooks before they allocate a pty for the session.
(That's because they allow multiplexed connections, and hence might run
multiple ptys over the same same session). This means PAM modules cannot
interactively ask the user for additional information as they deem fit.
That's a problem for us, since generally during an SSH login no
authentication token (aka "password") is supplied to us which we could
use to unlock the user's home dir.

With this commit we implement a way out: we allow the login to proceed,
but without the home dir activated, and then override the user's shell
with our fallback shell, which will ask for the user's password and then
chainload the actual shell.

This will of course only work if the login actually involves invoking
the configured interactive shell of the user. For other logins (such as
sftp or so), this cannot work, and they'll see an empty home dir
instead.
2024-02-14 15:06:20 +01:00
Lennart Poettering
49493a7478 homectl: implement fallback shell stub 2024-02-14 15:05:18 +01:00
Lennart Poettering
336b1f1936 homed: add a ActivateHomeIfReferenced() bus call
This is very similar to ActivateHome() but will fail if the home
directory is not referenced yet. Or in other words, this doesn't add any
new reference, but simply is the other side of RefUnrestricted(): if we
allowed a home dir to be referenced without it actually being active,
then this can catch up with things and activated what was previously
referenced already.

This also relaxes access rights to that users can always activate their
own home dirs. This is useful once we allow user code to run without the
home dir being activated.
2024-02-14 15:04:15 +01:00
Lennart Poettering
508d344e0e homed: add bus call that allows referencing a home without activating it
This is useful for allowing users to login without the ability to unlock
their home dir. Usecase is ssh: ssh might grant access without giving
us the chance to unlock the home dir for the user (because it doesn't
allow us asking questions during authentication), hence with this call
we can pin the home dir, but not activate it and then allow the
activation to be delayed until later.
2024-02-14 15:03:23 +01:00
Lennart Poettering
2f4aa81440 user-record-show: show if fallback data is used 2024-02-14 15:02:31 +01:00
Lennart Poettering
46c60f7216 user-record: add fields for a fallback home dir + shell
This adds fields to the user record logic to allow a "fallback" home
directory and shell to be set as part of the "status" section of the
user record, i.e. supplied by the manager of the user record.

The idea is that if the fallback homedir/shell is set it will take
precedence over the real one in most ways.

Usecase: let's try to make ssh logins into homed directories work.
systemd-homed would set a fallback shell/homedir for inactive home dirs.
Thus, when ssh logins take place via key auth, we can allow them, and
these fallback session params would be used because the real home cannot
be activated just yet becasue we cannot acquire any password for it from
the user.
2024-02-14 15:01:38 +01:00
Lennart Poettering
6e9bf0ad29 logind: add ability to upgrade session class from 'user-incomplete' to 'user' 2024-02-14 15:00:46 +01:00
Lennart Poettering
249067d178 pam-systemd: automatically enable "incomplete" user session if XDG_SESSION_INCOMPLETE env var is set
This allows earlier PAM modules (i.e. pam_systemd_home) to inform
pam_systemd that the session is not "complete" yet (i.e. doesn't have
the home dir set up properly yet).
2024-02-14 14:59:53 +01:00
Lennart Poettering
53ebde6db4 logind: add new 'user-incomplete' session class 2024-02-14 14:58:37 +01:00
Luca Boccassi
37c6c2035e Merge pull request #28761 from esposem/cmdline_manager
bootctl: handle UKI cmdline addons
2024-02-14 13:56:31 +00:00
Luca Boccassi
25d80c2203 Merge pull request #31283 from CodethinkLabs/vmspawn/start_from_template
vmspawn: Support being invoked from a template unit
2024-02-14 13:55:04 +00:00
Lennart Poettering
63091fa38c Merge pull request #31319 from poettering/journal-tighten-memfd-flags
journald: tighten checks on incoming memfds a bit
2024-02-14 14:40:46 +01:00