1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00
Commit Graph

78217 Commits

Author SHA1 Message Date
Yu Watanabe
04fa5c1580 udev-config: introduce UdevConfig
Then, save configurations by their source: udev.conf, command line
arguments, kernel command line options, and udev control.

Preparation to support reloading udev.conf in a later commit.
2024-12-19 12:28:44 +09:00
Yu Watanabe
394a678aec udev: move parsers for config file, kerenel command line, and positional arguments to udev-config.c
No functional change, just refactoring and preparation for later
commits.
2024-12-19 12:28:44 +09:00
Lennart Poettering
0d1ebcf67d
networkd-sysctl: tweak error handling and log level a bit (#35673) 2024-12-18 18:20:30 +01:00
Mike Yuan
cffae6e113
networkd-sysctl: tweak error handling and log level a bit
Follow-up for 6d9ef22acd

- Downgrade log level for bpf not installed or kernel version
  being too old to LOG_DEBUG. Otherwise, on kernels older than 6.12
  the log becomes quite annoying.
- Always propagate the error and ignore only on caller's side.
  The current style is a messy mix.
2024-12-18 16:38:54 +01:00
Daan De Meyer
a48803fd84 man: Document generator sandbox environment 2024-12-19 00:36:52 +09:00
Mike Yuan
22583a002e
networkd-sysctl: rename functions to match our typical prefixes 2024-12-18 16:36:24 +01:00
Yu Watanabe
be1bcb85ce
ptyfwd: several cleanups (#35663) 2024-12-19 00:35:42 +09:00
Yu Watanabe
85d040dabd update-utmp: do not give up if the first attempt at connecting bus failed
Otherwise, the program exits with failure if the first attempt in run() failed:
```
Dec 18 20:27:37 systemd-update-utmp[254]: Bus n/a: changing state UNSET → OPENING
Dec 18 20:27:37 systemd-update-utmp[254]: sd-bus: starting bus by connecting to /run/systemd/private...
Dec 18 20:27:37 systemd-update-utmp[254]: Bus n/a: changing state OPENING → CLOSED
Dec 18 20:27:37 systemd-update-utmp[254]: Failed to get D-Bus connection: Connection refused
```
2024-12-19 00:34:38 +09:00
Yu Watanabe
67e5622bfe TEST-50-DISSECT: notify message cannot be sent by ncat
Follow-up for d0a63cf041.

The command ncat may be already dead when the service manager receives
the notify message. Hence, the service cannot be found by the sender PID,
and the notify message will be ignored.
```
Dec 17 03:26:49 systemd[1]: Cannot find unit for notify message of PID 1159, ignoring.
Dec 17 03:26:49 systemd[1]: Received SIGCHLD from PID 1152 (bash).
Dec 17 03:26:49 systemd[1]: Child 1152 (bash) died (code=exited, status=0/SUCCESS)
Dec 17 03:26:49 systemd[1]: run-p1151-i1451.service: Child 1152 belongs to run-p1151-i1451.service.
Dec 17 03:26:49 systemd[1]: run-p1151-i1451.service: Main process exited, code=exited, status=0/SUCCESS (success)
Dec 17 03:26:49 systemd[1]: run-p1151-i1451.service: Failed with result 'protocol'.
Dec 17 03:26:49 systemd[1]: run-p1151-i1451.service: Service will not restart (restart setting)
Dec 17 03:26:49 systemd[1]: run-p1151-i1451.service: Changed start -> failed
```

This also drops unnecessary --pipe option and redundant check by 'env' command.
2024-12-18 15:50:02 +01:00
Morten Hauke Solvang
0da73fab56 resolved: if one transaction completes, expect other transactions within candidate to succeed quickly
Fixes #22575, as suggested by poettering in #35514.

Intended as a workaround for some buggy routers, which refuse to send empty
replies. If systemd-resolved starts two DnsTransactions, one for A and one
for AAAA, and the domain in question has no AAAA entry, then the server will
send a reply for A and no reply for AAAA. Correct behavior for the server would
be to send an empty reply for AAAA.

systemd-resolved would previously keep retrying the AAAA transaction, and
eventually timeout the whole query, returning an error to the caller.

Now, if the server replies to one query and not another, we cut short the
timeout and return the partial result. Returning the partial result allows
the rest of the system to keep working. It matches how e.g. glibc libnss_dns
behaves.
2024-12-18 15:43:46 +01:00
Daan De Meyer
1152826e8d test-firewall-util: Migrate to new assertion macros 2024-12-18 22:03:05 +09:00
Yu Watanabe
d6d98a0c01
udev: make builtins take UdevEvent object (#35625)
No functional change, just refactoring.
2024-12-18 22:02:22 +09:00
Yu Watanabe
114453d795 data-fd-util: drop dead code
Also drops unnecessary header inclusions.

Follow-ups for a87a9625f8.
Fixes CID#1568419.
2024-12-18 13:47:35 +01:00
Fabian Vogt
e61032bf47 tpm2-util: Also retry unsealing after policy_pcr returns PCR_CHANGED
It's not just Esys_Unseal that may fail due to PCR changes during the
session, but also Esys_PolicyPCR. Perform a retry in that case as well.

Fixes #35490
2024-12-18 13:34:55 +01:00
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
Michal Koutný
4c9f242a54 mkosi: Fix tools image package name 2024-12-18 11:08:06 +01:00
Lennart Poettering
7a8556b901
confext/sysext: add initrd-specific units (#35426)
In the rootfs these need to run after /var/lib/ has been set up. In the
initrd we want them to run as soon as possible so that they can be used
to customize setting up the rootfs.
2024-12-18 10:33:38 +01:00
Yu Watanabe
5830d34b40 core: drop unnecessary header inclusion
Follow-up for e76fcd0e40.
2024-12-18 09:30:25 +01:00
Yu Watanabe
80080f34f3 TEST-07-PID1: fix typo
Follow-up for e76fcd0e40.
2024-12-18 10:46:51 +09: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
be883be6d3
remove fallbacks for memfd-less kernels (#35605)
Let the culling continue: let's remove support for kernels that lack
memfd, i.e. pre-3.17 kernels.

This is a nice simplification of things.
2024-12-17 23:01:29 +01:00
Nick Rosbrook
96c4d9d94d test: skip TEST-69-SHUTDOWN on ubuntu too 2024-12-17 19:04:04 +00:00
Lennart Poettering
3ee8082947 update TODO 2024-12-17 18:26:15 +01:00
Lennart Poettering
6db5a6e799 doc: document new baseline requires memfd_create() 2024-12-17 18:26:15 +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