Commit Graph
49195 Commits
Author SHA1 Message Date
Lennart Poettering 2b5321817f swap: hook up with handoff timestamps 2024-04-25 13:40:41 +02:00
Lennart Poettering 19ae89869e mount: hook up with handoff timestamps 2024-04-25 13:40:41 +02:00
Lennart Poettering 1f41b10ee0 socket: hookup handoff timestamps with processes forked off by socket units 2024-04-25 13:40:41 +02:00
Lennart Poettering 3c1d1ca146 manager: switch service unit type over to using new handoff timestamping logic
Also: rename Handover → Handoff. I think it makes it clearer that this
is not really about handing over any resources, but that the executor is
out off the game from that point on.
2024-04-25 13:40:41 +02:00
Lennart Poettering 12001b1bf0 execute: send handoff timestamps from executor to service manager
This changes the executor to systematically send handoff timestamps to
the service manager if a socket for that is supplied. This drops the
code that did this via Type=exec messages, and reverts that part to the
old behaviour before 93cb78aee2.

Benefits of this approach:

1. We can collect the handoff for any command we fork off, regardless
   if it's ExecStart= something else, regardless whether it's Type=exec,
   Type=simple or some any other service type, regardless of the unit
   type.

2. We collect both CLOCK_REALTIME and CLOCK_MONOTONIC, as we do for the
   other process timestamps.

3. It's entirely backwards compatible, as this doesn't change the
   protocol between service manager and executor, but just extends it.
2024-04-25 13:33:03 +02:00
Lennart Poettering 817062e621 manager: add socket for receiving handoff timestamps from forked children
This adds an AF_UNIX socket pair to the manager that we can collect
handoff timestamp messages on.

The idea is that forked off children send a datagram with a timestamp
and we use its sender PID to match it against the right forked off
process.

This part only implements the receiving side: a socket is created, and
listened on. Received datagrams are parsed, verified and then dispatched
to the interested units.
2024-04-25 13:33:03 +02:00
Lennart Poettering 33fc8b0d95 core: fix assertions in manager_dispatch_user_lookup_fd()
assert_se() should not be used here, these checks are paranoia only and
have no side-effect after all.

hence fix this to use assert(), or in fact ASSERT_PTR()
2024-04-25 13:32:25 +02:00
Lennart Poettering 78ef66354c varlink: fix varlink_get_peer_pidref() fallback
let's properly handle old kernels that have no pidfd, and use regular
pids in that case, as intended originally.
2024-04-25 12:44:00 +02:00
Lennart Poettering 47bb0b8c29 errno-util: consider ENOPROTOOPT another "not supported"
It's generated by not supported getsocktopt()/setsockopt() options, and
it's just another way for saying "not supported", hence treat it as
such.
2024-04-25 12:43:21 +02:00
Yu Watanabe 90db1582a9 run/run: fix invocation ID handling
Fixes a regression introduced by 8157cc0e3e.
2024-04-25 10:58:56 +02:00
Yu Watanabe d11ba681ab network/radv: use sd_ndisc_prefix and friends to manage prefixes and so on
No functional change, just refactoring.
2024-04-25 09:45:02 +09:00
Yu Watanabe 29d9672eb2 network/radv: rename pref64Prefix -> Prefix64
Also this made several coding style cleanups.
2024-04-25 09:44:57 +09:00
Yu Watanabe 30eab38020 network/route: use our definitions of route preference
Including linux/icmpv6.h easily trigger conflicts when another header
includes netinet/icmp6.h. Let's drop the dependency and use our
definition of the same values.
2024-04-25 09:23:31 +09:00
Yu Watanabe 68ee2ba1ee Merge pull request #32464 from YHNdnzj/journal-object-invocation-id
journal: small fixes for OBJECT_SYSTEMD_INVOCATION_ID
2024-04-25 06:40:45 +09:00
Rasmus Villemoes dc3058e490 systemctl: list-jobs: interchange 'waiting for' and 'blocking' in output
The current output of 'systemctl list-jobs' with the --after and/or --before
switches seems backwards. With artificial units

# check-oil.service
[Unit]
Description=Check the oil level
Before=engine-ready.target

# fill-gas.service
[Unit]
Description=Fill the tank with gasoline
Before=engine-ready.target

# engine-ready.target
[Unit]
Description=The engine is ready

[Unit]
Description=Start the engine!
After=engine-ready.target
Wants=engine-ready.target

running 'systemctl list-jobs --before --after' produces

JOB UNIT                                              TYPE  STATE
93  check-oil.service                                 start running
└─      waiting for job 94 (engine-ready.target/start)   -     -
102 fill-gas.service                                  start running
└─      waiting for job 94 (engine-ready.target/start)   -     -
94  engine-ready.target                               start waiting
└─      waiting for job 111 (start-engine.service/start) -     -
└─      blocking job 93 (check-oil.service/start)        -     -
└─      blocking job 102 (fill-gas.service/start)        -     -
111 start-engine.service                              start waiting
└─      waiting for job 1 (multi-user.target/start)      -     -
└─      blocking job 94 (engine-ready.target/start)      -     -

Obviously, job 93 is not waiting for job 94, but rather blocking it.
2024-04-24 21:31:28 +02:00
Luca Boccassi cea14db914 Merge pull request #32458 from poettering/manager_get_units_for_pidref
core: split out manager_get_units_for_pidref() and use it at multiple places
2024-04-24 21:28:52 +02:00
Lennart Poettering b9e4d9ba95 mount,swap: include ExecStatus output in dump
socket and service units output there ExecCommand/ExecStatus definitions
already, but this was missing in mount/swap. Fix that.
2024-04-24 21:23:42 +02:00
Mike Yuan 6cb8286aa3 journald-server: drop spuriously doubled '=' for OBJECT_SYSTEMD_INVOCATION_ID 2024-04-25 00:56:04 +08:00
Lennart Poettering 58290af48a manager: also port manager_dispatch_sigchld() to manager_get_units_for_pidref()
We have pretty much the same code here, let's reuse the common
implementation.
2024-04-24 18:24:22 +02:00
Lennart Poettering 4414bd5932 manager: split out helper that gets Unit objects with interest in given PidRef
This is both easier to read and allows us to reuse the helper later.
2024-04-24 18:10:35 +02:00
Zbigniew Jędrzejewski-Szmek c2e6ed612a Merge pull request #32447 from keszybz/test-taint
core: drop unused param, move taint calculation to separate file
2024-04-24 18:09:57 +02:00
Lennart Poettering f6519d47a7 manager: port user lookup fd serialization to serialize_fd_many() 2024-04-24 17:34:42 +02:00
Lennart Poettering c3ab362dad manager: comprehensively mark manager_dispatch_user_lookup_fd() as static
The prototype was static, but the implementation was not. Make both
static, this is otherwise too confusing. (This doesn't actually change
anything, since the prototype decides about this anyway, but it makes
things easier to read.)
2024-04-24 17:33:51 +02:00
Lennart Poettering fbe8f6928e capability-util: avoid thread_local
While stracing PID1's forking off of children I noticed that every
single forked off child reads cap_last_cap from procfs. That value is a
kernel constant, hence we can save a lot of work if we'd cache it.

Thing is, we actually do cache it, in a thread_local cache field. This
means that the forked off processes (which are considered new threads)
will have to re-query it, even though we already know the result.

Hence, let's get rid of the thread_local stuff (given that the value is
going to be the same for all threads anyway, and we pretty much have a
single thread only anyway). Use an C11 atomic_int instead, which ensures
the value is either initialized or not initialized, but we don't need to
be concerned of partial initialization.

This makes the cap_last_cap reading go away in the children, as strace
shows (since cap_last_cap() is already called by PID 1 before
fork()ing, anyway).
2024-04-24 17:33:38 +02:00
Mike Yuan 98cf76a4cc cryptenroll: fix typo (close parenthesis out of nowhere)
Follow-up for 8518f4a814
2024-04-24 17:32:56 +02:00
Lennart Poettering 1a6dceeca2 manager: use startswith() return value 2024-04-24 16:58:12 +02:00
Lennart Poettering 3a7bb5c99c manager: use proper unicode arrow in dump 2024-04-24 16:15:53 +02:00
Zbigniew Jędrzejewski-Szmek 2a6b4d872d core/taint: make short_uid_range() not take a path
As requested in review.
2024-04-24 15:17:49 +02:00
Zbigniew Jędrzejewski-Szmek d851637ca6 core: drop unused param, move taint calculation to separate file
Follow-up for 2b28dfe6e6.

I also considered moving the function to src/basic, but since it's only used by
the manager, it doesn't seem useful.
2024-04-24 15:17:49 +02:00
Lennart Poettering 07296542d6 exec-invoke: correct dont_close[] size
THis needs 15 entries as far as I can count, not just 14.

Follow-up for: 5686391b00

Sniff.
2024-04-24 15:09:28 +02:00
Yu Watanabe 6fe51dc50c network/radv: merge two boolean flags for prefix into one 2024-04-24 12:26:25 +09:00
Yu Watanabe c7c56724a5 sd-radv: use in6_addr_prefix_intersect() 2024-04-24 12:22:05 +09:00
Yu Watanabe 21ae0b4b3c in-addr-util: introduce in{4,6}_addr_prefix_intersect() 2024-04-24 12:22:05 +09:00
Yu Watanabe 9dc2503539 sd-radv: allow to send multiple routes or prefix64 that have intersection with others
I cannot find any RFC that states we should not send multiple route
prefix or pref64 options that have intersection with others.
Moreover, each route prefix option has preference field, thus, user may
want to send e.g. a prefix with the normal preference, and another sub
prefix with the high preference. Previously, such configuration was
prohibited. Let's allow that now.
2024-04-24 12:22:05 +09:00
Yu Watanabe 96dd66eddf sd-radv: send RA on update in caller side
As the caller may want to update multiple prefixes and friends.
Let's not automatically announce on update in library side.

Currently, only prefix is updated during running. Hence, this does not
change any effective behavior.
2024-04-24 12:22:05 +09:00
Mike Yuan 844863c61e core/manager: add unmerged-bin taint 2024-04-24 08:43:08 +08:00
Mike Yuan ea81442892 core/manager: rearrange taint tags 2024-04-24 08:40:25 +08:00
Mike Yuan 2b28dfe6e6 core/manager: drop obsolete cgroup taint string
Wwe can't boot on systems without cgroup anyway
(even cgroup v1 will be gone pretty soon).
2024-04-24 08:39:29 +08:00
Mike Yuan 21f8e749a1 mount-setup: use mount_verbose_full where appropriate 2024-04-24 08:39:26 +08:00
Luca Boccassi 5e1124b510 Merge pull request #32437 from keszybz/notify-fixups-split-out
Two fixups for sd-notify split out from #32093
2024-04-23 19:36:53 +02:00
Luca Boccassi e1e81c0920 Merge pull request #32434 from poettering/cryptenroll-prefer-var
cryptenroll: prefer looking at /var/ instead of /
2024-04-23 18:45:43 +02:00
Antonio Alvarez Feijoo 8ebfef5c96 sysext: do not return 0 if unmerge() fails in the refresh() function.
Actually, return the result of `unmerge()` if it is called in the `refresh()`
function.

Fixes 8662fcbcf1
2024-04-23 16:15:55 +02:00
Zbigniew Jędrzejewski-Szmek a4acc2528f Merge pull request #32435 from YHNdnzj/followup
Some follow-ups for recent PRs
2024-04-23 15:47:57 +02:00
Lennart Poettering cd4eda525d cryptenroll: use [] in --help text to indicate block device argument is now optional 2024-04-23 15:23:44 +02:00
Lennart Poettering 8518f4a814 cryptenroll: default to block device backing /var/ rather than /
With 1df4b21abd we started to default to
enrolling into the LUKS device backing the root fs if none was specified
(and no wipe operation is used). This changes to look for /var/ instead.

On most systems /var/ is going to be on the root fs, hence this change
is with little effect.

However, on systems where / and /var/ is separate it makes more sense to
default to /var/ because that's where the persistent and variable data
is placed (i.e.  where LUKS should be used) while / doesn't really have
to be variable, could as well be immutable, or ephemeral. Hence /var/
should be a safer default.

Or to say this differently: I think it makes sense to support systems
with /var/ being on / well. I also think it makes sense to support
systems with them being separate, and /var/ being variable and
persistent. But any other kind of system I find much less interesting to
support, and in that case people should just specify the device name.

Also, while we are at it, tighten the checks a bit, insist on a dm-crypt
+ LUKS superblock before continuing.

And finally, let's print a short message indicating the device we
operate on.
2024-04-23 15:23:44 +02:00
Yu Watanabe bd0ec61ae3 journal: do not rotate unrelated journal files when full or corrupted
When we fail to add an entry to a journal file, typically when the file
is full or corrupted, it is not necessary to rotate other journal files.

Not only that's unnecessary, rotating all journal files allows
unprivileged users to wipe system or other user's journals by writing
many journal entries to their own user journal file.

Let's rotate all journal files only when
- it is really requested by a privileged user (e.g. by journalctl --rotate), or
- the system time jumps backwards.
And, otherwise rotate only the journal file we are currently writing.
2024-04-23 15:13:05 +02:00
Daan De Meyer 00bc83a275 core: Limit terminal reset using ANSI sequences to /dev/console
Doing this in reset_terminal_fd() is a bit too invasive, see
https://github.com/systemd/systemd/pull/32406#issuecomment-2070923583.

Let's only do this for /dev/console so that we work around weird firmwares
disabling line-wrapping, but avoid messing too much with other things.

While we're at it, let's handle more than just line wrapping, and do a
more general reset of stuff to get the terminal into a sane state.
2024-04-23 15:05:50 +02:00
Mike Yuan 3d9099f23d cryptenroll: sort includes
Follow-up for 1df4b21abd
2024-04-23 20:01:02 +08:00
Mike Yuan 31197c684a core/service: also allow updating main pid when SERVICE_STOP
Follow-up for f5b72af50d

See also: https://github.com/systemd/systemd/pull/32120#discussion_r1575992623
2024-04-23 20:01:01 +08:00
Zbigniew Jędrzejewski-Szmek 1b47cfab7f Merge pull request #32428 from poettering/sd-notify-reboot-param
pid1: send shutdown type and reboot argument to supervisor via sd_notify()
2024-04-23 13:31:40 +02:00