Commit Graph

7024 Commits

Author SHA1 Message Date
Mike Yuan
f66eeedf6f missing_socket: add SO_PASSRIGHTS 2025-06-17 13:16:42 +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
Alex
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
Mike Yuan
c51379e6d8 Use DCS sequence to query terminal name and set $TERM automatically (#37538)
This code seems to work quickly and nicely for a bunch of modern
terminals. Setting $TERM automatically removes an common annoyance for
users. This code will not work for all terminal emulators, but by adding
it in systemd we'll entice maintainers of those terminals to add support
for the sequences. For the terminals that don't support the sequence, we
get a bit of a slowdown of `< 1 ms`, which seems hardly noticeable. The
user can always set TERM explicitly to avoid this if upgrading to a
newer terminal emulator is not possible.

Closes https://github.com/systemd/systemd/issues/36994.
2025-05-29 21:01:01 +02:00
Zbigniew Jędrzejewski-Szmek
f256e48d4e basic/terminal-util: drop now-unused default_term_for_tty 2025-05-29 19:20:31 +02:00
Zbigniew Jędrzejewski-Szmek
ad6ca4a612 core: use terminal DCS sequence to set $TERM
query_term_for_tty() is used in two places: in fixup_environment(),
which affects PID1 itself, and in build_environment(), which affects
spawned services. There is obviously some cost to the extra call,
but I think it's worthwhile to do it. When $TERM is set incorrectly,
basic output works OK, but then there are various annoying corner
cases. In particular, we get the support for color (or lack of it)
wrong, and when output is garbled, users are annoyed. Things like
text editors are almost certain to behave incorrectly. Testing in
test-terminal-util indicates that the time required to make a successful
query is on the order of a dozen microseconds, and an unsuccessful
query costs as much as our timeout, i.e. currently 1/3 ms. I think
this is an acceptable tradeoff.

No caching is used, because fixup_environment() is only called once,
and the other place in build_environment(), only affects services
which are connected to a tty, which is only a handful of services,
and often only started in special circumstances.

Fixes https://github.com/systemd/systemd/issues/36994.
2025-05-29 19:20:31 +02:00
Zbigniew Jędrzejewski-Szmek
e3b050a5c2 basic/terminal-util: add a heuristic check whether terminfo file exists 2025-05-29 19:20:31 +02:00
Zbigniew Jędrzejewski-Szmek
5321b957b4 basic/terminal-util: query terminal name by DCS
As requested in https://github.com/systemd/systemd/issues/36994,
use DCS + q name ST. This works, but has limited terminal support:
xterm, foot, kitty.
2025-05-29 19:20:31 +02:00
Mike Yuan
cd3435fc0b cgroup-util: drop CGROUP_MASK_EXTEND_JOINED
Also kill the "compat pair invalidation" logic in unit_invalidate_cgroup()
2025-05-28 00:53:24 +02:00
Mike Yuan
9e73d37512 cgroup-util: move CGROUP_CPU_SHARES/BLKIO* to nspawn-oci
These are only used for translation from OCI metadata
to cgroup v2 values.
2025-05-28 00:21:37 +02:00
Yu Watanabe
ae6420c923 cgroup-util: minor cleanups (#37630) 2025-05-28 02:19:21 +09:00
Jan Vaclav
a8a39e23bb in-addr-util: use s6_addr* macros everywhere
Currently, the code in in-addr-util.c uses a mix of accessing the
in6_u members directly, as well as using the s6_addr* macros.
Let's unify it so that the s6_addr macros are used everwhere.
2025-05-27 22:33:57 +09:00
Mike Yuan
a941822d1c cgroup-util: assert on attribute for cg_{get,set}_attribute()
It makes zero sense to ever perform IO operations on cgroup dirs.
2025-05-27 14:31:06 +02:00
Mike Yuan
606ef91a40 cgroup-util: make cg_get_attribute_as_bool() return 0/1 directly
As with getenv_bool() and getxattr_at_bool(), to match
our usual style.
2025-05-27 14:28:08 +02:00
Mike Yuan
7b4022bdb0 cgroup-util: rename cg_get_xattr_malloc -> cg_get_xattr
This is not a trivial wrapper around user-created-buffer-based
syscall, so do not use _malloc suffix. Most of our functions
return an internally allocated buffer and this one's not special.
2025-05-27 14:28:08 +02:00