Commit Graph

5954 Commits

Author SHA1 Message Date
Luca Boccassi
60cf40599a escape: fix operator precedence in overflow check
CID#1535100

Follow-up for c6342e35b0
2024-03-07 00:46:21 +00:00
Yu Watanabe
3d1279af79 meson: add missing dependency to libdl
Follow-up for 1c20c9f4fc.

Fixes https://github.com/systemd/systemd/pull/31550#issuecomment-1980458377.
2024-03-06 17:24:03 +00:00
Luca Boccassi
5e575e4d92 Merge pull request #31580 from poettering/resolved-naptr
resolved: properly decode NAPTR RRs
2024-03-06 14:14:11 +00:00
Lennart Poettering
d49dc7bbe7 string-util: allow taking SIZE_MAX as size to shorten to
This is useful for two reasons:

1. it addresses a potential overflow in a graceful way

2. Gives callers the ability to just pass SIZE_MAX for a NOP

Prompted by: #31341
2024-03-06 13:24:15 +00:00
Mike Yuan
771bf2274a basic: remove spuriously doubled newline and leftover separator
Follow-up for 3fc72d5413
2024-03-06 03:29:12 +08:00
Lennart Poettering
c6342e35b0 escape: teach octescape() to work with NUL terminated strings 2024-03-05 15:46:31 +01:00
Matteo Croce
3fc72d5413 dynamically load compression libraries
Dynamically load liblz4, libzstd and liblzma with dlopen().
This helps to reduce the size of the initrd image when these libraries
are not really needed.
2024-03-05 12:37:21 +01:00
Matteo Croce
1c20c9f4fc move dlfcn-util into basic
I'm going to dlopen_many_sym_or_warn() in src/basic/compress.c, this
will introduce a circular dependency because libshared already depends
from libbasic.
To avoid this, move dlfcn-util.c from libshared to libbasic.
2024-03-05 12:33:44 +01:00
Mike Yuan
2560dcbfe6 stat-util: generalize is_* and verify_* handling 2024-03-04 19:53:51 +00:00
Mike Yuan
4f49512695 extract-word: modernize extract_many_words 2024-03-03 19:01:00 +08:00
Lennart Poettering
e28b70a527 hashmap: reorder fields to pack structure better
When building with ENABLE_DEBUG_HASHMAP we can pack the hashmap iterator
structure a bit better.

Fixes: #31558
2024-03-02 11:47:34 +09:00
Lennart Poettering
71cb203a6e importctl: draw a pretty progress bar while downloading
Everybody loves pretty terminal progress bar.
2024-03-01 22:25:42 +01:00
Lennart Poettering
4a5aa6842d fd-util: O_DIRECTORY is fine in fd_verify_safe_flags() too 2024-03-01 22:25:42 +01:00
Luca Boccassi
e72ae41b51 Merge pull request #31524 from poettering/secure-getenv-naming-fix
change naming order getenv_xyz_secure() → secure_getenv_xyz() to match glibc
2024-02-28 18:01:52 +00:00
Lennart Poettering
dbe253aa9d env-util: also rename getenv_uint64_secure() → secure_getenv_uint64()
As in the previous commit, let's not change the order of the words
compared to the underlying glibc API.
2024-02-28 15:38:00 +01:00
Lennart Poettering
efb9b3bab2 env-util: rename getenv_bool_secure() → secure_getenv_bool()
The glibc API is behind the wrapper is called "secure_getenv()", hence
our wrapper really should keep the order too, otherwise things are just
too confusing.
2024-02-28 15:38:00 +01:00
Sam Leonard
73a72e3a7b basic/terminal-util: accept ST or BEL to end escape sequence queries
Currently scan_background_color_response only accepts BEL (\x07) to end
a response, however some terminals (namely kitty in my case) will reply
with the string terminator (ST - https://en.wikipedia.org/wiki/ANSI_escape_code).

This commit changes the behaviour to now accept either ending.
2024-02-28 11:50:18 +00:00
Sam Leonard
9924d3c595 basic/terminal-util: add check for poll timeout in get_default_background_color
Currently the return value 0 is not checked for, this indicates a
timeout and should be handled to prevent doing a blocking read on a file
descriptor with no data ready.
2024-02-28 11:50:17 +00:00
Luca Boccassi
47c2a6e958 Merge pull request #31515 from keszybz/small-cleanups-after-review-of-stable-batch
Small cleanups after review of stable batch
2024-02-27 20:07:18 +00:00
Zbigniew Jędrzejewski-Szmek
2dc65c32b2 virt: wrap comment, add missing punctuation 2024-02-27 18:32:21 +01:00
Mike Yuan
31323f21bb meson: drop default-hierarchy= option, always use unified 2024-02-27 23:10:49 +08:00
Lennart Poettering
795ec90cda vmspawn: use our own ptyfwd code for the console of a VM
Let's make systemd-nspawn use our own ptyfwd logic to handle the TTY by
default.

This adds a new setting --console=, inspired by nspawn's setting of the
same name. If --console=interactive= is used, then we'll do the TTY
dance on our own via ptyfwd, and thus get tinting, our usual hotkey
handling and similar.

Since qemu's own console is useful too, let's keep it around via
--console=native.

FInally, replace the --qemu-gui switch by --console=gui.
2024-02-26 11:54:37 +01:00
Yu Watanabe
c7f46150bb in-addr-util: introduce in{4,6}_addr_is_multicast() 2024-02-25 11:43:37 +00:00
Luca Boccassi
461c85838e Merge pull request #31465 from xypron/detect-virt
Detect virtualization on RISC-V
2024-02-23 20:50:51 +00:00
Lennart Poettering
db7136ec73 signal-util: imply sentinel -1 in sigprocmask_many() + sigset_add_many() args list 2024-02-23 09:35:12 -08:00
Lennart Poettering
f58411a22f signal-util: use RET_NERRNO() + RET_GATHER() more 2024-02-23 09:35:12 -08:00
Heinrich Schuchardt
5041e771a8 detect-virt: allow detection via SMBIOS on RISC-V
SMBIOS support in QEMU for RISC-V is merged upstream.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-23 17:29:20 +01:00
Heinrich Schuchardt
819874adc0 detect-virt: allow detection via device-tree on RISC-V
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-23 17:25:59 +01:00
Luca Boccassi
e0699e067e Merge pull request #31411 from poettering/build-path
userdbd,homed,importd,sysupdate,pid1: make it easier to run daemons that have callouts from build dir
2024-02-23 11:57:42 +00:00
Yu Watanabe
0584e2aa7c Merge pull request #31425 from YHNdnzj/fd-util-followup
fd-util: introduce fd_verify_safe_flags
2024-02-22 08:29:11 +09:00
Yu Watanabe
c6939752c1 basic/linux: update kernel headers from v6.8-rc5 2024-02-22 06:22:22 +08:00
Mike Yuan
14f38d179d fd-util: introduce fd_verify_safe_flags
As per https://github.com/systemd/systemd/pull/31419#discussion_r1496921074
2024-02-22 06:17:54 +08:00
Lennart Poettering
234bdd9c99 process-util: use proc_mounted() check at one more place 2024-02-21 09:25:46 +01:00
Lennart Poettering
2287565d46 pid1: port executor binary pinning to new build path logic 2024-02-21 09:25:46 +01:00
Lennart Poettering
950ca1788e build-path: allow overriding of all callout binary paths via an env var 2024-02-21 09:25:46 +01:00
Lennart Poettering
91d149cfb4 basic: add "build path" logic
We have a number of components these days that are split into multiple
binaries, i.e. a primary one, and a worker callout usually. These
binaries are closely related, they typically speak a protocol that is
internal, and not safe to mix and match. Examples for this:

- homed and its worker binary homework
- userdbd and its worker binary userwork
- import and the various pull/import/export handlers
- sysupdate the same
- the service manager and the executor binary

Running any of these daemons directly from the meson build tree is
messy, since the implementations will typically invoke the installed
callout binaries, not the ones from the build tree. This is very
annoying, and not obvious at first.

Now, we could always invoke relevant binaries from $(dirname
/proc/self/exe) first, before using the OS installed ones. But that's
typically not what is desired, because this means in the installed case
(i.e. the usual one) we'll look for these callout binaries at a place
they typically will not be found (because these callouts generally are
located in libexecdir, not bindir when installed).

Hence, let's try to do things a bit smarter, and follow what build
systems such as meson have already been doing to make sure dynamic
library discovery works correctly when binaries are run from a build
directory: let's start looking at rpath/runpath in the main binary that
is executed: if there's an rpath/runpath set, then we'll look for the
callout binaries next to the main binary, otherwise we won't. This
should generally be the right thing to do as meson strips the rpath
during installation, and thus we'll look for the callouts in the build
dir if in build dir mode, and in the OS otherwise.
2024-02-21 09:25:46 +01:00
Adrian Vovk
e4d0606c2b fd-util: Add helpers to check if FD flags are safe
Adds a SAFE_FD_FLAGS define to list out all the safe FD flags, and also
an UNSAFE_FD_FLAGS() macro to strip out the safe flags and leave only
the unsafe flags. This can be used to quickly check if any unsafe flags
are set and print them for diagnostic purposes
2024-02-20 15:01:37 -05:00
Adrian Vovk
9e3db91f2f missing_fcntl: Fix RAW_O_LARGEFILE
This value is actually arch-specific, so this commit defines it for all
the arches that set it to some custom value

Fixes https://github.com/systemd/systemd/issues/31417
2024-02-20 15:01:36 -05:00
Adrian Vovk
85f660d46b fd-util: Expose helper to pack fds into 3,4,5,...
This is useful for situations where an array of FDs is to be passed into
a child process (i.e. by passing it through safe_fork). This function
can be called in the child (before calling exec) to pack the FDs to all
be next to each-other starting from SD_LISTEN_FDS_START (i.e. 3)
2024-02-19 11:18:11 +00:00
Luca Boccassi
5ea0da03d4 Merge pull request #31311 from yuwata/journal-user-corruption
journal: fix user journal corruption on rotation
2024-02-16 12:07:50 +00:00
Daan De Meyer
55c2350e85 Merge pull request #31320 from DaanDeMeyer/versioning
meson: Start adding devel and rc suffixes to the project version
2024-02-15 20:15:04 +01:00
Yu Watanabe
a6d0cf939c stat-util: introduce {stat,fd}_verify_linked() 2024-02-16 03:48:18 +09:00
Yu Watanabe
dd7fa015a6 stat-util: rebreak comment 2024-02-16 03:48:18 +09:00
Yu Watanabe
3900255ac1 Merge pull request #31331 from yuwata/xopenat
tree-wide: several cleanups related to xopenat()
2024-02-16 01:32:21 +09:00
Yu Watanabe
e40b11be04 fs-util: rename xopenat() -> xopanat_full() 2024-02-16 00:25:37 +09:00
Yu Watanabe
59a4e17249 chattr-util: fix error code
Follow-up for cf91b9155c.
2024-02-16 00:25:37 +09:00
Yu Watanabe
bec1383623 chase: do not wrap xopenat() with RET_NERRNO()
Follow-up for 47f0e1b5e0.
2024-02-16 00:25:37 +09:00
Yu Watanabe
e4c094c055 fs-util: readlinkat() supports an empty string
From readlinkat(2):
Since Linux 2.6.39, pathname can be an empty string, in which case the
call operates on the symbolic link referred to by dirfd (which should
have been obtained using open(2) with the O_PATH and O_NOFOLLOW flags).
2024-02-16 00:25:37 +09:00
Mike Yuan
9128fd553c env-util: minor modernization 2024-02-15 19:23:52 +08:00
Yu Watanabe
4dcfdd210c log: reorder arguments of internal macro
To make the order matches with log_internal().

No functional change. Hopefully silence coverity issues like
CID#1534478, CID#1534479, CID#1534480, CID#1534482.
2024-02-15 18:16:33 +09:00