Commit Graph
7036 Commits
Author SHA1 Message Date
Yu Watanabe cef4ec347f ioprio-util: move from basic/ to shared/
It is not used by libsystemd.
2025-06-19 19:08:45 +09:00
Yu Watanabe d26faa3186 missing_network: IPPROTO_MPTCP is already defined in linux/in.h
And the header is already included through (our implementation of)
netinet/in.h, hence we can safely drop the definition here.
2025-06-19 19:08:45 +09:00
Yu Watanabe 92b64168f6 sd-lldp: replace ETHERTYPE_LLDP with ETH_P_LLDP
ETH_P_LLDP is defined in linux/if_ether.h.
2025-06-19 19:08:45 +09:00
Yu Watanabe dbfe2faa48 port write_env_file() to label_os_pre() + teach firstboot a bit of relabelling (#37869)
This is a clean-up, and also addresses some of the points of #37857.
2025-06-19 18:03:12 +09:00
Lennart Poettering ea71d34738 fd-util: move cmsg_close_all() to socket-util.[ch]
This call only makes sense on sockets, it's not a generic fd concept,
hence let's move this over.
2025-06-18 19:06:11 +09:00
Yu Watanabe 43aacae83a dirent-util: use getdents64() as is
This partially reverts e86a492ff0.

The function getdents64() was introduced in glibc-2.30, and our baseline
on glibc is 2.31. Hence, we can assume the function always exists.
The posix_getdents() wrapper was introduced for compatibility with musl.
However, even the latest release of musl does not provide posix_getdents()
yet. Also, even with musl, by defining _LARGEFILE64_SOURCE, we can get
getdents64() and struct dirent64. Hence, the wrapper is anyway not
necessary.
2025-06-18 10:45:49 +02:00
Yu Watanabe abb99d3168 mallinfo-util: assume mallinfo() exists
The check existed for musl. Let's remove it, as we explicitly request glibc.

While removing the check, this also drops generic_mallinfo, introduces
a tiny converter from struct mallinfo to struct mallinfo2 if mallinfo2()
does not exist, and renames mallinfo-util.h to malloc.h.

With this change, we can drop many ifdefs and casts in .c files.
2025-06-18 10:45:27 +02:00
Lennart Poettering 3e5320e27d env-file: port write_env_file() to label_ops_pre()
Let's make more use of label_ops_pre()/label_ops_post(), and replace
write_env_file_label() by a flag to write_env_file().

This simplifies and normalizes the code.

This also makes one relevant change: it sets the new
WRITE_ENV_FILE_LABEL flag in firstboot.c when we write locale.conf,
where we previously did not (but should have). This should address one
detail of #37857.
2025-06-18 10:21:26 +02:00
Lennart Poettering 9ea5a6e7d6 fs-util: replace symlink_atomic_full_label() by a flag to symlinkat_atomic_full()
More porting work to label_ops_pre()/label_ops_post()

This also enables labelling of the /etc/localtime symlink in
systemd-firstboot, which should address one small facet of #37857
2025-06-18 10:21:25 +02:00
Daan De Meyer 4fe348cfdf cgroup-util: Always open cgroupv2 attribute files in O_NONBLOCK mode
As explained in https://lore.kernel.org/all/20250419183545.1982187-1-shakeel.butt@linux.dev/,
writing to memory.max or memory.high triggers synchronous memory reclaim
if the limit is lowered. This can end up taking nonnegligible amounts
of time, completely blocking pid1 from doing any other work while the
reclaim is ongoing.

To address this problem, the kernel going to add O_NONBLOCK semantics
to memory.max and memory.high. If the file is opened with O_NONBLOCK,
the synchronous memory reclaim is skipped and only triggered later
without blocking the process writing the file. Let's make sure we make
use of this by opening cgroupv2 attribute files with O_NONBLOCK.

We opt to do this for all cgroupv2 attribute files, to make sure that
if the same problem happens elsewhere in the future and is fixed in the
same way, we immediately take advantage of that fix without having to
make changes in systemd as well. We probably never want to block when
writing cgroupv2 attributes and any cases where we do want to block should
indicate so explicitly instead of blocking by default.
2025-06-17 15:07:32 +01:00
Lennart Poettering ef3a0ed834 various: turn off SO_PASSRIGHTS where fds are not expected (#37759) 2025-06-17 15:37:35 +02:00
Mike Yuan f66eeedf6f missing_socket: add SO_PASSRIGHTS 2025-06-17 13:16:42 +02:00
Mike Yuan 020d85c8e3 log: drop redundant forward decl
These are defined in forward.h already.
2025-06-17 11:44:50 +02:00
Mike Yuan 4c6fbe733b hostname-util: introduce machine_spec_valid() 2025-06-17 01:39:57 +02:00
Mike Yuan d2e727bf68 hostname-util: do not allow empty machine spec
Follow-up for 2ae32e9d8f

Let's not open this up even further and rather disallow
--machine="".
2025-06-17 01:39:56 +02:00
Yu Watanabe a4eb5094e6 terminal-util: fix doubled 'to' in log messages
Follow-up for 3390be38d1.
2025-06-16 22:25:27 +09:00
Mike Yuan deedd5c26e terminal-util: modernize ptsname_malloc a bit 2025-06-16 20:08:52 +09:00
Mike Yuan 2a1338242d socket-util: drop duplicate SCM_MAX_FD definition
We already carry it in missing_socket.h
2025-06-16 12:16:03 +02:00
Yu Watanabe 38de38a70d ordered-set: introduce ordered_set_put_strdup_full() and friends which take hash ops 2025-06-14 00:06:43 +09:00
Yu Watanabe 361b13ca7e include/linux: update kernel headers from v6.16-rc1 2025-06-12 16:04:40 +01:00
Mike Yuan d9bf815093 string-util: introduce strprepend_with_separator() 2025-06-11 12:50:51 +09:00
Yu Watanabe 58bb08be6d dirent-util: follow our coding style 2025-06-10 12:57:01 +09:00
Mike Yuan 0e9667fd9a basic/forward: replace tab with space 2025-06-09 20:39:23 +02:00
Yu Watanabe 4081e072ee Several follow-ups for recent header cleanups (#37785) 2025-06-10 01:01:05 +09:00
Yu Watanabe 169d270e81 meson: update generating lists
- config.h is not necessary when generating lists, hence drop it.
- linux/audit.h and libaudit.h are included by missing_audit.h,
  hence not necessary to include them explicitly.
2025-06-09 16:29:49 +01:00
Yu Watanabe afe1567297 include: net/if.h requires features.h
The header uses __THROW, which is defined in features.h, to make the
header self-consistent.
Note, src/basic/include/sys/mount.h also uses __THROW, and includes
features.h.
2025-06-09 22:45:23 +09:00
Yu Watanabe afcb6d671b forward: also include paths.h
It provides several important constants, especially _PATH_BSHELL, which
is used in PID1, executor, and run. The header has been included
indirectly through e.g. libmount.h, mntent.h, utmpx.h, and so on.
Let's explicitly include it in forward.h, as libmount.h and friends that
includes paths.h are irrelevant to _PATH_BSHELL, and we may easily fail
to build when code is touched.
The header is not heavy, hence should not hurt anything.
2025-06-09 22:45:23 +09:00
Daan De Meyer 1b4645d762 forward: Drop socklen_t forward declaration
This is glibc specific and doesn't exist on musl, since removing only
means adding one more include in selinux-util.h, let's drop it.

Fixes #37779
2025-06-08 10:58:56 +09:00
Lennart Poettering 1de31f23a0 conf-files: use proper enum for flags parameters 2025-06-06 09:04:38 +02:00
Lennart Poettering 4295c0db5f hostname-util: add new helper split_user_at_host()
Let's introduce a common helper for splitting user@host specifications
like we use them for --machine=.
2025-06-05 12:44:08 +02:00
Mike Yuan a842c26be3 pidfd-util: extract pidfd_get_inode_id_impl() and make it thread safe
Preparation for later commits.
2025-06-05 00:28:01 +02:00
Mike Yuan e09b7ced65 pidfd-util: open an internal pidfd if none is passed in pidfd_check_pidfs()
I'd like to introduce a libsystemd helper for acquiring pidfd
inode id, which however means the fd passed to pidfd_check_pidfs()
can no longer be trusted. Let's add back the logic of allocating
a genuine pidfd allocated internally, which was remove in
5dc9d5b4ea.
2025-06-05 00:28:01 +02:00
Lennart Poettering 4f4113ee33 sd-login: various modernizations (#37728) 2025-06-04 22:24:57 +02:00
Lennart Poettering 874c4beb24 io-util: protect against INT_MAX overflow in flush_fd() 2025-06-04 22:06:52 +02:00
Lennart Poettering e74c1e1cac compress: get rid of a bunch of 'else' 2025-06-04 18:04:27 +02:00
Lennart Poettering eac4a028df sd-login: modernize return parameter handling
Let's rename the return parameters as "ret_xyz" systematically in
sd-login.

Also, let's make the return parameters systematically optional, like we
typically do these days. So far some where optional, other's weren't.
Let's clean this up.
2025-06-04 17:58:42 +02:00
Jelle van der Waa 93117b0fbd cgroup-util: rename 'fsfd' -> 'cgroups_fd'
Makes the header and implementation consistent.
2025-06-04 10:45:54 +02:00
Lennart Poettering d483ac1d0d compress: avoid a bunch of div-by-zeroes
Follow-up for #37706. Implements the same logic for all compression
algorithms we have.
2025-06-03 18:27:02 +02:00
Yu Watanabe a491eca403 Bugprone argument comment 8 (#37678)
Follow up from https://github.com/systemd/systemd/pull/37556
2025-06-03 10:58:52 +09:00
Alexandjinyaoguo 2584f745e0 compress: prevent divide-by-zero when no data is read (#37706)
If the first call to `loop_read()` returns 0 (no input), `total_in`
remains 0, causing `total_out/total_in` to potential divide by zero.

We add a check before logging the compression ratio to skip the
percentage calculation when total_in is zero.

Co-authored-by: jinyaoguo <guo846@purdue.edu>
2025-06-03 10:51:00 +09:00
Jelle van der Waa fa6f4484e8 io-util: rename 'nfds' -> 'n_fds' 2025-06-02 18:05:45 +02:00
Jelle van der Waa 8821a312a8 uid-range: correct argument comment 2025-06-02 17:39:44 +02:00
Jelle van der Waa d4f938aec1 env-util: rename 'n' -> 'length' 2025-06-02 17:39:43 +02:00
Zbigniew Jędrzejewski-Szmek b83f69952b Deduplicate error string patterns (#37676)
I wanted to see if moving moving out constant string arguments our of
error messages results in smaller binary sizes. Turns out it does, but
the savings are not consistent. Sometimes we get a few kB in a single
binary, sometimes there is no size change.
2025-06-02 15:34:17 +02:00
Adrian Vovk 554130faf3 Define uid range for greeter
In multi-seat scenarios, a display manager might need to start multiple
greeter sessions. But systemd allows at most one graphical session per
user. So, display managers now have a range of UIDs to dynamically
allocate users for their greeter sessions.
2025-06-02 11:19:12 +02:00
Zbigniew Jędrzejewski-Szmek 42ba99748d various: do not include file names directly in error messages
git grep -l 'Failed to open /'|xargs sed -r -i 's|"Failed to open (/[^ ]+): %m"|"Failed to open %s: %m", "\1"|g'
git grep -l $'Failed to open \'/'|xargs sed -r -i $'s|"Failed to open \'(/[^ ]+)\': %m"|"Failed to open %s: %m", "\\1"|g'
git grep -l "Failed to open /"|xargs sed -r -i $'s|"Failed to open (/[^ ]+), ignoring: %m"|"Failed to open %s, ignoring: %m", "\\1"|g'
+ some manual fixups.
2025-06-02 11:10:38 +02:00
Lennart Poettering 1105f8d20f tree-wide: only use .si_pid field in siginfo_t, if .si_code indicates that's safe
Fixes: #37498
2025-05-31 14:48:37 +02:00
Yu Watanabe 3ec92f2f74 terminal-util: fix typo
Follow-up for 5321b957b4.
2025-05-31 04:44:34 +09:00
Mike Yuan 4d67fcabed env-util: add missing assertions 2025-05-29 21:01:43 +02:00
Mike Yuan a9b053deb1 env-util: modernize *_is_valid() 2025-05-29 21:01:43 +02:00