Commit Graph
37628 Commits
Author SHA1 Message Date
Lennart Poettering 69a21030b1 Merge pull request #22460 from bluca/monitor_refactor
core: split $MONITOR_METADATA and return it only if a single unit triggers OnFailure/OnSuccess
2022-03-10 18:34:20 +01:00
Luca Boccassi a8c5363ba9 Merge pull request #22682 from bluca/start_skip
core: do not return 'skipped' when Condition*= fail with StartUnitWithFlags()
2022-03-10 17:25:44 +00:00
Luca Boccassi e2cb73c946 Merge pull request #22695 from poettering/crash-handle-refactor
pid1: add comment clarifying not to use memory allocation from crash handler
2022-03-10 16:42:50 +00:00
Zbigniew Jędrzejewski-Szmek a257c941ad manager: pass monitor metadata in more cases
The first ExecStartPre or the first ExecStart commands would get the metadata,
but not the subsequent ones. Also check that we do not pass it in
ExecStartPost.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek 02de9614d4 manager: prevent cleanup of triggering units before we start the handler
This fixes the following case:
OnFailure= would be spawned correctly, but OnSuccess= would be
spawned without the MONITOR_* metadata, because we'd "collect" the unit
that started successfully. So let's block cleanup while we have a job
running for the handler. The job cannot last infinitely, so at some point
we'll be able to collect both.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek 7a5049c780 manager/service: when we have multiple candidates to handle, warn
This would be very confusing to users, so let's warn if they configured the
same handler for multiple units and we're not running it as expected.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek edbf8984a4 manager/service: when we spawn, say why
We already logged what we are spawning, but not so much why. Let's
add this, so it's easier to distinguish execstartpre/execstart/execstartpost
and such.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek 82acee149c manager: log how many OnSuccess/OnFailure jobs were started 2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek adf769b06c manager: adjust comment 2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek fb1381662b various: align vertically for ease of reading 2022-03-10 14:51:28 +00:00
Luca Boccassi 95c81c55b2 core: split $MONITOR_METADATA and return it only if a single unit triggers OnFailure/OnSuccess
Remove the list logic, and simply skip passing metadata if more than one
unit triggered an OnFailure/OnSuccess handler.
Instead of a single env var to loop over, provide each separate item
as its own variable.

Fixes https://github.com/systemd/systemd/issues/22370
2022-03-10 14:43:14 +00:00
Luca Boccassi ee3ae55e75 core: do not return 'skipped' when Condition*= fail with StartUnitWithFlags()
Backward incompatible change to avoid returning 'skipped' if a condition causes
a job activation to be skipped when using StartUnitWithFlags().
Job results are broadcasted, so it is theoretically possible that existing
software could get confused if they see this result.

Replaces https://github.com/systemd/systemd/pull/22369
2022-03-10 13:16:21 +00:00
Luca Boccassi bd844eae23 Merge pull request #22685 from bluca/user_root_dir
core: support MountAPIVFS and RootDirectory in user manager
2022-03-10 13:12:19 +00:00
Lennart Poettering 898c9a6f97 pid1: split out crash handler logic into its own .c/.h file
This stuff is sufficiently different from the rest of main.c, let's move
it to its own .c/.h file, to make main.c a bit shorter.

No code changes, just some refactoring.
2022-03-10 13:45:14 +01:00
Lennart Poettering 4fba096ba1 pid1: add comment to crash handler about memory allocations 2022-03-10 13:45:09 +01:00
Yu Watanabe 999fc88331 Merge pull request #22595 from poettering/logind-action-refact
logind: some minor refactoring around logind's HandleAction logic
2022-03-10 20:56:15 +09:00
Luca Boccassi ea63a260d4 core: support MountAPIVFS and RootDirectory in user manager
The only piece missing was to somehow make /proc appear in the
new user+mount namespace. It is not possible to mount a new
/proc instance, not even with hidepid=invisible,subset=pid, in
a user namespace unless a PID namespace is created too (and also
at the same time as the other namespaces, it is not possible to
mount a new /proc in a child process that creates a PID namespace
forked from a parent that created a user+mount namespace, it has
to happen at the same time).

Use the host's /proc with a bind-mount as a fallback for this
case. User session services would already run with it, so
nothing is lost.
2022-03-10 10:21:03 +00:00
licunlong 28c5859fa3 main: drop get_process_cmdline from crash handler
get_process_cmdline calls malloc, which should be avoid in signal handler.

Fixes: #22690
2022-03-10 09:19:50 +01:00
Lennart Poettering a3ddcc1114 logind: rename scheduled_shutdown_type → scheduled_shutdown_action
This matches naming of the 'delayed_action' field we already have. It's
similar in both type and concept, and hence should be named similarly.
2022-03-09 16:34:32 +01:00
Lennart Poettering 48bccaa92e logind: rename manager_item_for_handle() → handle_action_lookup()
The function has nothing to do with any Manager object, hence drop that
from the name. And it actually looks something up by handle *action* not
by *handle*, hence the old name was a bit misnomer. Let's call it
handle_action_lookup(), as it queries handle action metainfo for a
handle action.

Also, let's make sure it behaves more like our usual functions that
lookup some fixed data from some enum value/int: let's return NULL if we
don't find it.
2022-03-09 16:34:00 +01:00
Lennart Poettering 5e06260b2c logind: drop unused prototype 2022-03-09 16:24:11 +01:00
Lennart Poettering 510eccab5f logind: minor whitespace fix 2022-03-09 16:24:11 +01:00
Lennart Poettering b0a3a5e538 logind: rename ActionTableItem → HandleActionData
It stores meta-info about various HandleActions, hence let's name it
after that. The fact that it can be seen as stored inside some form of a
table is an implementation detail of logind-action.c, and should not
leak into other modules, hence let's focus on what it is, not how it is
stored.
2022-03-09 16:24:11 +01:00
Lennart Poettering 6800876608 logind: replace handle_action_valid() macro by inline function
The old macro will double evaluation and has no protection against
operator precedence issues. Let's fix that by using an inline func
instead, which also gives us typesafety.
2022-03-09 16:24:10 +01:00
Jason A. Donenfeld 31234fbeec random-util: unify RANDOM_ALLOW_INSECURE and !RANDOM_BLOCK and simplify
RANDOM_BLOCK has existed for a long time, but RANDOM_ALLOW_INSECURE was
added more recently, leading to an awkward relationship between the two.
It turns out that only one, RANDOM_BLOCK, is needed.

RANDOM_BLOCK means return cryptographically secure numbers no matter
what. If it's not set, it means try to do that, but if it fails, fall
back to using unseeded randomness.

This part of falling back to unseeded randomness is the intent of
GRND_INSECURE, which is what RANDOM_ALLOW_INSECURE previously aliased.
Rather than having an additional flag for that, it makes more sense to
just use it whenever RANDOM_BLOCK is not set. This saves us the overhead
of having to open up /dev/urandom.

Additionally, when getrandom returns too little data, but not zero data,
we currently fall back to using /dev/urandom if RANDOM_BLOCK is not set.
This doesn't quite make sense, because if getrandom returned seeded data
once, then it will forever after return the same thing as whatever
/dev/urandom does. So in that case, we should just loop again.

Since there's never really a time where /dev/urandom is able to return
some easily but more with difficulty, we can also get rid of
RANDOM_EXTEND_WITH_PSEUDO. Once the RNG is initialized, bytes
should just flow normally.

This also makes RANDOM_MAY_FAIL obsolete, because the only case this ran
was where we'd fall back to /dev/urandom on old kernels and return
GRND_INSECURE bytes on new kernels. So also get rid of that flag.

Finally, since we're always able to use GRND_INSECURE on newer kernels,
and we only fall back to /dev/urandom on older kernels, also only fall
back to using RDRAND on those older kernels. There, the only reason to
have RDRAND is to avoid a kmsg entry about unseeded randomness.

The result of this commit is that we now cascade like this:

  - Use getrandom(0) if RANDOM_BLOCK.
  - Use getrandom(GRND_INSECURE) if !RANDOM_BLOCK.
  - Use /dev/urandom if !RANDOM_BLOCK and no GRND_INSECURE support.
  - Use /dev/urandom if no getrandom() support.
  - Use RDRAND if we would use /dev/urandom for any of the above reasons
    and RANDOM_ALLOW_RDRAND is set.
2022-03-09 14:25:15 +01:00
Luca Boccassi 3ebf0b0bd4 core: create parent directory for mount point of ExtensionDirectories
This is used by ExtensionDirectories too, as they are bind-mounted in the
propagate directory to check the extension-release files
2022-03-09 02:02:17 +00:00
licunlong 7347b3db83 main: log which process send SIGNAL to PID1
This can help users to figure out what makes systemd freeze.
1. Someone kills systemd accidentally, then the sender_pid won't be 1;
2. systemd triggers segfault or assert, then the sender_pid will be 1;
2022-03-09 00:09:46 +09:00
Zbigniew Jędrzejewski-Szmek 4db62561c2 core: manage SetShowStatus through polkit
When writing docs for SD_BUS_VTABLE_CAPABILITY, I noticed that we have one use
of SD_BUS_VTABLE_CAPABILITY(CAP_SYS_ADMIN) in the tree. This is the default, so
it's not very useful to specify it. But if we're touching that, I think it's
better to use mac + polkit for this like for everything else.

We don't have a very good category for this, but I don't think it makes sense
to add a new one. I just reused the same as other similar calls.
2022-03-08 23:13:36 +09:00
Zbigniew Jędrzejewski-Szmek 835f79fddd Merge pull request #22656 from keszybz/portablectl-method2
portable: add return parameter to GetImageMetadataWithExtensions
2022-03-08 13:26:33 +01:00
Ludwig Nussel ee3d33c415 logind: use mfree instead of freep 2022-03-07 19:43:18 +00:00
Bastien Nocera d48bf01636 memory-id: Work-around incorrect "Number of slots"
In some BIOSes, the "Number of slots or sockets available for Memory
Devices in this array" is incorrectly set to the number of memory array
that's populated.

Work-around this problem by outputting the number of sockets after
having parsed them so that consumers of this data can carry on expecting
an accurate number in this property.

This fixes the number of memory slots advertised for the HP Z600.

See https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1686
2022-03-07 15:33:26 +00:00
Zbigniew Jędrzejewski-SzmekandLuca Boccassi 087a799f64 portable: add return parameter to GetImageMetadataWithExtensions
The complaint was that the output array was used for two kinds of data, and the
input flag decided whether this extra data should be included. The flag is
removed, and instead the old method is changed to include the data always as
a separate parameter.

This breaks backward compatibility, but  the old method is effectively broken
and does not appear to be used yet, at least in open source code, by
searching on codesearch.debian.net and github.com.

Fixes #22404.

Co-authored-by: Luca Boccassi <bluca@debian.org>
2022-03-07 14:49:54 +00:00
Zbigniew Jędrzejewski-Szmek 90e3f3581d portable: inline one variable declaration 2022-03-07 14:32:01 +01:00
Zbigniew Jędrzejewski-Szmek 573e33de07 portablectl: reorder if branches to match previous conditional in the same function
One is a ternary op, the other an normal conditional, but they should still use
the same order of branches.
2022-03-07 14:31:48 +01:00
Yu Watanabe a17e54783a tree-wide: fix typo 2022-03-07 15:32:22 +09:00
Zbigniew Jędrzejewski-Szmek b4e7d7555e man: describe capability checks on the bus
A description of SD_BUS_VTABLE_CAPABILITY is added, and the discussion
on SD_BUS_VTABLE_UNPRIVILEGED in expanded. I think it would be nice
to add longer description of how access is checked (maybe in sd-bus(3)),
but I'm leaving that for later. I think the text that was added here
describes everything, even if tersely.

Fixes #21882.
2022-03-04 15:43:18 +01:00
David Tardon 203ea2c8f1 devnode-acl: use _cleanup_ to free acl_t 2022-03-04 11:51:48 +01:00
Alfonso Sánchez-Beato 178d598b5f sd-stub: do not print warning if filesystem is not supported
Do not print a warning in case we try to load the file system protocol for an
unsupported file system, just return EFI_SUCCESS instead.
2022-03-03 23:14:45 +00:00
Zbigniew Jędrzejewski-Szmek f05a288135 Merge pull request #22644 from keszybz/meson-no-split
Use normal lists in meson instead of splitting on whitespace
2022-03-03 23:10:14 +01:00
Tobias Stoeckmann 1a823cdeb9 core: check size before mmap
The data type off_t can be 64 on 32 bit systems if they have large
file support. Since mmap expects a size_t with 32 bits as second
argument truncation could occur. At worst these huge files could
lead to mmaps smaller than the previous check for small files.

This in turn shouldn't have a lot of impact because mmap allocates
at page size boundaries. This also made the PAGE_ALIGN call in
open_mmap unneeded. In fact it was neither in sync with other mmap
calls nor with its own munmap counterpart in error path.

If such large files are encountered, which is very unlikely in these
code paths, treat them with the same error as if they are too small.
2022-03-03 22:48:43 +01:00
Lennart Poettering 94ce42bcb6 killall: show PID of processes killed in final killing spree
Let's show the PID of killed processes in all cases, to make debugging
easier.

See: https://lists.freedesktop.org/archives/systemd-devel/2022-March/047504.html
2022-03-03 22:45:47 +01:00
Zbigniew Jędrzejewski-Szmek 2f492a739c meson: move files' closing brace to separate line 2022-03-03 12:14:13 +01:00
Luca Boccassi 3a0692e3a8 Merge pull request #22522 from lnussel/fix_logind_restart
logind: load scheduled shutdown on restart
2022-03-02 17:58:53 +00:00
Zbigniew Jędrzejewski-Szmek b9acb5074e meson: use files() for libudevd_core_sources too
I'm not sure why a plain-text list was used in this case.
2022-03-02 14:52:50 +01:00
Zbigniew Jędrzejewski-Szmek f1b98127ff meson: do not use split() in file lists
The approach to use '''…'''.split() instead of a list of strings was initially
used when converting from automake because it allowed identical blocks of lines
to be used for both, making the conversion easier.

But over the years we have been using normal lists more and more, especially
when there were just a few filenames listed. This converts the rest.

No functional change.
2022-03-02 14:49:32 +01:00
Daan De Meyer ee48779e05 shared: Add more dlopen() tests
Add dlopen_dw(), dlopen_elf() and dlopen_pcre2() to the dlopen test.
To enable adding dlopen_pcre2(), we move pcre2-dlopen.h/c from
src/journal to src/shared.
2022-03-01 21:07:17 +00:00
Ludwig Nussel 00886e06e8 systemctl: use action_table for scheduling shutdown
The fall-through to reboot doesn't seem to make sense. It won't happen
in the current code. Filtering the actions on client side is not needed
either as the server will refuse unsupported operations anyway.
2022-02-28 11:29:45 +01:00
Ludwig Nussel aa6123e85e logind: load scheduled shutdown on restart
Make sure logind doesn't forget about a scheduled shutdown, even if it
gets restarted eg due to a package update.
2022-02-28 11:29:45 +01:00
Ludwig Nussel 9fa9c66dbd logind: fix handle_action_valid() 2022-02-28 10:31:10 +01:00
Yu Watanabe 3d24b0ddd8 network: netdev: drop unused creation type NETDEV_CREATE_AFTER_CONFIGURED 2022-02-27 09:36:48 +09:00