Commit Graph

6670 Commits

Author SHA1 Message Date
Mike Yuan
1ca89d32ae signal-util: make struct timespec const 2024-04-03 10:03:53 +08:00
Mike Yuan
65b584334d time-util: drop unneeded 'struct' 2024-04-03 10:03:53 +08:00
Daan De Meyer
cde08933a9 Fix assertion in socknameinfo_pretty() 2024-03-31 23:40:38 +01:00
Yu Watanabe
0966933b3d unit-def: append trailing comma for the last entry 2024-03-29 13:53:01 +09:00
Luca Boccassi
37543971af os-util: allow matching versioned image with extension-release file
Currently app_1.0.raw is refused if it contains extension-release.d/extension-release.app,
which stops one from using versioned images without using the force flag to disable
the check. Relax it so that only the actual name, and not the version, is compared, like
it already happens in other places.
2024-03-28 14:20:20 +00:00
Mike Yuan
f8c700791e string-util: modernize string_contains_word_strv a bit
Also correct the comment on flags.
2024-03-28 17:16:25 +08:00
Mike Yuan
981b033510 basic/string-table: remove unnecessary brackets 2024-03-25 23:10:52 +08:00
Friedrich Altheide
5e3c08d375 basic/virt: Fix virtualbox detection on proprietary system via board_vendor
Identify an virtualbox instance even if product_name, sys_vendor and bios_vendor reflect the
information of the real hardware, by checking if board_vendor == "Oracle Corporation"

This fixes #13429 again
The previous fix was removed in #21127
2024-03-24 18:02:42 +00:00
Zbigniew Jędrzejewski-Szmek
1934242b72 Drop unnecessary path_equal_ptr() wrapper
path_equal already works with NULL pointers.
2024-03-23 13:21:06 +01:00
Daan De Meyer
16f182e59a Merge pull request #31839 from DaanDeMeyer/log
log: Add per target log levels
2024-03-22 15:11:11 +01:00
Daan De Meyer
e8815abff6 log: Add per target log levels
For CI in mkosi, I want to configure systemd to log at debug level
to the journal, but not to the console. While we already have max
level settings for journald's forwarding settings, not every log line
goes to the journal, specifically during early boot and when units
are connected directly to the console (think systemd-firstboot), so
let's extend the log level options we already have to allow specifying
a comma separated list of values and lets allow prefixing values with
the log target they apply to to make this possible.
2024-03-22 12:46:32 +01:00
Yu Watanabe
431f2ffbea Merge pull request #31892 from YHNdnzj/machinectl-minor-cleanup
machinectl: minor modernization, use FOREACH_ARRAY
2024-03-22 08:10:39 +09:00
Mike Yuan
66d826026e cgroup-util: use path_find_first_component where appropriate
Prompted by 8922a728f7
2024-03-22 08:00:55 +09:00
Mike Yuan
51e0149173 nulstr-util: minor cleanup 2024-03-22 01:44:45 +08:00
Yu Watanabe
839dce5ecb Merge pull request #31862 from keszybz/add-strdup_to-helper
Add strdup_to() helper
2024-03-21 14:47:05 +09:00
Unique-Usman
c0cd99eee6 Follow up with the PR #31819 2024-03-20 15:48:05 +00:00
Luca Boccassi
c3a55dc469 Merge pull request #31844 from keszybz/missing-extra-checks
Add static asserts to verify that our missing_*.h headers defines are actually correct
2024-03-20 15:47:05 +00:00
Zbigniew Jędrzejewski-Szmek
196166dbb1 basic/unit-name: use strdup_to() in slice_build_parent_slice()
The handling of the buffer is not obvious, so add a comment.
2024-03-20 15:18:21 +01:00
Zbigniew Jędrzejewski-Szmek
4ab305fa3b basic/time-util: use strdup_to() and reformat a bit 2024-03-20 15:18:21 +01:00
Zbigniew Jędrzejewski-Szmek
6a705f1234 Replace strdup_or_null() by strdup_to()
I didn't know that this helper existed… It is very similar to strdup_to_full(),
but all callers can actually be replaced by strdup_to(), which has more fitting
semantics.
2024-03-20 15:18:21 +01:00
Zbigniew Jędrzejewski-Szmek
f174b294f6 basic/string-util: use strdup_to() in string_extract_line() 2024-03-20 15:18:21 +01:00
Zbigniew Jędrzejewski-Szmek
4eb3ec63b0 basic/socket-util: use strdup_to() in sockaddr_pretty()
The function was written to support ret==NULL, but the only caller always
passes ret, and sockaddr_pretty() also requires ret to be set, so that
half-implemented code wasn't very useful.
2024-03-20 15:18:21 +01:00
Zbigniew Jędrzejewski-Szmek
94b75cdb06 basic/fileio: use strdup_to_full() in read_stripped_line()
The return value of read_stripped_line() is changed. Before we'd return the
number of characters read, but that number was not meaningful after we called
strstrip(). So just return 0 if nothing was read (EOF), and 1 if something was
read (not EOF). All the callers were only checking for <0 or ==0.
2024-03-20 15:18:21 +01:00
Zbigniew Jędrzejewski-Szmek
4f77ddca59 various: also use strdup_to() in cases where we don't return immediately 2024-03-20 15:18:21 +01:00
Zbigniew Jędrzejewski-Szmek
418b936d47 various: use strdup_to() after getenv() 2024-03-20 15:18:21 +01:00
Zbigniew Jędrzejewski-Szmek
454318d3e8 various: use strdup_to() in various obvious cases
strdup_to() returns 0 on success and here we convert obvious blocks
which either return -ENOMEM or 0.
2024-03-20 15:13:44 +01:00
Zbigniew Jędrzejewski-Szmek
8922a728f7 basic/cgroup-util: use strdup_to() and strdup_to_full() as appropriate 2024-03-20 15:13:44 +01:00
Zbigniew Jędrzejewski-Szmek
892c5902ae src/basic: add yet another strdup helper
It's a bit ugly to have both strdup_to() and strdup_to_full(). I initially
started with one variant, but then in some functions we want the additional
info, while in many other places, having 1 instead of 0 causes the return
value of whole chains of functions to be changed. It *probably* wouldn't cause
any difference, but there is at least of bunch of tests that would need to be
updated, so in the end it seems to have the two variants.

The output param is first to match free_and_strdup() and other similar
functions.
2024-03-20 15:12:12 +01:00
Zbigniew Jędrzejewski-Szmek
0dee6f7a7b basic/missing_audit: add explanatory comment
It seems we need to check for the header file because it's not available in
some fuzzer builds.
2024-03-20 12:26:24 +01:00
Zbigniew Jędrzejewski-Szmek
aee547b97b basic/missing_*.h: indentation tweaks 2024-03-20 12:26:16 +01:00
Zbigniew Jędrzejewski-Szmek
4d6437d33c basic/missing_*.h: add asserts that the values are as expected
It's great that we provide fallback values, but if we got one of those wrong,
it could be a long time before anyone noticed. So let's add asserts that the
our internal defines actually match the official ones, when the latter are
available.

I did not add '#include "macro.h"' to missing_{audit,capability}, because
those are processed by an awk script that would need additional include
directories and could be confused by the additional lines. We don't include
those headers standalone anyway, so this is not necessary anyway.
2024-03-20 12:26:16 +01:00
Zbigniew Jędrzejewski-Szmek
7258971b13 basic/missing_ioprio: include the proper header file
IOPRIO_* is defined in linux/ioprio.h, so we were always using our fallback
definitions.

The header list in meson.build is sorted. I'm not sure why it wasn't.
2024-03-20 12:25:47 +01:00
Daan De Meyer
2e52b6c661 log: Make warning messages more consistent
Use our usual pattern of ", ignoring.".
2024-03-20 09:30:39 +01:00
Yu Watanabe
46325d9324 terminal-util: fix underlying with SYSTEMD_COLORS=no
Fixes #31857.
2024-03-19 22:21:56 +01:00
Abraham Samuel Adekunle
fcf38e2cb3 Add unittest file for basic:label 2024-03-18 11:04:42 +00:00
Yu Watanabe
d30d44883f stat-util: expose fd_is_read_only_fs()
Currently it is not used, but the fucntion is already quite generic and
useful.
2024-03-14 23:45:27 +08:00
Yu Watanabe
cdafb51ab4 Merge pull request #31754 from YHNdnzj/journal-fd-namespace
journal/cat: allow connecting output to specific journal namespace
2024-03-14 19:59:19 +09:00
Lennart Poettering
837eda0522 Merge pull request #31770 from poettering/linkat-replace
introduce linkat_replace() helper, and port various things over to it
2024-03-14 11:03:59 +01:00
Yu Watanabe
f03caa0d3e stat-util: fix typo
Follow-up for 7cff2b79f0.
2024-03-14 17:37:50 +09:00
Lennart Poettering
ccec206498 tmpfile-util: port link_tmpfile_at() over to linkat_replace() 2024-03-14 09:22:09 +01:00
Lennart Poettering
1f27e7b724 fs-util: add new helper linkat_replace() 2024-03-14 09:22:09 +01:00
Lennart Poettering
0b8e36f064 fs-util: move link_fd() from tmpfile-util.c into generic fs-util.c
It's a generically useful call, let's move it so that we can use it at
more places.
2024-03-14 09:17:46 +01:00
Lennart Poettering
dd92ba8a7a path-util: add helper that checks if a path definitely refers to a dir 2024-03-14 09:17:46 +01:00
Mike Yuan
baaca3db6a path-util: introduce skip_leading_slash and use it where appropriate 2024-03-14 14:25:52 +08:00
Lennart Poettering
95db87ffed Merge pull request #31731 from poettering/stat-is-set
stat-util: add explicit helpers for checking if stat/statx is initialized
2024-03-13 10:37:15 +01:00
Mike Yuan
a793133963 Merge pull request #31727 from YHNdnzj/homed-followup
data-fd-util: some cleanups
2024-03-13 13:10:34 +08:00
Lars Ellenberg
b8e25bff38 fs-utils: new wrapper fd_reopen_propagate_append_and_position()
We may want to propagate O_APPEND, or (try to) keep the current file position,
even if we use fd_reopen() to re-initialize (and "unshare") other file
description status.

For now, used only with --pty to keep/propagate O_APPEND (and/or) position
if set on stdin/stdout.

If we re-open stdout and "drop" the O_APPEND,
we get rather "unexpected" behavior,
for example with repeated "systemd-run --pty >> some-log".

If someone carefully pre-positioned the passed in original file descriptors,
we avoid surprises if we do not reset file postition to zero.

fcntl F_GETFL first, and propagate O_APPEND if present in the existing flags.

Then use lseek to propagate the file position.
2024-03-12 19:01:00 +01:00
Lennart Poettering
7cff2b79f0 stat-util: make sure inode_type_to_string() handles anonymous inodes in a reasonable way 2024-03-12 10:45:24 +01:00
Lennart Poettering
1c248d7fb7 stat-util: add explicit helpers for checking if stat/statx is initialized
This is a follow-up for 945a8210c7 and
makes the st_dev check generic, so that we can reuse it some other
places. It also incorporates the non-NULL check now, to be a
comprehensive one-stop solution.

The helper is static inline so that compilers can optimize the redundant
checks away in case it is combined with other checks.
2024-03-12 10:25:48 +01:00
Mike Yuan
faadc90c33 fileio,data-fd-util: use U64_* more 2024-03-12 16:42:48 +08:00