Commit Graph

5231 Commits

Author SHA1 Message Date
Yu Watanabe
83f3d73da8 compress: introduce compression_supported() helper function 2023-04-04 18:32:12 +09:00
Yu Watanabe
21eac258f8 chase: fix error handling
Fixes a bug introduced by 63bfd52f48.
2023-04-04 09:20:09 +02:00
OMOJOLA JOSHUA DAMILOLA
de2820606d src: changed usage of basename() to path_extract_filename().
TODO.
2023-04-04 00:10:22 +01:00
Zbigniew Jędrzejewski-Szmek
2657d5bddc basic/fs-util: typo fix 2023-04-03 15:28:53 +02:00
Zbigniew Jędrzejewski-Szmek
2c71aa77a5 basic/mkdir: simplify error handling
If we created the dir successfully, we let chmod_and_chown_at() do its thing
and shouldn't go into the part where we check if the existing directory has the
right permissions and ownership and possibly adjust them. The code was doing
that, by relying on the fact that chmod_and_chown_at() does not return -EEXIST.
That's probably true, but seems unnecessarilly complicated.

Follow-up for c1b1492a94.
2023-04-03 15:28:00 +02:00
Daan De Meyer
6eec59f9cc stat-util: Add xstatfsat() 2023-04-01 14:25:30 +02:00
Luca Boccassi
ed2a4e8d78 Merge pull request #27075 from mrc0mmand/test-tweaks
test: a couple of coverage-related test tweaks
2023-03-31 01:18:15 +01:00
Frantisek Sumsal
4388541237 coverage: add a wrapper for execveat()
gcov provides wrappers for the exec*() calls but there's none for execveat(),
which means we lose all coverage prior to the call. To mitigate this, let's
add a simple execveat() wrapper in gcov's style[0], which dumps and resets
the coverage data when needed.

This applies only when we're built with -Dfexecve=true.

[0] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/libgcov-interface.c;h=b2ee930864183b78c8826255183ca86e15e21ded;hb=HEAD
2023-03-30 20:42:47 +02:00
Xiaotian Wu
a4a2077df5 basic: update the Arch tuples for LoongArch
After this commit[1], LoongArch now uses these Multiarch specs:

- Double float: loongarch64-linux-gnu
- Single float: loongarch64-linux-gnuf32
- Soft float: loongarch64-linux-gnusf

You can visit here[2] to view the full documentation.

[1]: 55dbaadaaa
[2]: https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html
2023-03-30 15:44:03 +02:00
Daan De Meyer
5ccf06074a Merge pull request #27064 from DaanDeMeyer/chase-fixes
Chase fixes
2023-03-30 11:44:33 +02:00
Daan De Meyer
ee6fea2b7f Merge pull request #27063 from yuwata/chase-graceful
chase: gracefully drop CHASE_AT_RESOLVE_IN_ROOT when AT_FDCWD is specified
2023-03-30 11:44:17 +02:00
Daan De Meyer
1b07fd3c22 Merge pull request #27041 from poettering/fdstore-dump
add ability to show contents of service fdstore + teach systemd-notify passing fds into the fdstore
2023-03-30 09:32:13 +02:00
Yu Watanabe
8bf26bfe26 chase: add CHASE_AT_RESOLVE_IN_ROOT only when it is necessary 2023-03-30 16:29:45 +09:00
Yu Watanabe
e115daa6a8 chase: drop CHASE_AT_RESOLVE_IN_ROOT when AT_FDCWD or root dir fd is specified
If we get AT_FDCWD or root dir fd, we always resolve symlinks relative to the host's root.
Hence, the flag is meaningless.
2023-03-30 16:29:37 +09:00
Daan De Meyer
708e88704b chase: Simplify chase_and_open() and chase_and_openat()
xopenat() now calls fd_reopen() if an empty path is specified, so
let's make use of that to simplify the chase open helpers.
2023-03-30 09:04:14 +02:00
Daan De Meyer
fedceeba2e fs-util: Strip O_NOFOLLOW in xopenat() when calling fd_reopen()
We definitely want to follow symlinks when calling fd_reopen() so
let's strip O_NOFOLLOW when we call it from xopenat().
2023-03-30 09:04:14 +02:00
Daan De Meyer
16859751ca chase: Fix error code check 2023-03-30 09:04:14 +02:00
Daan De Meyer
11659e4830 chase: Fix formatting 2023-03-30 09:04:14 +02:00
Daan De Meyer
47ef19d6b9 Merge pull request #27062 from yuwata/chase-trivial
chase: trivial cleanups
2023-03-30 08:45:38 +02:00
Yu Watanabe
6d5d3e207b chase: fix indentation 2023-03-30 14:52:13 +09:00
Yu Watanabe
52576a7503 chase: fix comment 2023-03-30 14:52:13 +09:00
Yu Watanabe
46693a7925 fd-util: make fd_get_path() support AT_FDCWD 2023-03-30 12:03:33 +09:00
Mike Yuan
c884484956 Merge pull request #27053 from DaanDeMeyer/firstboot-followups
Firstboot followups
2023-03-30 04:22:16 +08:00
Lennart Poettering
2ea24611b9 pid1: add DumpFileDescriptorStore() bus call that returns fdstore content info 2023-03-29 18:53:20 +02:00
Lennart Poettering
b2b84f4b23 fd-util: add helper for converting O_RDONLY/WRONLY/RDWR to strings 2023-03-29 18:27:05 +02:00
Lennart Poettering
d80e2a1ed3 devnum-util: add new devnum_is_zero() helper 2023-03-29 18:27:05 +02:00
Lennart Poettering
d83ce13636 stat-util: add inode_type_to_string() helper for showing mode_t inode type as string 2023-03-29 18:27:04 +02:00
Daan De Meyer
fe58566282 user-util: Rename ETC_PASSWD_LOCK_NAME to ETC_PASSWD_LOCK_FILENAME 2023-03-29 17:52:35 +02:00
Lennart Poettering
a1d315730f pid1: introduce new SERVICE_{DEAD|FAILED}_BEFORE_AUTO_RESTART service substates
When a service deactivates and is then automatically restarted via
Restart= we currently quickly transition through
SERVICE_DEAD/SERVICE_FAILED. Which is weird given it's not the
normal ("permanent") dead/failed state, but a transitory one we
immediately leave from again. We do this so that software that looks for
failures/successes can take notice, even if we restart as a consequence
of the deactivation.

Let's clean this up a bit: let's introduce two new states:
SERVICE_DEAD_BEFORE_AUTO_RESTART and SERVICE_FAILED_BEFORE_AUTO_RESTART
that are used for the transitory states. Both the SERVICE_DEAD and
SERVICE_DEAD_BEFORE_AUTO_RESTART will map to the high-level
UNIT_INACTIVE state though. (and similar for the respective failed
states). This means the high-level state machine won't change by this,
only the low-level one.

This clearly seperates the substates, which makes the state engine
cleaner, and allows clients to follow precisely whether we are in a
transitory dead/failed state, or a permanent one, by looking at the
service substate. Moreover it allows us to remove the 'n_keep_fd_store'
which so far we used to ensure the fdstore was not released during this
transitory dead/failed state but only during the permanent one. Since we
can now distinguish these states properly we can just use that.

This has been bugging me for a while. Let's clean this up.

Note that the unit restart logic is already nicely covered in the
testsiute, hence this adds no new tests for that.

And yes, this could be considered a compat break, but sofar we took the
liberty to make changes to the low-level state machine (i.e. SERVICE_xyz
states, sometimes called "substates") without considering this a bad
breakage – the high-level state machine (i.e.  UNIT_xyz states) should
be considered API that cannot be changed.
2023-03-29 17:22:07 +02:00
Daan De Meyer
8e3eb949a5 user-util: Add ETC_PASSWD_LOCK_NAME 2023-03-29 09:25:38 +02:00
Daan De Meyer
ee2975a9d9 log: Add LOG_SET_PREFIX() macro
LOG_SET_PREFIX() sets a logging prefix for the current block. The
prefix is prepended to every logging message in the block, followed
by ": ". If a logging prefix is already configured, it is overridden
for the duration of the block, after which it is restored.

A use case for this macro is when we're operating on an image or
directory (using --root or --image). We can use LOG_SET_PREFIX() to
prefix all logging messages with the directory or image that we're
operating on.
2023-03-29 13:00:33 +09:00
Yu Watanabe
0290243acf Merge pull request #27040 from keszybz/empty-path-skip-cleanup
Restore silent skipping of missing rules files by udev
2023-03-29 10:18:06 +09:00
Luca Boccassi
a4d1d1f63d Merge pull request #26941 from bluca/portable_version
portable: introduce SYSEXT_ fields to identify sysexts, and include more metadata in log messages via LogExtraFields=
2023-03-28 17:49:52 +01:00
Zbigniew Jędrzejewski-Szmek
3e2d735328 basic/stat-util: remove unused null_or_empty_fd() 2023-03-28 18:44:40 +02:00
Yu Watanabe
201423d801 process-util: introduce get_process_cmdline_strv()
The reason why get_process_cmdline() is so complicated is that we
need to escape and quote arguments for building a single result
string.

That's necessary when we want to log or print the command line.
However, when we want to parse the command line, it is not necessary
that the result is a single string, but can be strv.

This will be used when we parse the command line.
2023-03-28 17:09:15 +02:00
Luca Boccassi
2ed74695b3 strv: add helper to find value in key/value pairs from list of keys 2023-03-28 10:36:01 +01:00
Luca Boccassi
6255bbe262 env: add load_env_file_pairs_fd() 2023-03-28 10:36:01 +01:00
Yu Watanabe
409759634e env-util: introduce strv_env_assign_many() 2023-03-28 02:51:54 +09:00
Lennart Poettering
fdb583e6a9 fd-util: cover some corner cases with fd_reopen() on symlinks
The /proc/self/fd/ interface cannot be used to follow symlinks pinned
via O_PATH. Add a comment + test for that. Moreover, using fd_reopen()
with O_NOFOLLOW cannot work. Add an explicit check and test for that, to
make behaviour uniform.
2023-03-27 12:28:48 +02:00
Daan De Meyer
4e24df3cc3 Merge pull request #26961 from DaanDeMeyer/chase-and-pin
chase-symlinks: Add chase_and_open_parent() + at() variant
2023-03-27 10:41:08 +02:00
Daan De Meyer
670afc182a chase-symlinks: Add chase_and_open_parent() + at() variant
Helper to chase a path, pin its parent directory and return the filename
of the resolved path in its parent directory.
2023-03-26 20:31:10 +02:00
Lennart Poettering
50ed5cbf5f tree-wide: port various places to find_line_startswith() 2023-03-24 18:30:20 +01:00
Lennart Poettering
7b82d95f8d string-util: add new helper for finding line starting with specific string in a text buffer
We have implemented this manually a couple of times, and always wrong.
Hence let's implement this correctly for once and use everywhere.
2023-03-24 18:30:20 +01:00
Daan De Meyer
e5f2490200 chase-symlinks: Allow optional path with CHASE_EXTRACT_FILENAME
This allows helpers to set it unconditionally even if the caller
is not interested in the path.
2023-03-24 13:53:45 +01:00
Daan De Meyer
f461a28da7 chase-symlinks: Rename chase_symlinks() to chase()
Chasing symlinks is a core function that's used in a lot of places
so it deservers a less verbose names so let's rename it to chase()
and chaseat().

We also slightly change the pattern used for the chaseat() helpers
so we get chase_and_openat() and similar.
2023-03-24 13:43:51 +01:00
Daan De Meyer
12962485e4 Merge pull request #26958 from yuwata/nulstr-optionally-drop-trailing-nulstr
nulstr: make strv_parse_nulstr() optionally drop trailing NULs
2023-03-24 11:33:58 +01:00
Yu Watanabe
4669be626d process-util: drop trailing NUls before parsing the nulstr
No functional changes, just refactoring.
2023-03-24 15:21:59 +09:00
Yu Watanabe
a4f66f90ad nulstr-util: introduce strv_parse_nulstr_full() that optionally drop trailing empty strings 2023-03-24 15:21:59 +09:00
Yu Watanabe
2a6911bb1f proc-cmdline: make proc_cmdline_parse_given() static
It is used only in proc-cmdline.c and its test. And the test can be
covered by proc_cmdline_parse().
2023-03-24 15:20:05 +09:00
Yu Watanabe
1479799c4d proc-cmdline: use proc_cmdline_key_string() when we search for key 2023-03-24 15:20:05 +09:00