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

71164 Commits

Author SHA1 Message Date
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
Yu Watanabe
489326e25b
Merge pull request #31314 from yuwata/network-ndisc-check-conflicting-address
network/ndisc: check conflicting address
2024-02-14 22:19:05 +09:00
Luca Boccassi
311efaae25 meson: do not attempt to install tests when they are disabled
If -Dtests=false but -Dinstall-tests=true the build will fail, as some tests will
be pulled in the build but not their prerequisites. It doesn't make sense to ask
for tests to be installed if they are disabled.

FAILED: test-acd
cc  -o test-acd test-acd.p/src_libsystemd-network_test-acd.c.o -flto -Wl,--as-needed -Wl,--no-undefined -pie -fstack-protector -Wl,-z,relro -specs=/usr/share/debhelper/dh_package_notes/debian-package-notes.specs -g -O2 -ffile-prefix-map=/tmp/s=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -ffat-lto-objects -Wdate-time -D_FORTIFY_SOURCE=2 '-Wl,-rpath,$ORIGIN/src/shared:XXXXXXXXXXXXXXX' -Wl,-rpath-link,/tmp/s/obj-x86_64-linux-gnu/src/shared -Wl,--start-group src/shared/libsystemd-shared-255.so src/libsystemd-network/libsystemd-network.a -Wl,--end-group -Wl,--fatal-warnings -Wl,-z,now -Wl,-z,relro -Wl,--warn-common -Wl,--gc-sections -Wl,--fatal-warnings -Wl,-z,now -Wl,-z,relro -Wl,--warn-common -Wl,--gc-sections
/usr/bin/ld: /tmp/cc0oYwFZ.ltrans0.ltrans.o: in function `main':
./obj-x86_64-linux-gnu/./obj-x86_64-linux-gnu/<artificial>:85:(.text.startup+0x33): undefined reference to `test_setup_logging'
collect2: error: ld returned 1 exit status
2024-02-14 12:41:09 +01:00
Lennart Poettering
296de3867c journald: rebreak some comments 2024-02-14 11:00:18 +01:00
Lennart Poettering
1f47e27a29 journald: when getting journal data via memfd, check flags are valid
Add some extra safety checks: refuse weird open flags.

And while we are at it, also use stat_verify_regular()
2024-02-14 11:00:08 +01:00
Emanuele Giuseppe Esposito
01fd84111f bootctl: discover and pring global UKI PE addons
An UKI final command line is not just made of the content of .cmdline,
but also from the addons that are inserted in
/boot/efi/EFI/Linux/<UKI_NAME>.efi.extra.d (local addons) and /boot/efi/loader/addons
(global addons).

Therefore bootclt "status" and "list" should also include these addons
when printing the UKI command line.

Support for /boot/efi/EFI/Linux/<UKI_NAME>.efi.extra.d is already present,
so now cover addons present in /boot/efi/loader/addons (global addons).

Example (assume UKI_NAME=devel):
$ bootctl
ukiCmdline: console=tty0 console=ttyS0
  globalAddon: loader/addons/global.addon.efi
      cmdline: └─quiet
   localAddon: devel.efi.extra.d/rpm_addon.addon.efi
      cmdline: └─this is a normal addon
 finalCmdline: console=tty0 console=ttyS0 quiet this is a normal addon
2024-02-14 04:58:28 -05:00
Emanuele Giuseppe Esposito
122650b4a0 bootctl: discover local UKI PE addons
An UKI final command line is not just made of the content of .cmdline,
but also from the addons that are inserted in
/boot/efi/EFI/Linux/<UKI_NAME>.efi.extra.d (local addons) and
/boot/efi/loader/addons (global addons).

Therefore bootclt "status" and "list" should also include these addons
when printing the UKI command line.

Right now, discover addons present in
/boot/efi/EFI/Linux/<UKI_NAME>.efi.extra.d.

Example output (assume UKI_NAME=devel):
$ bootctl
ukiCmdline: console=tty0 console=ttyS0
   localAddon: devel.efi.extra.d/rpm_addon.addon.efi
      cmdline: └─this is a normal addon
 finalCmdline: console=tty0 console=ttyS0 this is a normal addon
2024-02-14 04:58:20 -05:00
Emanuele Giuseppe Esposito
ebd1a30093 bootspec: refactor find_sections
Prepare for the incoming changes that introduce PE addons support.
Addons will contain a .cmdline section, but not .osrel.
2024-02-14 04:56:42 -05:00
Lennart Poettering
a050dc507c update TODO 2024-02-14 10:56:35 +01:00
Franck Bui
08abfd0b8c test: make sure to install the filesystem package in the test image on SUSE
Othewise test images are missing the tmpfiles snippets used to create the very
basic files at boot, which can be useful when a test wants to reuse the OS tree
(is already running in) for spawning a new container in pristine state.
2024-02-14 10:21:33 +01:00
Adrian Vovk
c425c8854f hashmap: Add helper to dump sorted keys
Currently, hashmap_dump_sorted sorts by key and then returns the values
in order sorted by key. This commit adds another helper that does the
same but returns the sorted keys instead
2024-02-14 09:35:36 +01:00
Yu Watanabe
d1cde7f051 sd-journal: drop unused function prototype
Follow-up for 8b4fbbb0a1.

The function was renamed and moved by
035b0f8fe8.
Maybe the prototype is mistakenly re-introduced on rebase.
2024-02-14 09:31:13 +01:00
Mike Yuan
872ffc8a82 core/load-fragment: modernize config_parse_socket_listen
Prompted by #31304
2024-02-14 09:23:07 +01:00
Lennart Poettering
64e18af731
Merge pull request #31206 from AdrianVovk/user-record-fields
Added some more user record fields
2024-02-14 09:22:23 +01:00
Adrian Vovk
83b4576195 env-util: Add helper to store current log level
This is useful after a fork but before an exec into a binary that uses
systemd's logging utilities. For example, this should be used in dbus
services that fork off worker processes: currently, the log level set by
the LogControl dbus API will be lost because of the exec, and the worker
process will not have the correct log level set.
2024-02-14 09:21:45 +01:00
Lennart Poettering
2fe27f966f
Merge pull request #31297 from AdrianVovk/sha256-util-lib
basic: Add some sha256 helper functions
2024-02-14 09:19:56 +01:00
Yu Watanabe
8bd473ff25 core: allow to specify /dev/rfkill for ListenSpecial=
Follow-up for 8049bce619.

Fixes #31294.
2024-02-14 09:14:59 +01:00
Adrian Vovk
80d07162e7 format-utils: Expose FORMAT_UID and FORMAT_GID
This pulls this generally useful helper out of sysusers and into the
util lib, and updates the places throughout the codebase where it makes
sense to use it.
2024-02-14 09:14:13 +01:00
Adrian Vovk
e2a40cc7b9 homed: Add some missing asserts
These functions expect secrets to be passed in (some even dereference
the variables), but fail to assert that they're non-null. So this commit
adds some assertions
2024-02-14 09:13:46 +01:00
Yu Watanabe
e720ad88f3 network/ndisc: check if there exists a conflicting address
Follow-up for 0a0c2672db.

Before the commit, if a conflicting address exists or already requested,
then the configuration of newly requested address (especially, prefix
length) is mostly ignored silently.

However, after the commit, even if there exists a conflicting address,
networkd anyway tries to configure the newly requested address, and
enter failed state. Such situation can be triggered, e.g. when the DHCPv6
client is started earlier than NDisc, by WithoutRA=solicit.

Fixes #31263.
2024-02-14 13:59:04 +09:00
Yu Watanabe
9e79ef9120 network/ndisc: drop unnecessary ownership transfer
Follow-up for e217da1380.
2024-02-14 13:59:04 +09:00
Yu Watanabe
77de62f96c network/dhcp6: use address_can_update() at one more place
In address_can_update(), only prefix length is checked for IPv6
addresses. So, this should not change any behavior.
2024-02-14 13:59:04 +09:00
Yu Watanabe
a45e1c35e3 network/address: drop requirement of Address.link and .network in address_can_update()
This also rename arguments.
No functional change, just refactoring.
2024-02-14 13:59:04 +09:00
Adrian Vovk
49e55abb7f
user-record: Add languages field
This field is like preferredLanguage, but takes a priority list of
languages instead. If an app isn't translated into a user's primary
language, it can fall back to one of the other languages in the list
thus making the app more accessible to the user.

For instance: in my experience, many Ukrainians are fluent in Russian,
often significantly better than English (especially if they are of a
generation that grew up during the USSR). Such a person might set this
new variable to ["uk_UA.UTF-8", "ru_UA.UTF-8"] so that software that
lacks Ukrainian translations will first try Russian translations before
defaulting to English.

Fixes #31290
2024-02-13 17:39:14 -05:00
Adrian Vovk
fa485e8fc5
locale-util: Restrict valid locales
This further restricts the charset of locales to better reflect what
locales actually look like.

This allows us to safely join locale names using the `:` character, for
instance, which cannot appear in a locale name and is used by the
`$LANGUAGE` env var
2024-02-13 17:31:36 -05:00
Adrian Vovk
592ca6f0ef
pam_systemd: Let user record override env vars
The user record should be the source of truth for the user's environment
variables, and the user should be able to override them in much the same
way that they can if they simply append the variable to their ~/.profile

For example, before $LANG would never get set to the user's preferred
language, because the service manager always ensures that $LANG is set
to something (either the localed config, or a compiled-in default). Thus
the user's preferredLanguage setting was always ignored
2024-02-13 17:31:35 -05:00
Luca Boccassi
e1390da025 varlink: fix dead code
'e' is already checked in the previous branch, no need to check it again,
it cannot be NULL.

CID#1534465

Follow-up for 9bca989183
2024-02-13 21:43:59 +00:00
Yu Watanabe
604b200108 test: fix typo
Follow-up for d02018afdb.
2024-02-14 04:04:12 +09:00
Yu Watanabe
964756923b test: fix typo
Follow-up for 3456c89ac2.
2024-02-14 04:03:09 +09:00
Yu Watanabe
a14d3b48f7 cryptsetup: fix typo
Follow-up for c5daf14c88.
2024-02-14 04:01:52 +09:00
Adrian Vovk
0bac442251
basic: Add some sha256 helper functions
Adds a util function to sha256 an open fd (moved from dissect). Also
adds functions to check if a string contains a valid sha256 hash, and
parse it into a sha256 array.
2024-02-13 13:59:27 -05:00
Yu Watanabe
dcd484e545 tools: fix typo
Follow-up for 6d55e3a364.
2024-02-14 03:58:35 +09:00
Frantisek Sumsal
5b1aa0e19a core: escape spaces when serializing as well
Otherwise they might get stripped when reading the serialized data back.

Resolves: #31214
2024-02-14 02:22:58 +08:00
Adrian Vovk
a7a67dfd9d
fundamental: Add overflow-safe math helpers
ADD_SAFE/SUB_SAFE/MUL_SAFE do addition/subtraction/multiplication
respectively with an overflow check. If an overflow occurs these return
false, otherwise true. Example: (c = a + b) would become ADD_SAFE(&c, a,
b)

INC_SAFE/DEC_SAFE/MUL_ASSIGN_SAFE are like above but they also reassign
the first argument. Example: (a += b) would become INC_SAFE(&a, b)
2024-02-13 13:08:20 -05:00