Commit Graph

6336 Commits

Author SHA1 Message Date
Lennart Poettering
bd4beaa2eb tree-wide: always do dlopen() with RTLD_NOW + RTLD_NODELETE
Let's systematically use RTL_NOW|RLTD_NODELETE as flags passed to
dlopen(), across our codebase.

Various distros build with "-z now" anyway, hence it's weird to specify
RTLD_LAZY trying to override that (which it doesn't). Hence, let's
follow suit, and just do what everybody else does.

Also set RTLD_NODELETE, which is apparently what distros will probably
end up implying sooner or later anyway. Given that for pretty much all
our dlopen() calls we never call dlclose() anyway, let's just set this
everywhere too, to make things systematic.

This way, the flags we use by default match what distros such as fedora
do, there are no surprises, and read-only relocations can be a thing.

Fixes: #34537
2024-10-02 07:13:21 +02:00
Lennart Poettering
0a73c8e7b8 linux: import input.h and friends
The CIs apparently have rally old headers, where KEY_BRIGHTNESS_AUTO is
missing, let's hence ship our own copies from a current kernel.
2024-10-01 18:35:00 +02:00
Yu Watanabe
bfa834f138 Merge pull request #34511 from YHNdnzj/strv-extend-strv-consume
basic/strv: introduce strv_extend_strv_consume()
2024-09-21 13:57:02 +09:00
Mike Yuan
a2c8652a2a tree-wide: use strv_extend_strv_consume() where appropriate 2024-09-21 00:53:50 +02:00
Mike Yuan
8a7ade7427 basic/strv: introduce strv_extend_strv_consume() 2024-09-21 00:53:49 +02:00
Mike Yuan
527b9e2437 basic/strv: make string_strv_hash_ops static, add missing assertions 2024-09-20 22:44:35 +02:00
Mike Yuan
47941afd17 basic/memory-util: make mempcpy_typesafe() take number of obj rather than raw size
Follow-up for eda6223942
2024-09-20 22:44:34 +02:00
Mike Yuan
34fb408f8b basic: replace size_multiply_overflow() with MUL_ASSIGN_SAFE where applicable 2024-09-20 22:44:34 +02:00
Mike Yuan
175de2c28e basic/macro: move DECIMAL_STR_FMT to shared/tests
This shall never be used outside of test functions.
2024-09-20 22:44:34 +02:00
Yu Watanabe
ffdf497860 strv: introduce strv_find_closest()
Follow-up for 1e1ac5d53b.
2024-09-21 05:06:12 +09:00
Michael Ferrari
1e1ac5d53b firstboot: add similar input suggestion
This uses the same logic as similar verb suggestion for command line
utilities. Try to be helpful when the user entered something invalid
instead of just showing the prompt again.
2024-09-20 08:34:03 +09:00
Mike Yuan
eda6223942 basic/memory-util: introduce mempcpy_typesafe 2024-09-20 08:29:35 +09:00
Yu Watanabe
4f2975385f Merge pull request #34040 from AdrianVovk/repart-dollar-boot
repart: Implement $BOOT support
2024-09-18 05:09:20 +09:00
Daan De Meyer
0432e28394 Merge pull request #34440 from yuwata/network-log-no-matching-network
network: log when no matching .network file found
2024-09-17 21:09:19 +02:00
Michael Ferrari
91ea3dcf35 homed: wait for user input during firstboot
This mirrors the behavior of `systemd-firstboot` and allows bootup
messages to settle down before user input is actually processed.

See: https://github.com/systemd/systemd/issues/34448
2024-09-18 03:21:11 +09:00
Adrian Vovk
e671bdc5c3 strv: Fixup STRV_FOREACH_PAIR macro
The macro didn't properly parenthesize a caller-controlled argument.
For example: `STRV_FOREACH_PAIR(a, b, something ?: something_else)`
would expand to `typeof(*something ?: something_else)`, which would
cause compile failures
2024-09-17 14:06:26 -04:00
Yu Watanabe
572d031eca log: introduce log_oom_full() 2024-09-18 02:50:19 +09:00
Mike Yuan
93d2d36638 basic/build: also include BTF status 2024-09-16 10:42:16 +09:00
Lennart Poettering
c8d60ae79d efivars: add helper that reads an fs path from an efi var 2024-09-15 19:34:19 +02:00
Lennart Poettering
d7a6bb9891 tree-wide: make sigprocmask() changes more automatic
This tries to get rid of most manual sigprocmask() changes, in favour
of:

1. The SD_EVENT_SIGNAL_PROCMASK flag to sd_event_add_signal()
2. The sd_event_set_signal_exit() call for handling SIGTERM/SIGINT
3. Move masking of SIGWINCH into ptyfwd, out of nspawn/vmspawn/run

And while we are at it get rid of a bunch of event source fields whose
lifetime is bound to the sd_event object they belong to anyway, and make
use of the "floating" event source feature of sd-event instead.
2024-09-13 17:12:28 +02:00
Lennart Poettering
868258cf38 basic: split ifname related calls from format-util.h into format-ifname.h
This way we don't have to pull in net/if.h into format-util.h.

This is supposed to address https://github.com/systemd/systemd/pull/32212#discussion_r1755639881

No actual code changes, just a .c/.h file split-up.
2024-09-13 07:27:47 +02:00
Matteo Croce
64e03ca8bf minor fixups for #32212
Fix minor post merge comments
2024-09-13 07:23:07 +02:00
Lennart Poettering
5892950ba4 Merge pull request #32212 from teknoraver/networkd-sysctl
More visibility into systemd-networkd sysctls
2024-09-12 17:28:59 +02:00
Lennart Poettering
1d551b1e7d syscalls: run "ninja update-syscalls-*" 2024-09-12 14:20:50 +02:00
Matteo Croce
766bcf302a extend sysctl functions to shadow values
Pass to all the sysctl_* functions a hashmap which can be used to
optionally save the value written in the sysctl.
2024-09-11 23:01:25 +02:00
Mike Yuan
4ec630bfba Merge pull request #33833 from YHNdnzj/manager-reload-assert
core/manager: do not re-init Manager.lookup_paths when manager_reload(), minor assorted cleanups
2024-09-09 14:21:57 +02:00
Yu Watanabe
85fd8df03d missing_socket: drop unnecessary definitions
Now, we have copy of vm_sockets.h, hence these definitions are not
necessary anymore.
2024-09-09 14:52:18 +09:00
Yu Watanabe
47a71f9852 missing_network: drop unnecessary definition
Now we have ipv6.h, hence the definition is not necessary anymore.
2024-09-09 14:52:18 +09:00
Yu Watanabe
0ca88780d6 arphrd-list: use imported linux/if_arp.h 2024-09-09 14:52:18 +09:00
Yu Watanabe
a84649592c linux: import more network related headers from v6.11-rc6
Hopefully, no effective change.
2024-09-09 14:52:18 +09:00
Mike Yuan
978e7d166c terminal-util: correct fd validity check
Follow-up for 14f594b995
2024-09-08 20:45:33 +02:00
Mike Yuan
5bab5e4ac3 chattr-util: use BIT_FOREACH where appropriate 2024-09-07 14:46:18 +02:00
Mike Yuan
26f5897767 chattr-util: set O_NOCTTY when reopening O_PATH fd
Follow-up for 07862c9fc2
2024-09-07 14:46:18 +02:00
Lennart Poettering
664570f531 iovec-util: add iovec_append() for appending to an existing iovec 2024-09-06 15:23:14 +02:00
Lennart Poettering
f3389fffd6 user-util: switch from utmp to utmpx
We generally use utmpx instead of utmp (both are actually identical on
Linux, but utmpx is POSIX, while utmp is not). Let's fix one left-over
case.

UT_NAMESIZE does not exist in utmpx world, it has no direct counterpart,
hence let's just sizeof_field() to determine the size of the actual
field. (which comes to the same result of course: 32).
2024-09-06 13:54:09 +02:00
Yu Watanabe
ccd62e6d4d Merge pull request #34155 from poettering/gmtime-safe
handle gmtime_r() errors more robustly
2024-09-06 09:07:48 +09:00
A. Wilcox
d0e11b9e17 basic: Include <sys/file.h> for LOCK_* constants
This is needed to ensure LOCK_{EX,SH} are defined in certain
environments, including uclibc-ng and musl libc.
2024-09-06 08:37:25 +09:00
Lennart Poettering
6f5cf41570 time-util: rework localtime_or_gmtime() into localtime_or_gmtime_usec()
We typically want to deal in usec_t, hence let's change the prototype
accordingly, and do proper range checks. Also, make sure are not
confused by negative times.

Do something similar for mktime_or_timegm().

This is a more comprehensive alternative to #34065

Replaces: #34065
2024-09-05 17:40:25 +02:00
Yu Watanabe
3ce22ee7f8 Merge pull request #34090 from DaanDeMeyer/cow-fix
Rework COW <=> NOCOW copying behavior
2024-09-05 10:19:49 +09:00
Daan De Meyer
07862c9fc2 chattr-util: Optimize read_attr_at()
Let's make sure we only reopen O_PATH file descriptors.
2024-09-04 18:51:53 +02:00
Mike Yuan
ad501930d7 socket-util: make recvmsg_safe() handle MSG_TRUNC too
Also, unify MSG_TRUNC handling all across the codebase.
2024-09-04 18:51:44 +02:00
Mike Yuan
190a095380 audit-util: check correct errno 2024-09-04 18:50:54 +02:00
Mike Yuan
d6024cb3c1 fd-util: also close pidfd from SCM_PIDFD in cmsg_close_all() 2024-09-04 18:50:54 +02:00
Yu Watanabe
382886fe11 log: protect errno from log_syntax_invalid_utf8_internal()
Potentially, utf8_escape_invalid() called by
log_syntax_invalid_utf8_internal() may update errno.
2024-09-02 05:45:09 +09:00
Yu Watanabe
1e04eb00f7 log: introduce log_syntax_parse_error()
This provides generic error message for failures in conf parsers.
Currently this is not used, but will be used later.
2024-09-02 05:45:04 +09:00
Mike Yuan
9517c81747 basic/raw-clone: refuse CLONE_PIDFD too 2024-09-01 10:44:39 +09:00
Luca Boccassi
5162829ec8 core: do BindMount/MountImage operations in async control process
These operations might require slow I/O, and thus might block PID1's main
loop for an undeterminated amount of time. Instead of performing them
inline, fork a worker process and stash away the D-Bus message, and reply
once we get a SIGCHILD indicating they have completed. That way we don't
break compatibility and callers can continue to rely on the fact that when
they get the method reply the operation either succeeded or failed.

To keep backward compatibility, unlike reload control processes, these
are ran inside init.scope and not the target cgroup. Unlike ExecReload,
this is under our control and is not defined by the unit. This is necessary
because previously the operation also wasn't ran from the target cgroup,
so suddenly forking a copy-on-write copy of pid1 into the target cgroup
will make memory usage spike, and if there is a MemoryMax= or MemoryHigh=
set and the cgroup is already close to the limit, it will cause an OOM
kill, where previously it would have worked fine.
2024-08-29 12:48:55 +01:00
Yu Watanabe
83c187f585 parse-util: drop unused parse_ip_prefix_length() 2024-08-25 06:18:30 +09:00
Mike Yuan
d71f138156 basic/sigbus: use FOREACH_ELEMENT where appropriate, assert >= 0 for success 2024-08-22 20:14:25 +02:00
Mike Yuan
e06c5be29a process-util: always retry with pidfd_spawn() w/o cgroup first
Follow-up for 7ac58157ca

With the mentioned commit, iff E2BIG we'd retry pidfd_spawn()
with POSIX_SPAWN_SETCGROUP disabled. However, the same strategy
should actually apply to EOPNOTSUPP/ENOSYS/EPERM too -
they can mean two things here: no clone3() or no CLONE_PIDFD.
Therefore, let's first try clone() + CLONE_PIDFD, and fall further back
to plain clone() (posix_spawn()) only as last resort. Plus, record
the fact so that we don't unnecessarily retry every single time
if CLONE_PIDFD is the one that's unavailable.
2024-08-21 15:27:57 +02:00