1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-21 22:04:01 +03:00

52463 Commits

Author SHA1 Message Date
Lennart Poettering
9aee971185 tree-wide: use pidref_is_self() at more places 2024-12-18 13:34:35 +01:00
Yu Watanabe
64b504bde3 machinectl: explicitly assign PTY forwarder to sd_bus_slot
No functional change, just refactoring.
2024-12-18 20:28:28 +09:00
Yu Watanabe
12807b5a49 ptyfwd: always flush buffer and disconnect before exit
Then, it is not necessary to manually drain PTY forwarder by the user
side. Also, not necessary to free PTY forwarder earlier explicitly to
make it disconnected.
2024-12-18 20:28:07 +09:00
Yu Watanabe
4a4e7ec0e9 ptyfwd: always write additional line break on stop
Currently we do that in the user of PTY forwarder, e.g. nspawn.
But, let's do that unconditionally in the PTY forwarder.
2024-12-18 20:26:58 +09:00
Yu Watanabe
d517427dff ptyfwd: save the last character before the escape sequence
If we write e.g. a line break and CSI sequence, then it is not necessary
to write another line break on exit.
2024-12-18 19:55:46 +09:00
Yu Watanabe
5e6a48bf99 ptyfwd: do not forward partial escape sequence
Otherwise, if the sender is killed while writing escape sequence,
we may get spurious output.
2024-12-18 19:55:37 +09:00
Yu Watanabe
781c8c3f72 ptyfwd: coding style fix
- replace 'type *func()' -> 'type* func()',
- rename output argument to 'ret'.
2024-12-18 19:45:46 +09:00
Yu Watanabe
5830d34b40 core: drop unnecessary header inclusion
Follow-up for e76fcd0e40a6910f4818a374c6a8d854d644ff93.
2024-12-18 09:30:25 +01:00
Lennart Poettering
4f6086ceb4
pam_systemd: some refactorings and bugfixes (#35178)
Inspired at #35171 I had another closer look at pam_systemd, and found a
bunch of things to fix, and correct.
2024-12-17 23:02:00 +01:00
Lennart Poettering
25b1a73f71 journald: get rid of get_process_capeff(), use pidref_get_capability() instead
This does pretty much the same, but is nicer, since it parses things
properly.
2024-12-17 19:06:54 +01:00
Lennart Poettering
a5370d35d6 capability-util: introduce capability_is_set() helper 2024-12-17 19:06:54 +01:00
Lennart Poettering
1184626a26 capability-util: generalize helper to acquire local caps
This generalizes and modernizes the code to acquire set of local caps,
based on the code for this in the condition logic. Uses PidRef, and
acquires the full quintuplet of caps.

This can be considered preparation to one day maybe build without
libcap.
2024-12-17 19:06:54 +01:00
Lennart Poettering
4dac692094 fuzz-journal-remote: use memfd_new_and_seal() where appropriate
This means we can drop memfd_new_and_map() and results in generally
shorter code.
2024-12-17 18:26:15 +01:00
Lennart Poettering
65d9ef40f2 pid1: drop check that ensures /run/ has plenty space before reexec/reload
Now that we only support serialization into a memfd (rather than a file
in /run/) there's no point to check the free space in /run/. Let's drop it.

One error scenario gone. Yay.
2024-12-17 18:26:15 +01:00
Lennart Poettering
d54bbc4cdc memfd-util: trivial modernizations 2024-12-17 18:26:15 +01:00
Lennart Poettering
5d1e57b820 serialize: add explicit calls for finishing serialization
These new calls will do three things:

1. in case of FILE* stuff: flush any pending bytes onto the fd, just in
   case
2. seal the backing memfd
3. seek back to the beginning.

Note that this adds sealing to serialization: once we serialized fully,
we'll seal the thing off for further modifications, before we pass the
fd over to the target process. This should add a bit of robustness, and
maybe finds a bug or two one day, if we accidentally write to a
serialization that is complete.
2024-12-17 18:26:15 +01:00
Lennart Poettering
4d98709cb2 memfd-util: introduce memfd_new_full() helper
This is just like memfd_new(), but allows fine grained control of the
sealing flags.

This switches over all uses of memfd_new() where we actually want
sealing to use memfd_new_full().

This then allows use to use memfd_new() for two further calls, where we
previously used the more lowlevel memfd_create_wrapper().
2024-12-17 18:26:15 +01:00
Lennart Poettering
9b1d97cccd memfd-util: explain what memfd_create_wrapper() is for in a comment 2024-12-17 18:26:15 +01:00
Lennart Poettering
caf1436ee8 memfd-util: use TASK_COMM_LEN at one more place
Note this corrects the size of the array from 17 to 16, as the 16
already includes space for a trailing NUL.
2024-12-17 18:26:15 +01:00
Lennart Poettering
ce66a2f2bb sd-journal: drop memfd fallback 2024-12-17 18:26:15 +01:00
Lennart Poettering
52cd287933 serialize: drop memfd fallback when serializing 2024-12-17 18:26:15 +01:00
Lennart Poettering
e1c52c9238 memfd-util: short memfd_clone_fd() 2024-12-17 18:26:15 +01:00
Lennart Poettering
db5381c49c memfd-util: simplify memfd_new_and_seal()
Let's use pwrite() to write the contents of the memfd. This has the
benefit of not moving the file offset, which means we don't have to
reset it after at all.
2024-12-17 18:26:15 +01:00
Lennart Poettering
a87a9625f8 tree-wide: drop acquire_data_fd_full() helper
Let's drop support systems lacking memfds, i.e. pre kernel 3.17 systems.
This allows us to drastically simplify the "data fd" concept, so far
that we can remove it entirely.

This replaces acquire_data_fd() with a specialized call to
memfd_new_and_seal(), not that memfds can be the only implementation of
the concept.
2024-12-17 18:26:15 +01:00
Lennart Poettering
f07fe275d5 pam_systemd: introduce pam_get_data_many() helper and make use of it
This is to pam_get_data() what pam_get_item() is to pam_get_item_many().
2024-12-17 17:52:23 +01:00
Lennart Poettering
7f471bd3b2 pam_systemd: fix error code confusion when prepping D-Bus message
We got confused by the error codes here, and sometimes return PAM errors
where the caller propagated them unconverted as negative errno errors. Fix that.
2024-12-17 17:52:21 +01:00
Lennart Poettering
32580792df pam_systemd: split pam_sm_open_session() into more digestable blocks
Let's separate four different parts of pam_sm_open_session():

1. Acquiring of our various parameters from pam env, pam data, pam items
2. Mangling of that data to clean it up
3. Registering of the service with logind
4. Importing shell credentials into environment variables
5. Enforcement of user record data

This makes the code a lot more readable, and gets rid of an ugly goto
label.

It also corrects things: if step 3 doesnt work because logind is not
around, we'll now still do step 4, which we previously erroneously
skipped.

Besides that no real code changes.
2024-12-17 17:52:18 +01:00
Lennart Poettering
166a678fea pam_systemd: split out setting of shell env vars from credentials and move it later
Let's shorten the code of pam_sm_open_session() a bit, and also make
sure the importing of the env vars from the creds also happens if the
session registration with logind is skipped.
2024-12-17 17:52:14 +01:00
Lennart Poettering
5e782e4de3 pam_systemd: drop "uid" field from SessionContext
Let's instead just pass over the UserRecord, it's a much more useful
object with lots more information we'll sooner or later need
(preparation for later commits).
2024-12-17 17:52:11 +01:00
Lennart Poettering
014d23c395 pam_systemd: drop "pid" field from SessionContext
We never use the field and this is not going to change...

This addresses a weird asymmetry, as create_session_message() always
went to the process' own PID when doing pidfds but otherwise (i.e.
without pidfds) would honour the PID specified as function parameter.
2024-12-17 17:52:08 +01:00
Lennart Poettering
6082ccf792 pam_systemd: normalize parsing of XDG_VTNR
Let's make it more like the parsing of the "incomplete" boolean env var,
to streamline things.
2024-12-17 17:51:57 +01:00
Lennart Poettering
8d08f18b52
discover-image: modernize image discovery around O_PATH (#35513)
let's always pin the image fd as early as we can, then derive all
properties off it, to have a consistent view on things.
2024-12-17 17:39:59 +01:00
Lennart Poettering
00a415fc8f tree-wide: remove support for kernels lacking ambient caps
Let's bump the kernel baseline a bit to 4.3 and thus require ambient
caps.

This allows us to remove support for a variety of special casing, most
importantly the ExecStart=!! hack.
2024-12-17 17:34:46 +01:00
Daan De Meyer
96ec3911f3
machine: introduce io.systemd.Machine.{MapFrom, MapTo} methods (#35064)
This PR introduces varlink's alternatives to the following DBus methods:
- MapFromMachineUser
- MapToMachineUser
- MapFromMachineGroup
- MapToMachineGroup
2024-12-17 16:51:51 +01:00
Antonio Alvarez Feijoo
5aab7ad075 boot: do not build test-hwids-section.c if ukify is disabled
Otherwise the build fails:

```
[22/3075] Generating src/boot/test-hwids-section.c with a custom command (wrapped by meson to capture output)
FAILED: src/boot/test-hwids-section.c
/usr/bin/meson --internal exe --capture src/boot/test-hwids-section.c -- /usr/bin/python3.10 /mnt/work/systemd/upstream-fork/main/src/boot/generate-hwids-section.py /mnt/work/systemd/upstream-fork/main/src/boot/hwids
--- stderr ---
Traceback (most recent call last):
  File "/mnt/work/systemd/upstream-fork/main/src/boot/generate-hwids-section.py", line 12, in <module>
    import ukify
  File "/mnt/work/systemd/upstream-fork/main/src/boot/../ukify/ukify.py", line 61, in <module>
    import pefile  # type: ignore
ModuleNotFoundError: No module named 'pefile'
```

Follow-up for 640f8c3eb8dc21539500e92a5c69cdb6cbda3381
2024-12-17 11:15:39 +00:00
Ivan Kruglov
8351463f67 machine: introduce io.systemd.Machine.{MapFrom, MapTo} methods 2024-12-17 11:25:24 +01:00
Lennart Poettering
98e28335b7 discover-image: modernize image discovery around O_PATH
let's always pin the image fd as early as we can, then derive all
properties off it, to have a consistent view on things.
2024-12-17 11:21:57 +01:00
Lennart Poettering
476b7c3a68 discover-image: make sure quota logic works on O_PATH fds 2024-12-17 11:21:57 +01:00
Lennart Poettering
abeedbde90 btrfs-util: make sure btrfs_subvol_get_info_fd() works on O_PATH fds 2024-12-17 11:21:57 +01:00
Lennart Poettering
e837c257d0 chattr-util: move O_PATH conversion from read_attr_at() to read_attr_fd() 2024-12-17 11:19:55 +01:00
Yu Watanabe
c195fdba12
test: Add CHID matching test (#35532) 2024-12-17 13:21:04 +09:00
Yu Watanabe
47f58740aa
core: make ProtectHostname= optionally take a hostname (#35626)
Closes #35623.
2024-12-17 13:20:08 +09:00
Yu Watanabe
b58b00e4c3 systemctl-edit: ignore ENOENT from unit_is_masked()
If a specified unit does not exist, then it is definitely not masked.

Fixes #35632.
2024-12-17 13:19:35 +09:00
Yu Watanabe
a4d1891475 meson: allow to customize the access mode for tty/pts devices
Then, switch the default value to "0600", due to general security
concerns about terminals being written to by other users.

Closing #35599.
2024-12-16 21:36:07 +00:00
Lennart Poettering
0543b02cf8 networkd: show wireguard private key read error number
Noticed while looking at #35641
2024-12-16 18:54:57 +00:00
anonymix007
640f8c3eb8 test: Add test-chid-match 2024-12-16 21:02:54 +03:00
Yu Watanabe
7c4e351861 boot: introduce smbios_raw_info_get_cached() to cache populated SMBIOS raw info
Then, drop cache in smbios_info_populate().
No functional change, just refactoring and preparation for later commit.
2024-12-16 21:02:54 +03:00
anonymix007
f28cedfa31 boot: Add chid.c to libefitest
Also fix compilation for testing CHID matching in userspace
2024-12-16 21:02:54 +03:00
anonymix007
48acd7fe90 boot: Deduplicate efi.h and efi-fundamental.h
These definitions are needed for both userspace and EFI, so keep them in efi-fundamental.h
2024-12-16 21:02:54 +03:00
Yu Watanabe
e76fcd0e40 core: make ProtectHostname= optionally take a hostname
Closes #35623.
2024-12-16 23:55:44 +09:00