]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
10 months agonetworkd-sysctl: tweak error handling and log level a bit 35673/head
Mike Yuan [Wed, 18 Dec 2024 13:34:59 +0000 (14:34 +0100)] 
networkd-sysctl: tweak error handling and log level a bit

Follow-up for 6d9ef22acdeac4b429efb75164341233955484af

- 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.

10 months agonetworkd-sysctl: rename functions to match our typical prefixes
Mike Yuan [Wed, 18 Dec 2024 13:26:39 +0000 (14:26 +0100)] 
networkd-sysctl: rename functions to match our typical prefixes

10 months agoptyfwd: several cleanups (#35663)
Yu Watanabe [Wed, 18 Dec 2024 15:35:42 +0000 (00:35 +0900)] 
ptyfwd: several cleanups (#35663)

10 months agoupdate-utmp: do not give up if the first attempt at connecting bus failed
Yu Watanabe [Wed, 18 Dec 2024 13:27:29 +0000 (22:27 +0900)] 
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
```

10 months agoTEST-50-DISSECT: notify message cannot be sent by ncat
Yu Watanabe [Tue, 17 Dec 2024 06:09:47 +0000 (15:09 +0900)] 
TEST-50-DISSECT: notify message cannot be sent by ncat

Follow-up for d0a63cf0412ccb9b4edd1f6048e25aa7f68b0133.

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.

10 months agoresolved: if one transaction completes, expect other transactions within candidate...
Morten Hauke Solvang [Thu, 12 Dec 2024 13:26:31 +0000 (14:26 +0100)] 
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.

10 months agotest-firewall-util: Migrate to new assertion macros
Daan De Meyer [Wed, 18 Dec 2024 10:42:37 +0000 (11:42 +0100)] 
test-firewall-util: Migrate to new assertion macros

10 months agoudev: make builtins take UdevEvent object (#35625)
Yu Watanabe [Wed, 18 Dec 2024 13:02:22 +0000 (22:02 +0900)] 
udev: make builtins take UdevEvent object (#35625)

No functional change, just refactoring.

10 months agodata-fd-util: drop dead code
Yu Watanabe [Wed, 18 Dec 2024 02:55:47 +0000 (11:55 +0900)] 
data-fd-util: drop dead code

Also drops unnecessary header inclusions.

Follow-ups for a87a9625f8bde776ece11b8ddb77588cfff73038.
Fixes CID#1568419.

10 months agotpm2-util: Also retry unsealing after policy_pcr returns PCR_CHANGED
Fabian Vogt [Mon, 16 Dec 2024 18:08:13 +0000 (19:08 +0100)] 
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

10 months agotree-wide: use pidref_is_self() at more places
Lennart Poettering [Tue, 19 Nov 2024 14:54:28 +0000 (15:54 +0100)] 
tree-wide: use pidref_is_self() at more places

10 months agomachinectl: explicitly assign PTY forwarder to sd_bus_slot 35663/head
Yu Watanabe [Wed, 18 Dec 2024 04:35:54 +0000 (13:35 +0900)] 
machinectl: explicitly assign PTY forwarder to sd_bus_slot

No functional change, just refactoring.

10 months agoptyfwd: always flush buffer and disconnect before exit
Yu Watanabe [Wed, 18 Dec 2024 02:14:06 +0000 (11:14 +0900)] 
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.

10 months agoptyfwd: always write additional line break on stop
Yu Watanabe [Wed, 18 Dec 2024 02:12:57 +0000 (11:12 +0900)] 
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.

10 months agoptyfwd: save the last character before the escape sequence
Yu Watanabe [Wed, 18 Dec 2024 02:10:47 +0000 (11:10 +0900)] 
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.

10 months agoptyfwd: do not forward partial escape sequence
Yu Watanabe [Wed, 18 Dec 2024 02:06:07 +0000 (11:06 +0900)] 
ptyfwd: do not forward partial escape sequence

Otherwise, if the sender is killed while writing escape sequence,
we may get spurious output.

10 months agoptyfwd: coding style fix
Yu Watanabe [Tue, 17 Dec 2024 06:37:10 +0000 (15:37 +0900)] 
ptyfwd: coding style fix

- replace 'type *func()' -> 'type* func()',
- rename output argument to 'ret'.

10 months agomkosi: Fix tools image package name
Michal Koutný [Wed, 18 Dec 2024 09:36:55 +0000 (10:36 +0100)] 
mkosi: Fix tools image package name

10 months agoconfext/sysext: add initrd-specific units (#35426)
Lennart Poettering [Wed, 18 Dec 2024 09:33:38 +0000 (10:33 +0100)] 
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.

10 months agocore: drop unnecessary header inclusion
Yu Watanabe [Wed, 18 Dec 2024 02:01:35 +0000 (11:01 +0900)] 
core: drop unnecessary header inclusion

Follow-up for e76fcd0e40a6910f4818a374c6a8d854d644ff93.

10 months agoTEST-07-PID1: fix typo
Yu Watanabe [Wed, 18 Dec 2024 01:46:14 +0000 (10:46 +0900)] 
TEST-07-PID1: fix typo

Follow-up for e76fcd0e40a6910f4818a374c6a8d854d644ff93.

10 months agopam_systemd: some refactorings and bugfixes (#35178)
Lennart Poettering [Tue, 17 Dec 2024 22:02:00 +0000 (23:02 +0100)] 
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.

10 months agoremove fallbacks for memfd-less kernels (#35605)
Lennart Poettering [Tue, 17 Dec 2024 22:01:29 +0000 (23:01 +0100)] 
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.

10 months agotest: skip TEST-69-SHUTDOWN on ubuntu too
Nick Rosbrook [Tue, 17 Dec 2024 16:10:42 +0000 (11:10 -0500)] 
test: skip TEST-69-SHUTDOWN on ubuntu too

10 months agoupdate TODO 35605/head
Lennart Poettering [Fri, 13 Dec 2024 18:52:33 +0000 (19:52 +0100)] 
update TODO

10 months agodoc: document new baseline requires memfd_create()
Lennart Poettering [Fri, 13 Dec 2024 18:08:16 +0000 (19:08 +0100)] 
doc: document new baseline requires memfd_create()

10 months agofuzz-journal-remote: use memfd_new_and_seal() where appropriate
Lennart Poettering [Mon, 16 Dec 2024 11:18:17 +0000 (12:18 +0100)] 
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.

10 months agopid1: drop check that ensures /run/ has plenty space before reexec/reload
Lennart Poettering [Mon, 16 Dec 2024 10:48:19 +0000 (11:48 +0100)] 
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.

10 months agomemfd-util: trivial modernizations
Lennart Poettering [Mon, 16 Dec 2024 10:32:07 +0000 (11:32 +0100)] 
memfd-util: trivial modernizations

10 months agoserialize: add explicit calls for finishing serialization
Lennart Poettering [Mon, 16 Dec 2024 10:29:52 +0000 (11:29 +0100)] 
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.

10 months agomemfd-util: introduce memfd_new_full() helper
Lennart Poettering [Mon, 16 Dec 2024 10:28:46 +0000 (11:28 +0100)] 
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().

10 months agomemfd-util: explain what memfd_create_wrapper() is for in a comment
Lennart Poettering [Mon, 16 Dec 2024 10:27:58 +0000 (11:27 +0100)] 
memfd-util: explain what memfd_create_wrapper() is for in a comment

10 months agomemfd-util: use TASK_COMM_LEN at one more place
Lennart Poettering [Mon, 16 Dec 2024 10:04:03 +0000 (11:04 +0100)] 
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.

10 months agosd-journal: drop memfd fallback
Lennart Poettering [Fri, 13 Dec 2024 18:05:41 +0000 (19:05 +0100)] 
sd-journal: drop memfd fallback

10 months agoserialize: drop memfd fallback when serializing
Lennart Poettering [Fri, 13 Dec 2024 17:59:15 +0000 (18:59 +0100)] 
serialize: drop memfd fallback when serializing

10 months agomemfd-util: short memfd_clone_fd()
Lennart Poettering [Fri, 13 Dec 2024 17:55:59 +0000 (18:55 +0100)] 
memfd-util: short memfd_clone_fd()

10 months agomemfd-util: simplify memfd_new_and_seal()
Lennart Poettering [Fri, 13 Dec 2024 17:55:00 +0000 (18:55 +0100)] 
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.

10 months agotree-wide: drop acquire_data_fd_full() helper
Lennart Poettering [Fri, 13 Dec 2024 17:51:34 +0000 (18:51 +0100)] 
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.

10 months agopam_systemd: introduce pam_get_data_many() helper and make use of it 35178/head
Lennart Poettering [Fri, 15 Nov 2024 14:23:41 +0000 (15:23 +0100)] 
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().

10 months agopam_systemd: fix error code confusion when prepping D-Bus message
Lennart Poettering [Fri, 15 Nov 2024 14:03:51 +0000 (15:03 +0100)] 
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.

10 months agopam_systemd: split pam_sm_open_session() into more digestable blocks
Lennart Poettering [Fri, 15 Nov 2024 13:25:59 +0000 (14:25 +0100)] 
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.

10 months agopam_systemd: split out setting of shell env vars from credentials and move it later
Lennart Poettering [Fri, 15 Nov 2024 14:08:15 +0000 (15:08 +0100)] 
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.

10 months agopam_systemd: drop "uid" field from SessionContext
Lennart Poettering [Fri, 15 Nov 2024 13:39:11 +0000 (14:39 +0100)] 
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).

10 months agopam_systemd: drop "pid" field from SessionContext
Lennart Poettering [Fri, 15 Nov 2024 13:36:22 +0000 (14:36 +0100)] 
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.

10 months agopam_systemd: normalize parsing of XDG_VTNR
Lennart Poettering [Fri, 15 Nov 2024 13:31:09 +0000 (14:31 +0100)] 
pam_systemd: normalize parsing of XDG_VTNR

Let's make it more like the parsing of the "incomplete" boolean env var,
to streamline things.

10 months agodiscover-image: modernize image discovery around O_PATH (#35513)
Lennart Poettering [Tue, 17 Dec 2024 16:39:59 +0000 (17:39 +0100)] 
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.

10 months agotree-wide: remove support for kernels lacking ambient caps
Lennart Poettering [Thu, 12 Dec 2024 12:42:12 +0000 (13:42 +0100)] 
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.

10 months agomachine: introduce io.systemd.Machine.{MapFrom, MapTo} methods (#35064)
Daan De Meyer [Tue, 17 Dec 2024 15:51:51 +0000 (16:51 +0100)] 
machine: introduce io.systemd.Machine.{MapFrom, MapTo} methods (#35064)

This PR introduces varlink's alternatives to the following DBus methods:
- MapFromMachineUser
- MapToMachineUser
- MapFromMachineGroup
- MapToMachineGroup

10 months agoboot: do not build test-hwids-section.c if ukify is disabled
Antonio Alvarez Feijoo [Tue, 17 Dec 2024 09:05:54 +0000 (10:05 +0100)] 
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

10 months agomachine: tests for io.systemd.Machine.{MapFrom, MapTo} methods 35064/head
Ivan Kruglov [Thu, 7 Nov 2024 10:09:14 +0000 (11:09 +0100)] 
machine: tests for io.systemd.Machine.{MapFrom, MapTo} methods

10 months agomachine: introduce io.systemd.Machine.{MapFrom, MapTo} methods
Ivan Kruglov [Thu, 7 Nov 2024 09:39:41 +0000 (10:39 +0100)] 
machine: introduce io.systemd.Machine.{MapFrom, MapTo} methods

10 months agodiscover-image: modernize image discovery around O_PATH 35513/head
Lennart Poettering [Mon, 9 Dec 2024 12:52:32 +0000 (13:52 +0100)] 
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.

10 months agodiscover-image: make sure quota logic works on O_PATH fds
Lennart Poettering [Mon, 9 Dec 2024 12:51:51 +0000 (13:51 +0100)] 
discover-image: make sure quota logic works on O_PATH fds

10 months agobtrfs-util: make sure btrfs_subvol_get_info_fd() works on O_PATH fds
Lennart Poettering [Mon, 9 Dec 2024 12:51:28 +0000 (13:51 +0100)] 
btrfs-util: make sure btrfs_subvol_get_info_fd() works on O_PATH fds

10 months agochattr-util: move O_PATH conversion from read_attr_at() to read_attr_fd()
Lennart Poettering [Mon, 9 Dec 2024 12:50:48 +0000 (13:50 +0100)] 
chattr-util: move O_PATH conversion from read_attr_at() to read_attr_fd()

10 months agoupdate TODO
Lennart Poettering [Tue, 17 Dec 2024 10:18:01 +0000 (11:18 +0100)] 
update TODO

10 months agotest: Add CHID matching test (#35532)
Yu Watanabe [Tue, 17 Dec 2024 04:21:04 +0000 (13:21 +0900)] 
test: Add CHID matching test (#35532)

10 months agocore: make ProtectHostname= optionally take a hostname (#35626)
Yu Watanabe [Tue, 17 Dec 2024 04:20:08 +0000 (13:20 +0900)] 
core: make ProtectHostname= optionally take a hostname (#35626)

Closes #35623.

10 months agosystemctl-edit: ignore ENOENT from unit_is_masked()
Yu Watanabe [Mon, 16 Dec 2024 03:37:17 +0000 (12:37 +0900)] 
systemctl-edit: ignore ENOENT from unit_is_masked()

If a specified unit does not exist, then it is definitely not masked.

Fixes #35632.

10 months agomeson: allow to customize the access mode for tty/pts devices
Yu Watanabe [Mon, 16 Dec 2024 02:50:53 +0000 (11:50 +0900)] 
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.

10 months agonetworkd: show wireguard private key read error number
Lennart Poettering [Mon, 16 Dec 2024 16:19:59 +0000 (17:19 +0100)] 
networkd: show wireguard private key read error number

Noticed while looking at #35641

10 months agomkosi: temporarily disable panic_on_warn
Luca Boccassi [Mon, 16 Dec 2024 17:13:08 +0000 (17:13 +0000)] 
mkosi: temporarily disable panic_on_warn

Due to a BTRFS issue in kernel 6.12 (and backported in Ubuntu to 6.8)
there's a warning triggered by some tests, and it then causes a panic.

The BTRFS issue has a patch but it is not available in any distro yet,
so disable panic_on_warn until it reaches Arch and Ubuntu Noble. Bugs
have been filed.

10 months agotest: Add test-chid-match 35532/head
anonymix007 [Thu, 12 Dec 2024 17:32:24 +0000 (20:32 +0300)] 
test: Add test-chid-match

10 months agoboot: introduce smbios_raw_info_get_cached() to cache populated SMBIOS raw info
Yu Watanabe [Mon, 16 Dec 2024 16:25:27 +0000 (01:25 +0900)] 
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.

10 months agoboot: Add chid.c to libefitest
anonymix007 [Thu, 12 Dec 2024 17:31:02 +0000 (20:31 +0300)] 
boot: Add chid.c to libefitest

Also fix compilation for testing CHID matching in userspace

10 months agoboot: Deduplicate efi.h and efi-fundamental.h
anonymix007 [Thu, 12 Dec 2024 20:56:56 +0000 (23:56 +0300)] 
boot: Deduplicate efi.h and efi-fundamental.h

These definitions are needed for both userspace and EFI, so keep them in efi-fundamental.h

10 months agohwdb: fix key toggle touchpad for VAIO VJFH52 (#35645)
Lucas Adriano Salles [Mon, 16 Dec 2024 15:10:42 +0000 (11:10 -0400)] 
hwdb: fix key toggle touchpad for VAIO VJFH52 (#35645)

Fixes #35644.

10 months agocore: make ProtectHostname= optionally take a hostname 35626/head
Yu Watanabe [Sun, 15 Dec 2024 01:36:42 +0000 (10:36 +0900)] 
core: make ProtectHostname= optionally take a hostname

Closes #35623.

10 months agocore/exec-invoke: fix ProtectHostname= value in log message
Yu Watanabe [Sun, 15 Dec 2024 01:00:06 +0000 (10:00 +0900)] 
core/exec-invoke: fix ProtectHostname= value in log message

Follow-up for cf48bde7aea52b18ac3fa218d3f60fd3d533ef66.

10 months agoudev: add option to trigger parent devices despite filters
Federico Giovanardi [Thu, 17 Oct 2024 13:29:51 +0000 (15:29 +0200)] 
udev: add option to trigger parent devices despite filters

This commit add the `-i` option to `udevadm trigger` that force it to
match parent devices even if they're excluded from filters.
The rationale is that some embedded devices have a huge number of
platform devices ( ~ 4k for MX8 ) they are there because they're defined
in the device tree but there isn't any action or udev rules associated
with them.

So at boot a significant time is spend triggering and processing rules
for devices that don't produce any effect and we would like to filter
them by calling:

```
udevadm trigger --type=device --action=add -s block -s tty
```

instead of the normal

```
udevadm trigger --type=device --action=add
```

so we can use filter to filter out only subsystems for we we know that
we have rules in place that do something useful.

On the other side action / rules are not triggered until the parent is
triggered ( which is part of another subsystem), so the additional option
will allows udev to complete the coldplug with only the devices we care.

Example on iMX8:

.Without the new option
```
root@dev:~# udevadm trigger --dry-run  -s block --action=add -v
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0boot0
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0boot1
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p2
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p3
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p4
```

.With the new option
```
root@dev:~# udevadm trigger --dry-run -i -s block --action=add -v
/sys/devices/platform
/sys/devices/platform/bus@5b000000
/sys/devices/platform/bus@5b000000/5b010000.mmc
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0boot0
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0boot1
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p2
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p3
/sys/devices/platform/bus@5b000000/5b010000.mmc/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p4
```
Boot time reduction with this is place is ~ 1 second.

10 months agoterminal-util: temporarily turn on nonblocking mode when waiting for ANSI seq responses
Lennart Poettering [Fri, 13 Dec 2024 19:11:35 +0000 (20:11 +0100)] 
terminal-util: temporarily turn on nonblocking mode when waiting for ANSI seq responses

We never know, maybe there's some spurious POLLIN and read() will fail
with EAGAIN even though we saw POLLIN. Handle that.

(this can happen if we area not the only process reading from the tty,
or in case of hups and such).

Fixes: #35499
10 months agoptyfwd: fix OSC sequence termination handling (#35640)
Lennart Poettering [Mon, 16 Dec 2024 14:41:32 +0000 (15:41 +0100)] 
ptyfwd: fix OSC sequence termination handling (#35640)

Fixes #35631.

10 months agoTEST-50-DISSECT: add test case with systemd-notify
Yu Watanabe [Sun, 15 Dec 2024 02:02:11 +0000 (11:02 +0900)] 
TEST-50-DISSECT: add test case with systemd-notify

This also merges the previous test cases into one.

Follow-up for 284dd31e9d7d25e8a0bdfee60cf938ab961f2a7a and
498c20fad6a472dfbbfacc1ed55754f9ebfa869e.

10 months agoptyfwd: fix logic of OSC sequence termination 35640/head
Yu Watanabe [Mon, 16 Dec 2024 07:25:00 +0000 (16:25 +0900)] 
ptyfwd: fix logic of OSC sequence termination

Previously, when an OSC sequence is terminated with \x1b\x5c, configured
OSC sequence would be inserted between the two characters, rather
than after the two.

Fixes a bug introduced by d848a9499830c530e804a41ffd8aa1bc942fa735.
Fixes #35631.

10 months agoptyfwd: clean up logic of color state transition in pty_forward_ansi_process()
Yu Watanabe [Mon, 16 Dec 2024 07:23:49 +0000 (16:23 +0900)] 
ptyfwd: clean up logic of color state transition in pty_forward_ansi_process()

Drop all 'continue', to make the logic easy to understand.
No functional change, just refactoring and preparation for later commit.

10 months agohwdb: Make remote controllable lights work out-of-the-box
Bastien Nocera [Thu, 12 Dec 2024 13:23:46 +0000 (14:23 +0100)] 
hwdb: Make remote controllable lights work out-of-the-box

Give access to USB/Bluetooth lights such as the Logitech Litra family of
devices.

The Logitech devices in particular are accessible through USB
and Bluetooth.

10 months agotest/README: Environment= setting for mkosi should be in [Build] section
Yu Watanabe [Sun, 15 Dec 2024 17:02:30 +0000 (02:02 +0900)] 
test/README: Environment= setting for mkosi should be in [Build] section

Otherwise, we get the following warning:

mkosi.local.conf: Setting Environment should be configured in [Build], not [Content].

10 months agohwdb: add scancodes for HP Elitebook 2170p runnning coreboot
persmule [Sun, 15 Dec 2024 13:03:57 +0000 (21:03 +0800)] 
hwdb: add scancodes for HP Elitebook 2170p runnning coreboot

HP Elitebook 2170p's keyboard scancodes under coreboot is different
with those under oem firmware. The scan code of backspace key of HP
Elitebook 2170p under coreboot is 0x66, but 93b078c has
KEYBOARD_KEY_66=pickup_phone for general HP laptops, making the
backspace key of the HP Elitebook 2170p running coreboot unusable.

The committed scancodes map KEYBOARD_KEY_66 back to backspace, and
provide all Fn-keys of HP Elitebook 2170p under coreboot.
Their evdev string matches the default SMBIOS tables of coreboot
for Elitebook 2170p, to avoid conflict with HP Elitebook 2170p running
oem firmware.

Fixes #35469 and https://ticket.coreboot.org/issues/571

10 months agoTEST-35-LOGIN: check only tty session
Yu Watanabe [Sun, 15 Dec 2024 08:42:10 +0000 (17:42 +0900)] 
TEST-35-LOGIN: check only tty session

For some reasons, another session logind-test-user may be started.
===
Dec 13 07:04:16 systemd-logind[2140]: Got message type=method_call ... member=CreateSessionWithPIDFD ...
(snip)
Dec 13 07:04:16 systemd-logind[2140]: New session 15 of user logind-test-user.
Dec 13 07:04:16 systemd-logind[2140]: VT changed to 2
Dec 13 07:04:16 systemd-logind[2140]: rfkill: Found udev node /dev/rfkill for seat seat0
Dec 13 07:04:16 systemd-logind[2140]: udmabuf: Found udev node /dev/udmabuf for seat seat0
Dec 13 07:04:16 systemd-logind[2140]: Found static node /dev/snd/timer for seat seat0
Dec 13 07:04:16 systemd-logind[2140]: Found static node /dev/snd/seq for seat seat0
Dec 13 07:04:16 systemd-logind[2140]: Changing ACLs at /dev/snd/timer for seat seat0 (uid 0→4712 add)
Dec 13 07:04:16 systemd-logind[2140]: Changing ACLs at /dev/rfkill for seat seat0 (uid 0→4712 add)
Dec 13 07:04:16 systemd-logind[2140]: Changing ACLs at /dev/udmabuf for seat seat0 (uid 0→4712 add)
Dec 13 07:04:16 systemd-logind[2140]: Changing ACLs at /dev/snd/seq for seat seat0 (uid 0→4712 add)
Dec 13 07:04:16 systemd[1]: user-4712.slice: Changed dead -> active
Dec 13 07:04:16 systemd[1]: user-4712.slice: Job 5951 user-4712.slice/start finished, result=done
Dec 13 07:04:16 systemd[1]: Created slice user-4712.slice.
Dec 13 07:04:16 systemd-logind[2140]: Electing new display for user logind-test-user
Dec 13 07:04:16 systemd-logind[2140]: Choosing session 15 in preference to -
(snip)
Dec 13 07:04:16 systemd-logind[2140]: Got message type=method_call ... member=CreateSessionWithPIDFD ...
(snip)
Dec 13 07:04:16 systemd-logind[2140]: New session 16 of user logind-test-user.
Dec 13 07:04:16 systemd-logind[2140]: Electing new display for user logind-test-user
Dec 13 07:04:16 systemd-logind[2140]: Ignoring session 16
===
Let's track only session for the user with tty, which we explicitly created.

Fixes #35597.

10 months agoudev/net: make Link object take reference to UdevEvent 35625/head
Yu Watanabe [Wed, 4 Dec 2024 18:12:42 +0000 (03:12 +0900)] 
udev/net: make Link object take reference to UdevEvent

No functional change, just refactoring.

10 months agoudev: introduce reference counter for UdevEvent
Yu Watanabe [Wed, 4 Dec 2024 18:12:03 +0000 (03:12 +0900)] 
udev: introduce reference counter for UdevEvent

No functional change, preparation for later commits.

10 months agoudev-builtin: make udev_builtin_add_property() and friends take UdevEvent*
Yu Watanabe [Wed, 4 Dec 2024 16:17:40 +0000 (01:17 +0900)] 
udev-builtin: make udev_builtin_add_property() and friends take UdevEvent*

No functional change, just refactoring.

10 months agonetwork: don't warn with no NSID assigned
Ronan Pigott [Sat, 14 Dec 2024 21:39:26 +0000 (14:39 -0700)] 
network: don't warn with no NSID assigned

This is nothing interesting to warn about. Also use the symbolic
constant name when testing for this condition.

10 months agotest: include MAINPID in notify message in TEST-50-DISSECT for notify socket
Luca Boccassi [Sat, 14 Dec 2024 16:44:40 +0000 (16:44 +0000)] 
test: include MAINPID in notify message in TEST-50-DISSECT for notify socket

Copy what systemd-notify does by default by setting it to the PID of the shell,
so that main process tracking works as expected. Also use test -S instead of ls
to check socket.

[   33.980396] (sh)[1024]: run-p1022-i1322.service: Executing: sh -c "echo READY=1 | ncat --unixsock --udp \$NOTIFY_SOCKET --source /run/notify && env"
[   34.138778] systemd[1]: run-p1022-i1322.service: Child 1024 belongs to run-p1022-i1322.service.
[   34.138825] systemd[1]: run-p1022-i1322.service: Main process exited, code=exited, status=0/SUCCESS (success)
[   34.139451] systemd[1]: run-p1022-i1322.service: Failed with result 'protocol'.
[   34.139559] systemd[1]: run-p1022-i1322.service: Service will not restart (restart setting)
[   34.139573] systemd[1]: run-p1022-i1322.service: Changed start -> failed
[   34.139945] systemd[1]: run-p1022-i1322.service: Job 1364 run-p1022-i1322.service/start finished, result=failed

Fixes #35619

Follow-up for 18bb30c3b2ea7f4497edf86414133667b3e155fe

10 months agoudev: move several definitions (#35613)
Luca Boccassi [Sat, 14 Dec 2024 16:32:02 +0000 (16:32 +0000)] 
udev: move several definitions (#35613)

10 months agotest-time-util: fix truncation of usec to sec
Yu Watanabe [Sat, 14 Dec 2024 07:49:54 +0000 (16:49 +0900)] 
test-time-util: fix truncation of usec to sec

Also
- use ASSERT_XYZ() macros,
- log tzname[] on failure.

10 months agomkosi: fix section for WithNetwork=
Luca Boccassi [Sat, 14 Dec 2024 10:57:34 +0000 (10:57 +0000)] 
mkosi: fix section for WithNetwork=

/tmp/autopkgtest.L6NPL0/build.doZ/src/mkosi.conf.d/10-debian-ubuntu/mkosi.conf.d/network.conf: Setting WithNetwork should be configured in [Build], not [Content]

10 months agoTEST-07-PID1: fixlets for running with sanitizers (#35616)
Luca Boccassi [Sat, 14 Dec 2024 12:21:45 +0000 (12:21 +0000)] 
TEST-07-PID1: fixlets for running with sanitizers (#35616)

Hopefully fixes #35546.

10 months agoTEST-07-PID1: skip test cases that invokes unshare when running with sanitizers 35616/head
Yu Watanabe [Sat, 14 Dec 2024 08:34:55 +0000 (17:34 +0900)] 
TEST-07-PID1: skip test cases that invokes unshare when running with sanitizers

Fixes #35546.

10 months agomkosi: drop wrapper for unshare
Yu Watanabe [Sat, 14 Dec 2024 08:29:56 +0000 (17:29 +0900)] 
mkosi: drop wrapper for unshare

This effectively reverts ef9a3241b37690ee0e76d84d48f82135da42e48b,
as it does not work.

10 months agoudev: move enums to udev-def.h 35613/head
Yu Watanabe [Tue, 3 Dec 2024 21:05:38 +0000 (06:05 +0900)] 
udev: move enums to udev-def.h

No functional change, just refactoring and preparation for later
commits.

10 months agoudev: move listen_fds() to udev-manager.c
Yu Watanabe [Tue, 3 Dec 2024 20:02:53 +0000 (05:02 +0900)] 
udev: move listen_fds() to udev-manager.c

Also
- drop redundant error message when manager_init() failed,
- close unexpected fds.

No functional change, just refactoring.

10 months agoudev: several coding style fixes
Yu Watanabe [Wed, 4 Dec 2024 15:44:14 +0000 (00:44 +0900)] 
udev: several coding style fixes

- use 'type* func()' rather than 'type *func()',
- merge variable declarations,
- etc.

10 months agoudev: several trivial cleanups for builtins (#35612)
Daan De Meyer [Sat, 14 Dec 2024 06:48:50 +0000 (06:48 +0000)] 
udev: several trivial cleanups for builtins (#35612)

10 months agotest-udev-spawn: migrate to use ASSERT_XYZ()
Yu Watanabe [Sun, 24 Nov 2024 07:13:04 +0000 (16:13 +0900)] 
test-udev-spawn: migrate to use ASSERT_XYZ()

10 months agoudev-builtin-kmod: log about unloading only when already loaded 35612/head
Yu Watanabe [Tue, 3 Dec 2024 19:55:12 +0000 (04:55 +0900)] 
udev-builtin-kmod: log about unloading only when already loaded

10 months agoudev-builtin: drop unnecessary 'initialized' flag
Yu Watanabe [Tue, 3 Dec 2024 19:52:28 +0000 (04:52 +0900)] 
udev-builtin: drop unnecessary 'initialized' flag

All builtin _init() functions can be called multiple times gracefully,
and _exit() can be called without _init() called.

10 months agoudev-builtin: use FOREACH_ELEMENT() macro
Yu Watanabe [Tue, 3 Dec 2024 19:49:42 +0000 (04:49 +0900)] 
udev-builtin: use FOREACH_ELEMENT() macro

10 months agologind: allow wall messages to be controlled via config file
David Härdeman [Thu, 21 Nov 2024 19:24:06 +0000 (20:24 +0100)] 
logind: allow wall messages to be controlled via config file

Right now, the sending of wall messages on reboot/shutdown/etc can be
controlled via DBus properties. This patch adds support for changing the
default via the logind.conf file as well.

Note that the DBus setting is lost if logind is restarted or reloaded,
but it was already the case before this patch that the setting is lost
upon restart.

10 months agoReplace array with magic indices with normal variables in vconsole-setup (#35181)
Yu Watanabe [Sat, 14 Dec 2024 01:49:01 +0000 (10:49 +0900)] 
Replace array with magic indices with normal variables in vconsole-setup (#35181)