Commit Graph

6670 Commits

Author SHA1 Message Date
Mike Yuan
8b8edb512a env-util: remove unneeded DISABLE_WARNING_FORMAT_NONLITERAL
_printf_ is used, so this shouldn't emit a warning
in the first place.
2024-03-12 15:41:51 +08:00
Mike Yuan
18eebde33a Merge pull request #31713 from YHNdnzj/pidref-equal
pidref: use fd_inode_same to compare pidfds
2024-03-12 14:15:36 +08:00
Yu Watanabe
3ecd6fa98b time-util: expose map_clock_usec_internal() as map_clock_usec_raw()
This will be used later.
2024-03-12 01:57:17 +09:00
Mike Yuan
2f41f10bcd pidref: use fd_inode_same to compare pidfds 2024-03-11 22:57:50 +08:00
Mike Yuan
945a8210c7 stat-util: struct stat could be initialized with (st_mode & S_IFMT == 0)
For anonymous inodes, the result would be 0, but
the struct stat is initialized obviously.
So let's switch to st_dev for the check, which
is guaranteed to be non-zero.

Also this is completely unnecessary for statx(),
since we check stx_mask first and that on its own
denotes that the struct is initialized.
2024-03-11 22:57:50 +08:00
Mike Yuan
0cdb8df620 stat-util: introduce fd_inode_same 2024-03-11 22:53:08 +08:00
Lennart Poettering
9f65355b85 fd-util: beef up fd_verify_safe_flags() features
Let's make fd_verify_safe_flags() even more useful:

1. let's return the cleaned up flags (i.e. just the access mode) after
   validation, hiding all the noise, such as O_NOFOLLOW, O_LARGEFILE and
   similar.

2. let's add a "full" version of the call that allows passing additional
   flags that are OK to be set.
2024-03-11 14:49:51 +01:00
cpackham-atlnz
ed01b92e1c basic: add PIDFS magic (#31709)
Kernel commit cb12fd8e0dabb9a1c8aef55a6a41e2c255fcdf4b added pidfs.
Update filesystems-gperf.gperf and missing_magic.h accordingly.

This fixes the following error building against a bleeding edge kernel.
```
../src/basic/meson.build:234:8: ERROR: Problem encountered: Unknown filesystems defined in kernel headers:

Filesystem found in kernel header but not in filesystems-gperf.gperf: PID_FS_MAGIC
```
2024-03-11 11:55:36 +00:00
Thomas Blume
fc5c6eccb4 units: make templates for quotaon and systemd-quotacheck service 2024-03-09 19:32:09 +00:00
Zbigniew Jędrzejewski-Szmek
ec596fe34e Merge pull request #30480 from keszybz/kernel-install-more-paths
Read kernel-install config from /run/kernel too
2024-03-08 08:25:07 +01:00
Zbigniew Jędrzejewski-Szmek
9bc7493098 strv: add helper to extend strv from both sides
Also, use the more correct type of 'const char* const*' for the input strv.
This requires adding the cast in a few places, but also allows to remove some
casts in others.
2024-03-07 18:49:44 +01:00
Zbigniew Jędrzejewski-Szmek
76d75d8b7b constants: drop duplicated CONF_PATHS defines
Follow-up for b0d3095fd6.
2024-03-07 18:47:50 +01:00
Mike Yuan
5ba6321d86 bus-unit-util: define FREEZE_BUS_CALL_TIMEOUT locally
Follow-up for f274f8bf25

We define *_SLOW_BUS_CALL_TIMEOUT in each component's
own file too. This one is no different and doesn't need
to be in constants.h IMO.
2024-03-08 01:09:01 +08:00
Luca Boccassi
5e418fe32a Merge pull request #31590 from YHNdnzj/install-cleanup
shared/install: several cleanups
2024-03-07 11:28:04 +00:00
Luca Boccassi
60cf40599a escape: fix operator precedence in overflow check
CID#1535100

Follow-up for c6342e35b0
2024-03-07 00:46:21 +00:00
Mike Yuan
7dfc71399d path-lookup: rename lookup_paths_free -> _done
This is stack-allocated, so update to match our usual rules.
2024-03-07 02:01:57 +08: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
Zbigniew Jędrzejewski-Szmek
8f43182847 various: use modern strv helpers
If we're building a strv, let's just use strv_new() with the CONF_PATHS macro,
which gives as an exploded string set.
2024-02-28 11:10:34 +01: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