Commit Graph

6959 Commits

Author SHA1 Message Date
Daan De Meyer
b4736d9a25 basic: Move LogRatelimit struct to log-ratelimit.h as well 2025-05-25 09:40:26 +02:00
Daan De Meyer
4cfd024e73 forward: Move ChaseFlags forward declaration to forward.h 2025-05-24 20:44:12 +02:00
Daan De Meyer
b416ac0e15 basic: Move ratelimit logging functions to log-ratelimit.h 2025-05-25 03:28:50 +09:00
Jelle van der Waa
3ce64b0fbe cgroup-util: rename 'kill_log' -> 'log_kill'
Rename according to the implementation.
2025-05-24 17:13:39 +02:00
Jelle van der Waa
684cd01f0e cgroup-util: rename 's' -> 'killed_pids' 2025-05-24 16:58:56 +02:00
Yu Watanabe
9d75fb9647 linux: update kernel headers from v6.15-rc7 2025-05-24 03:04:22 +09:00
Lennart Poettering
ceed11e465 path-util: invert PATH_STARTSWITH_ACCEPT_DOT_DOT flag
As requested: https://github.com/systemd/systemd/pull/37572#pullrequestreview-2861928094
2025-05-23 06:51:45 +02:00
Lennart Poettering
482107724f cgroup: port some code over to path_startswith_full() 2025-05-23 06:51:43 +02:00
Lennart Poettering
ee19edbb9f path-util: add flavour of path_startswith() that leaves a leading slash in place 2025-05-23 06:50:30 +02:00
Daan De Meyer
6b436ebace meson: Make sure <sys/socket.h> is included in af-from-name.gperf 2025-05-22 21:10:15 +02:00
Daan De Meyer
bba27cd746 basic: Add missing process-util.h include to origin-id.h 2025-05-22 21:10:15 +02:00
Daan De Meyer
b2ae2119c5 forward: Add more forward declarations
CGroupMask was erronously added to core-forward.h even though it
comes from src/basic so we move it to the right location.
2025-05-22 17:26:43 +02:00
Daan De Meyer
5ea01af240 meson: Use .inc for generated code meant to be included in other files
These files use the .h extension but are not standalone so let's not
make it appear like they are proper headers and instead use the .inc
extension.
2025-05-22 11:25:29 +02:00
Yu Watanabe
2fbbf6c4c7 unit-def: reindent comments
Prompted by dfdeb0b1cb.
2025-05-22 05:15:08 +09:00
Yu Watanabe
276ddd8a91 logind: state serialization fixes (#37555)
Turns out our escaping was really broken when saving/restoring
session/seat/user state. Let's fix that.
2025-05-22 03:54:40 +09:00
Lennart Poettering
c450027d14 env-file: rework write_env_file() to make use of O_TMPFILE 2025-05-22 02:50:48 +09:00
Lennart Poettering
e27333b2cc env-file: add helper for printing a properly escaped env var file assignment 2025-05-21 17:33:40 +02:00
Daan De Meyer
44599b20bc stat-util: Use typeof_field() in one more place 2025-05-21 13:24:42 +02:00
Yu Watanabe
ef27ebab08 Clean up more includes (#37527)
Split out of #37344
2025-05-21 19:43:39 +09:00
Jelle van der Waa
d8b9f67e67 treewide: fix header file definitions 2025-05-21 10:50:25 +02:00
Daan De Meyer
fa34123c35 test: Clean up includes
To make sure everything still compiles, we add a preliminary include
of forward.h to tests.h to make sure it is included in every test source
file. We'll clean up the tests.h includes in a later commit.

We also add a <errno.h> include to errno-list.h to keep test-errno-list.c
compiling. It'll be removed again when we clean up includes in src/basic.

Split out of #37344.
2025-05-21 10:49:42 +02:00
Daan De Meyer
8b5ce49591 basic: Include time-util.h in constants.h
constants.h defines a bunch of constants that use macros from
time-util.h, so add the needed include. To avoid cyclic dependencies,
we move the HAS_FEATURE_MEMORY_SANITIZER and HAS_FEATURE_ADDRESS_SANITIZER
logic to macro.h and get rid of the constants.h include there.

The rest of this commit is adding missing constants.h includes where
needed due to it being removed from macro.h.
2025-05-21 10:49:42 +02:00
Daan De Meyer
4c26a68f7b forward.h: Add forward declaration of BusObjectImplementation 2025-05-21 10:12:19 +02:00
Luca Boccassi
27ffdb6d9e {pidfd,cgroup}-util: avoid alignment warning when accessing f_handle (#37520)
NetworkManager imports some systemd code, which we then build with
`-Wcast-align=strict`. This results in this warning:

```
../src/libnm-systemd-shared/src/basic/pidfd-util.c: In function 'pidfd_get_inode_id':
../src/libnm-systemd-shared/src/basic/pidfd-util.c:255:41: warning: cast increases required alignment of target type [-Wcast-align]
  255 |                                 *ret = *(uint64_t*) fh.file_handle.f_handle;
      |                                         ^
```

Since the address of `f_handle` should always be aligned at the word
boundary (it is preceded by 2 int`s` in `file_handle`), this patch uses
`CAST_ALIGN_PTR()` to avoid this warning.
2025-05-20 14:50:22 +01:00
Luca Boccassi
82d3551fbf repart: add --append-fstab parameter (#37238)
If --generate-fstab=PATH is used, there is the possibility that the
fstab file already exists, making systemd-repart fail.

This commit will add a new --append-fstab= parameter, that will read
the file and merge it with the new generated content.  Using the
comments, the command can separate the automatic-generated section from
the user-provided section, allowing for the next append the replacement
only of the automatic-generated section, keeping the user one.
2025-05-20 14:49:43 +01:00
Daan De Meyer
1fda0f4cae Various meson improvements (#37510) 2025-05-20 13:44:33 +02:00
Luca Boccassi
6946eed3fa core: Also refresh confext extensions when reloading notify-reload service (#33995)
`ExtensionImages=` and `ExtensionDirectories=` now let you specify
vpick-named extensions; however, since they just get set up once when
the service is started, you can't see newer versions without restarting
the service entirely. Here, also reload confext extensions when you
reload a service. This allows you to deploy a new version of some
configuration and have it picked up at reload time without interruption
to your workload.

Right now, we would only reload confext extensions and leave the sysext
ones behind, since it didn't seem prudent to swap out what is likely
program code at reload. This is made possible by only going for the
`SYSTEMD_CONFEXT_HIERARCHIES` overlays (which only contains `/etc`).

This PR:
- Adjusts `service.c` to also refresh extensions when needed. 
- Adds integration tests to check that a confext reload actually
occurred.
- Adds to the `systemd.exec` man pages to document this behavior.

This is a follow up to #24864 and #31364. Thank you to @bluca and
@goenkam for help in getting this up.
2025-05-20 11:27:34 +01:00
Jan Vaclav
4d2e61211d cgroup-util: avoid alignment warning when accessing f_handle 2025-05-20 12:16:31 +02:00
Jan Vaclav
b900a8d827 pidfd-util: avoid alignment warning when accessing f_handle 2025-05-20 12:07:43 +02:00
Daan De Meyer
d86fead481 meson: Rework clang-tidy integration to be done via unit tests
Instead of using run-clang-tidy.py with its own scheduling, let's
just gather a list of source files ourselves and then use that to
add a unit test for each source file that runs clang-tidy on the
source file.

We also add a bit of logic to run clang-tidy on most header files
as well for extra coverage. This uncovered various header files that
were not standalone so this commit also includes fixes to make sure
the clang-tidy tests are all green.

We can also use this in a later commit to run clang-include-cleaner
on each source file in the same way.
2025-05-20 10:29:59 +02:00
Alberto Planas
ba2d8107e2 string-util: add find_line[_after] functions
As a wrapper for `find_line_startswith`, `find_line_after` search for
the exact line and return the pointer for the next line, or NULL if
missing.

`find_line` with search for the exact line and return the pointer to the
beginning of the line.

Signed-off-by: Alberto Planas <aplanas@suse.com>
2025-05-20 10:29:33 +02:00
Mike Yuan
dbe592a067 cgroup-util: modernize cg_get_keyed_attribute()
- assert on supplied keys being unique
- Reject duplicate attributes with -EBADMSG
- Rename 'ret_values' to just 'values', given we don't
  allocate the array
- Remove now unused cg_get_keyed_attribute_graceful()
2025-05-19 21:24:18 +02:00
maia x.
dfdeb0b1cb core: reload confexts when reloading notify-reload services
`ExtensionImages=` and `ExtensionDirectories=` now let you specify
vpick-named extensions; however, since they just get set up once when
the service is started, you can't see newer versions without restarting
the service entirely.  Here, also reload confext extensions when you
reload a service. This allows you to deploy a new version of some
configuration and have it picked up at reload time without interruption
to your workload.

Right now, we would only reload confext extensions and leave the sysext
ones behind, since it didn't seem prudent to swap out what is likely
program code at reload. This is made possible by only going for the
`SYSTEMD_CONFEXT_HIERARCHIES` overlays (which only contains `/etc`).

Implementation wise, this uses the new kernel API and two collaborating
child processes under the host & child namespaces in order to gather the
right FDs needed:

  - (1) In child, set up the extension images and directories in a slave
	mountns, and obtain their FDs.
  - (2) Fork into a grandchild under target process namespace, and do a
        "fake" unmount to obtain the FD of the underlying target folder
	say /etc).
  - (3) In the child again, set up new overlay under host NS rights.

We do not want to do I/O heavy jobs inline in PID1 blocking the state
machine, so add separate async states to handle this case.

Co-authored-by: Luca Boccassi <luca.boccassi@gmail.com>
2025-05-19 13:36:21 +01:00
Mike Yuan
13cb664181 terminal-util: restore terminal settings if fd_reopen() fails
Follow-up for a0c314d6b0
2025-05-17 12:33:26 +01:00
Yu Watanabe
7c087d802f Remove overzealous checks (#37493) 2025-05-17 01:37:18 +09:00
Zbigniew Jędrzejewski-Szmek
f4bdf373c5 basic/terminal-util: simplify output param handling
Those static functions were written to support optional output params, but they
are only ever called with the output param set, and it doesn't make sense to
ever call them without the output param. Since those are internal functions,
drop this unused complexity.
2025-05-16 15:33:50 +02:00
Zbigniew Jędrzejewski-Szmek
5b5545f112 basic/terminal-util: drop 'U' suffix
C automatically casts a signed int to unsigned in binary operation with an
unsigned int. Thus that suffix is not useful. Also surrounding code doesn't use
it.
2025-05-16 15:33:10 +02:00
Lennart Poettering
b177095bfa terminal-util: explicitly reset cursor
Apparently there are terminals where our usual reset is not enough to
turn the cursor back on. Hence do so explicitly.

Fixes: #22168
2025-05-16 21:42:32 +09:00
Daan De Meyer
ef10d4b526 Bugprone argument comment - round 5 (#37481) 2025-05-15 20:33:50 +02:00
Jelle van der Waa
346c62f9ca treewide: correct argument comments 2025-05-15 15:39:20 +02:00
Mike Yuan
7762e9bbb2 core: always enable CPU accounting; cgtop: drop cgv1 handling (#37448) 2025-05-15 14:41:07 +02:00
Jelle van der Waa
274da0b67b terminal-util: rename openpt_allocate_* ret_peer argument
Make it consistent with its implementation.
2025-05-15 11:12:43 +02:00
Lennart Poettering
272017d32a socket-util: add trivial socket_get_cookie() helper 2025-05-15 09:45:19 +02:00
Mike Yuan
29da53dde3 core: always enable CPU accounting
Our baseline is v5.4 and cgroup v2 is enforced now,
which means CPU accounting is cheap everywhere without
requiring any controller, hence just remove the directive.
2025-05-15 02:19:16 +02:00
Mike Yuan
946eea7a7f mountpoint-util: remove unused TMPFS_LIMITS_SYS_FS_CGROUP
Follow-up for 6801a9d88a
2025-05-15 09:00:51 +09:00
Mike Yuan
68a2435cc2 cgroup-util: drop cg_kill() cgroup.threads kludge
Our baseline is v5.4 now.
2025-05-15 07:26:03 +09:00
Daan De Meyer
3b21af5234 hashmap: Split out iterator.h
As preparation for #37344, let's split out iterator.h so we can
avoid including the entirety of hashmap.h where it's not needed.
2025-05-15 00:01:32 +02:00
Daan De Meyer
0dc510ab03 tpm2-util: Make sure structs/enums are named and add to forward.h
We have to name structs/enums to be able to forward declare them, so
let's do that and add the missing ones to forward.h.
2025-05-14 22:34:02 +02:00
Yu Watanabe
1ef6cee327 Bugprone argument comment - round 4 (#37380)
Follow up from https://github.com/systemd/systemd/pull/37356
2025-05-15 03:36:16 +09:00
Daan De Meyer
17b0d165f6 capability-util: Ignore unknown capabilities instead of aborting
capability_quintet_mangle() can be called with capability sets
containing unknown capabilities. Let's not crash when this is the
case but instead ignore the unknown capabilities.

Fixes d5e12dc75e
2025-05-15 03:33:32 +09:00