Commit Graph

5245 Commits

Author SHA1 Message Date
Yu Watanabe
db0096f2ad chase: drop unnecessary conditions for buffer 2023-04-10 08:17:07 +09:00
Yu Watanabe
46b457e54b fileio: introduce read_one_line_file_at() 2023-04-09 07:08:38 +02:00
Yu Watanabe
b1229544a0 conf-files: introduce _at() variants of conf_files_list() or friends 2023-04-08 05:09:48 +09:00
Yu Watanabe
1a39bddfbb conf-files: split out logic of copy and sort filenames from hashmap
No functional change, preparation for the next commit.
2023-04-08 05:08:51 +09:00
Yu Watanabe
273426750a conf-files: use path_compare_filename() 2023-04-08 05:08:51 +09:00
Yu Watanabe
6808e00463 path-util: introduce path_compare_filename() 2023-04-08 05:08:51 +09:00
Yu Watanabe
a5af5f80ca conf-files: drop redundant call of chase()
Previously, chase() was called twice in files_add() and path_strv_resolve_uniq().
2023-04-08 05:08:48 +09:00
Zbigniew Jędrzejewski-Szmek
ddd43f31e3 Merge pull request #26887 from yuwata/proc-cmdline-filter-arguments
proc-cmdline: filter PID1 arguments on container
2023-04-07 10:55:30 +02:00
Zbigniew Jędrzejewski-Szmek
1e094cb4ba Merge pull request #27126 from yuwata/journal-compress
sd-journal: allow to specify compression algorithm through env
2023-04-07 09:28:27 +02:00
maanyagoenka
b60e0f5777 os-util: add a new confext image type and the ability to parse their release files
Adds a new image type called IMAGE_CONFEXT which is similar to IMAGE_SYSEXT but works
for the /etc/ directory instead of /usr/ and /opt/. This commit also adds the ability to
parse the release file that is present with the confext image in /etc/confext-release.d/
directory.
2023-04-05 21:50:04 +00:00
Yu Watanabe
e212f42279 fd-util: introduce dir_fd_is_root_or_cwd() 2023-04-05 00:52:56 +09:00
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
6339d3e602 proc-cmdline: filter PID1 arguments when we are running in a container
Otherwise, PID1 arguments e.g. "--deserialize 16" may be parsed
unexpectedly by generators.

Fixes the issue reported at
https://github.com/systemd/systemd/issues/24452#issuecomment-1475004433.
2023-03-29 10:34:41 +09:00
Yu Watanabe
94e0130ab0 proc-cmdline: introduce proc_cmdline_strv()
When we are running in a container, we parse the command line of PID1 in
proc_cmdline_parse() or friends. Previously, first we merge the command
line nulstr as a single string, and then split by using
extract_first_word(). That's not only redundant, but also unsafe when
the command line argument contain a space.

This drops the redundant steps, hence we can safely parse arguments with
space.
2023-03-29 10:34:39 +09:00
Yu Watanabe
70806d4554 proc-cmdline: split commandline earlier in proc_cmdline_parse() and friend
No functional change, just preparation for later commits.
2023-03-29 10:33:01 +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