Commit Graph
67462 Commits
Author SHA1 Message Date
Yu Watanabe 0bf091a626 proc-cmdline: re-implement proc_cmdline_filter_pid1_args() without using getopt_long()
If getopt_long() is called for a list of arguments and it is freed, then
calling getopt_long() for another list will trigger use-after-free.

The function proc_cmdline_filter_pid1_args() may be called before or during
parsing program arguments (typically named as parse_argv()), hence we cannot
use getopt_long() in proc_cmdline_filter_pid1_args().

Fixes #28366.
2023-07-14 13:36:50 +09:00
Yu Watanabe 542f99cc8b test: add more test cases for proc_cmdline_filter_pid1_args() 2023-07-14 13:36:50 +09:00
Yu Watanabe f14f1273d3 Merge pull request #27526 from mrc0mmand/journal-fss
journal: clean up the FSS related code a bit & add a couple of tests
2023-07-14 13:30:30 +09:00
Fuminobu TAKEYAMA ef4300654e core: fix race condition during startup of a service with ExitType=cgroup
This commit allows service_sigchld_event() is executed before
service_dispatch_exec_io(), which might happen when a main process exits
very quickly.

Also do not check PID for service goodness because the main process have
already been exited in this case.

Fix: #27919
2023-07-14 10:51:41 +08:00
Yu Watanabe a035a33f83 Merge pull request #28385 from YHNdnzj/fstab-initrd-bind-mount
fstab-generator: resolve bind mount source when in initrd
2023-07-14 11:21:14 +09:00
Mike Yuan b5fd3956ec fstab-generator: resolve bind mount source when in initrd
We currently prepend /sysroot to mount points for entries
in /sysroot/etc/fstab. But when it comes to bind mounts,
the source needs to canonicalized too.

Fixes #6827
Replaces #7894
2023-07-14 01:29:23 +08:00
Mike Yuan 35df78cd88 fstab-util: add fstab_is_bind 2023-07-14 01:27:02 +08:00
Daan De Meyer d7d36252e5 ukify: Derive public key from private key if not specified 2023-07-13 16:31:05 +01:00
David Tardon b1ebc20137 bus-polkit: avoid extra variable 2023-07-13 16:40:30 +02:00
David Tardon 2f50a4f38f bus-polkit: allow to auth. a bus call for multiple actions
In #20155, verify_shutdown_creds() needs to authenticate for both
org.freedesktop.login1.hibernate-multiple-sessions and
org.freedesktop.login1.hibernate-ignore-inhibit . Previously, the second
authentication attempt would fail with -ESTALE.

Fixes #20155.
2023-07-13 16:40:05 +02:00
David Tardon 959301cf9f bus-polkit: parse reply from polkit on receive
... and store just the result.
2023-07-13 16:29:17 +02:00
David Tardon c71901b247 bus-polkit: extract action into a separate struct
This is a preparation for later commits.
2023-07-13 16:29:17 +02:00
David Tardon 361c4ee82f bus-polkit: describe async. polkit verification 2023-07-13 16:29:16 +02:00
David Tardon 0df66e42fa bus-polkit: refactor a bit to avoid goto 2023-07-13 16:00:06 +02:00
David Tardon 8f7195ef3c bus-polkit: drop unused argument 2023-07-13 16:00:06 +02:00
David Tardon 10ee1413f6 bus-polkit: use automatic cleanup 2023-07-13 16:00:06 +02:00
Frantisek Sumsal 6ce3d33bd5 test: add a couple of tests for FSS journals 2023-07-13 15:32:20 +02:00
Frantisek Sumsal 9e94023236 journal: clean up the FSS handling code a bit 2023-07-13 15:32:20 +02:00
Luca Boccassi 4e680156c8 homed: make all pam_prompt strings translatable
Users get prompted with these, so they should be translated.
Note that a comment is moved up, as otherwise the pot generation picks
it up and copies it into the translation file.

Fixes https://github.com/systemd/systemd/issues/28379
2023-07-13 13:24:53 +01:00
Zbigniew Jędrzejewski-Szmek 1339b950cf network: use RET_GATHER
No functional change intended.
2023-07-13 11:40:15 +02:00
Zbigniew Jędrzejewski-Szmek eb6cae1a40 modules-load: use RET_GATHER, update error handling
We would try to return the first error, but conf_files_list_nulstr()
failure would terminate the app immediately. So let's just return the
error from conf_files_list_nulstr(), and the first error encountered for
other failures after which we continue.
2023-07-13 11:40:15 +02:00
Zbigniew Jędrzejewski-Szmek fa989c74a6 gpt-auto-generator: use RET_GATHER, return first error 2023-07-13 11:40:15 +02:00
David Tardon 85fe60b9e8 docs: fix order 2023-07-13 09:37:00 +00:00
Zbigniew Jędrzejewski-Szmek 60ecc386ab coredump: use RET_NERRNO and RET_GATHER
No functional change indended.
2023-07-13 11:12:00 +02:00
Zbigniew Jędrzejewski-Szmek 0114bab25f bootctl: use RET_GATHER, return first error 2023-07-13 11:12:00 +02:00
Zbigniew Jędrzejewski-Szmek 9ef648cca1 various: use RET_GATHER
No functional change indentended.
2023-07-13 11:12:00 +02:00
Zbigniew Jędrzejewski-Szmek 809c3a84e1 Introduce RET_GATHER and use it in src/shared/
The idea is to make it easier to implement the common pattern of
accumulating errors (negative values) in an accumulator to return
the first error.
2023-07-13 11:12:00 +02:00
Zbigniew Jędrzejewski-Szmek c8e02e408f sysusers: add comments and simplify how set with names is created
The code was correct, but rather confusing: it used two sets with strings with
trivial_hash_ops to store strings used in other hashmaps. Let's add a bunch of
comments to explain what is happening. We also don't need two sets, using just
one saves a bit of memory.

While at it, let's add some debug messages if duplicate user/group names or
uids/gids are present.
2023-07-13 11:12:00 +02:00
Zbigniew Jędrzejewski-Szmek 09ace4c76d sd-device: simplify code flow
This function was written as if it wanted to do some cleanup after exiting from
the loop, but that never happened.
2023-07-13 11:12:00 +02:00
Zbigniew Jędrzejewski-Szmek 8623dab880 units/systemd-vconsole-setup: suppress error when service is restarted
The service has Type=oneshot, which means that the default value of SuccessExitStatus=0.
When multiple vtcon devices are detected, udev will restart the service after each
one. If this happens quickly enough, the old instance will get SIGTERM while it is
still running:

[    5.357341] (udev-worker)[593]: vtcon1: /usr/lib/udev/rules.d/90-vconsole.rules:12 RUN '/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service
[    5.357439] (udev-worker)[593]: vtcon1: Running command "/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service"
[    5.357485] (udev-worker)[593]: vtcon1: Starting '/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service'
[    5.357537] (udev-worker)[609]: vtcon0: /usr/lib/udev/rules.d/90-vconsole.rules:12 RUN '/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service
[    5.357587] (udev-worker)[609]: vtcon0: Running command "/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service"
[    5.357634] (udev-worker)[609]: vtcon0: Starting '/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service'
...
[    5.680529] systemd[1]: systemd-vconsole-setup.service: Trying to enqueue job systemd-vconsole-setup.service/restart/replace
[    5.680565] systemd[1]: systemd-vconsole-setup.service: Merged into running job, re-running: systemd-vconsole-setup.service/restart as 557
[    5.680600] systemd[1]: systemd-vconsole-setup.service: Enqueued job systemd-vconsole-setup.service/restart as 557
...
[    5.682334] systemd[1]: Received SIGCHLD from PID 744 ((le-setup)).
[    5.682377] systemd[1]: Child 744 ((le-setup)) died (code=killed, status=15/TERM)
[    5.682407] systemd[1]: systemd-vconsole-setup.service: Child 744 belongs to systemd-vconsole-setup.service.
[    5.682436] systemd[1]: systemd-vconsole-setup.service: Main process exited, code=killed, status=15/TERM
[    5.682471] systemd[1]: systemd-vconsole-setup.service: Failed with result 'signal'.
[    5.682518] systemd[1]: systemd-vconsole-setup.service: Service will not restart (manual stop)
[    5.682552] systemd[1]: systemd-vconsole-setup.service: Changed stop-sigterm -> failed

This is expected and not a problem. Let's treat SIGTERM as success so we don't
get this spurious "failure".
2023-07-13 10:56:52 +02:00
Zbigniew Jędrzejewski-Szmek a8425c53eb core: adjust indentation
One of the two conditionals in the function had different indentation than the
other.
2023-07-13 10:56:52 +02:00
Zbigniew Jędrzejewski-Szmek a0043bfa51 pid1,vconsole-setup: take a lock for the console device
When systemd-firstboot (or any other unit which uses the tty) is started,
systemd will reset the terminal. If systemd-vconsole-setup happens to be
running at that time, it'll error out when it tries to use the vconsole fd and
gets an EIO from ioctl.

e019ea738d was the first fix. It added an
implicit ordering between units using the tty and systemd-vconsole-setup.
(The commit title is wrong. The approach was generalized, but the commit title
wasn't updated.)
Then cea32691c3 was added to restart
systemd-vconsole-setup.service from systemd-firstboot.service. This was OK,
with the ordering in place, systemd-vconsole-setup.service would wait until
systemd-firstboot.service exited. But this wasn't enough, because we want the
key mappings to be loaded immediately after systemd-firstboot writes the
config. 8eb668b9ab implemented that, but actually
reintroduced the original issue. I had to drop the ordering between the two
units because otherwise we'd deadlock, waiting from firstboot for
vconsole-setup which wouldn't start while firstboot was running.
Restarting vconsole-setup.service from systemd-firstboot.service works just
fine, but when vconsole-setup.service is started earlier, it may be interrupted
by systemd-firstboot.service.

To resolve the issue, let's take a lock around the tty device. The reset is
performed after fork, so the (short) delay should not matter too much.

In xopenat_lock() the assert on <path> is dropped so that we can call
xopenat(fd, NULL) to get a copy of the original fd.

Fixes #26908.
2023-07-13 10:47:12 +02:00
Yu Watanabe 8d3c5b39b9 network: use json_append() and json_variant_append_array() 2023-07-13 17:06:47 +09:00
Yu Watanabe c619033f09 hashmap: introduce hashmap_dump_sorted() and friends 2023-07-13 17:06:47 +09:00
Yu Watanabe ddd6875d19 logs-show: use json_variant_append_array() 2023-07-13 17:06:47 +09:00
Yu Watanabe c22dcd67e1 tpm2-util: use json_variant_append_array() 2023-07-13 17:06:29 +09:00
Yu Watanabe 684bce3d54 busctl: use json_variant_append_array() 2023-07-13 17:03:13 +09:00
Lennart Poettering d89457a145 loop-write: do strlen() implicitly if size is specified as SIZE_MAX
This reduces repetition in the function calls, since quite often we
write out strings with loop_write().

Noticed while reviewing #28077.
2023-07-13 09:59:28 +09:00
Susant Sahani fc4a7f13bb ndisc: honour MTU for onlink prefix
Fixes #26520
2023-07-13 09:45:38 +09:00
Luca Boccassi 37daa74bb8 Merge pull request #28368 from mrc0mmand/test-fail-on-error
test: a couple of clean ups
2023-07-12 23:51:42 +01:00
Roger Gammans 681295c060 Add alternate name for MX Ergo as found on some devices
Fixes #28349
2023-07-12 23:50:35 +01:00
Lennart Poettering dbc62e590a update TODO 2023-07-12 23:23:42 +02:00
Daan De Meyer 608aa606cf Merge pull request #28365 from DaanDeMeyer/udevadm-query
Various fixes and improvements
2023-07-12 21:48:04 +02:00
Daan De Meyer a9e536a6bc logs-show: Rename json_data to JsonData and add typedef 2023-07-12 20:05:20 +02:00
Daan De Meyer ee9d31a608 json: free array in json_variant_unref_many()
This allows using it with CLEANUP_ARRAY(). For the 2 call sites
where we don't need to free the array, we do a regular for loop
calling json_variant_unref() instead.
2023-07-12 20:05:20 +02:00
Daan De Meyer 2507731374 basic: Fix color + underline functions/macros
We currently concatenate ANSI_UNDERLINE to the color of our choice
in DEFINE_ANSI_FUNC_UNDERLINE() and DEFINE_ANSI_FUNC_UNDERLINE_256().
The first thing that ANSI_UNDERLINE does is reset all previous ansi
escape sequences, so you just get underlining without any colors.

Let's fix the issue by actually concatenating _UNDERLINE to the given
color macro name so this works properly.

Also add missing color macros that this uncovered.
2023-07-12 20:05:20 +02:00
Daan De Meyer a1af83728f device-util: Declare iterator variables inline 2023-07-12 20:05:18 +02:00
Mike Yuan 39939e7d02 core: refuse late merge only for anchor job when JOB_RESTART_DEPENDENCIES
Follow-up for 2a39b91459

The mentioned change makes all jobs in the transaction unmergeable
if mode == JOB_RESTART_DEPENDENCIES, but we only want the anchor job
to be re-enqueued.
2023-07-12 18:25:45 +02:00
Lennart Poettering 8620854aa1 Merge pull request #28344 from YHNdnzj/compare-device-node
hibernate-resume: add & use devnode_same to compare device nodes
2023-07-12 17:59:28 +02:00
Micah Abbott 2262cbf9fd docs: cleanups to ROOT_STORAGE_DAEMONS
There were a couple spelling/grammatical errors in the docs that made
it hard to read and understand parts of this doc. I cleaned up those
errors and reflowed the line breaks to keep to the 80 char limit.
2023-07-12 15:49:05 +01:00