Commit Graph

654 Commits

Author SHA1 Message Date
Mike Yuan
7ce2c1bb5f mountpoint-util: rename fd_is_mount_point() to is_mount_point_at()
fd_* functions in our codebase usually mean fd-specific operations,
while this one actually takes openat()-style params. Rename it
accordingly hence.
2025-01-22 01:37:31 +01:00
Lennart Poettering
3d6f14d327 tmpfiles: move two commands to the right --help sections 2025-01-13 15:05:41 +01:00
Mike Yuan
1e4e557262 tree-wide: replace FLAGS_SET(..., 1 << v) with BIT_SET(..., v) 2024-12-28 15:08:00 +01:00
Zbigniew Jędrzejewski-Szmek
390bab5392 tmpfiles: reduce quoting in warning message
We printed:
systemd-tmpfiles[705]: /usr/lib/tmpfiles.d/20-systemd-shell-extra.conf:10: Unknown modifiers in command 'L$'.
systemd-tmpfiles[705]: /usr/lib/tmpfiles.d/systemd-network.conf:10: Unknown modifiers in command 'd$'.
systemd-tmpfiles[705]: /usr/lib/tmpfiles.d/systemd-network.conf:11: Unknown modifiers in command 'd$'.
...

There's a lot of additional characters here make the message harder to parse. We know
that the command is a word without any whitespace, so quoting isn't really necessary.

Change this to:
... unknown modifiers in command: L$
2024-12-13 16:23:05 +00:00
Daan De Meyer
b5dc805583 tmpfiles: Implement L? to only create symlinks if source exists
This allows a single tmpfiles snippet with lines to symlink directories
from /usr/share/factory to be shared across many different configurations
while making sure symlinks only get created if the source actually exists.
2024-11-04 19:04:21 +01:00
Zbigniew Jędrzejewski-Szmek
487d412327 tree-wise: use "lightweight" spelling
Both spellings were used, but the dictionary says that "lightweight"
is the standard spelling.
2024-10-18 18:43:40 +02:00
Mike Yuan
1f8eedba9d path-lookup: introduce user_search_dirs() (shall replace xdg_user_dirs())
xdg_user_dirs() doesn't seem well-organized currently.
In all other xdg_user_*() funcs we assume /etc/xdg/systemd
to be a symlink to /etc/systemd/, hence it is the odd one out.
Also, when the relevant envvar is unset, it only returns
the global search dirs.

sd_path_lookup() actually covers this nicely with SD_PATH_SEARCH_*,
where the combined search paths (from user home and system) are used.
Therefore, let's introduce a wrapper for that, and deprecate xdg_user_dirs()
(would be removed in later commits).
2024-10-06 19:42:39 +02:00
Mike Yuan
60cd6deb06 path-lookup: deduplicate xdg_user_*() with sd_path_lookup()
While at it, place ret param at last.
2024-10-06 19:27:12 +02:00
Mike Yuan
3f8999a76e fs-util: rename laccess to access_nofollow
In order to distinguish it from libc function naming.
2024-10-05 01:30:43 +02:00
Yu Watanabe
fc19ad8227 Merge pull request #34496 from YHNdnzj/tmpfiles-neg-errno
tmpfiles: ERRNO_IS_NOINFO -> _IS_NEG_, correct negative errno checks
2024-09-20 08:54:34 +09:00
Mike Yuan
eda6223942 basic/memory-util: introduce mempcpy_typesafe 2024-09-20 08:29:35 +09:00
Mike Yuan
755877f20a tmpfiles: ERRNO_IS_NOINFO -> _IS_NEG_, correct negative errno checks 2024-09-20 00:00:01 +02:00
Mike Yuan
6e1c603969 tmpfiles: use RET_GATHER more 2024-09-20 00:00:01 +02:00
Lennart Poettering
db15657dfb tmpfiles: introduce an explicit line flag $ for enabling purge logic for a line
Let's make the risk of accidental misuse, and mark lines that shall be
covered by --purge with an explicit new flag "$".

See: #33349
2024-09-15 19:43:09 +02:00
Zbigniew Jędrzejewski-Szmek
732ed8a84e meson: rename libbasic to libbasic_static
Our variables for internal libraries are named 'libfoo' for the shared lib
variant, and 'libfoo_static' for the static lib variant. The only exception was
libbasic, because we didn't have a shared variant for it. But let's rename it
for consitency. This makes the build config easier to understand.
2024-07-03 17:25:26 +02:00
Matthias Lisin
282bda46f1 tmpfiles: use common macro for a set of specifiers
This adds %q, %A and %M specifiers to tmpfiles:
- %A and %M were previously added to tmpfiles.d man page, but not to specifier_table
- %q is added via COMMON_SYSTEM_SPECIFIERS
2024-06-26 04:18:14 +02:00
Lennart Poettering
d7d41a6a76 tmpfiles: mention that --create also adjusts files/directories in --help text 2024-06-18 14:45:59 +01:00
Lennart Poettering
6718998d1e tmpfiles: suffix --replace= properly with = in comment 2024-06-18 14:45:59 +01:00
Lennart Poettering
2a37663036 tmpfiles: make --tldr help text symmetric to --cat-config 2024-06-18 14:45:59 +01:00
Lennart Poettering
4f25330d87 tmpfiles: improve debug logging around O_NOATIME fallback 2024-06-18 14:45:59 +01:00
Lennart Poettering
6f77039e97 tmpfiles: remove pointless empty line 2024-06-18 14:45:59 +01:00
Lennart Poettering
69d76823ce tmpfiles: move --purge to command section in --help text where it belongs
Also, make contrast between --remove and --purge clearer: one deletes
files marked for deletion, the other deletes files marked for creation.
2024-06-18 14:45:59 +01:00
Lennart Poettering
41064a3c97 tmpfiles: insist on at least one configuration file being specified on --purge
Also, extend the man page explanation substantially, matching more
closely what --create says.

Fixes: #33349
2024-06-18 14:45:59 +01:00
Lennart Poettering
edeceb80a9 tmpfiles: honour --dry-run when removing directories 2024-06-18 10:15:24 +02:00
Lennart Poettering
eaa3adbe69 tmpfiles: sort needs_purge line list in same order as enum defines them 2024-06-18 10:15:24 +02:00
Christian Göttsche
a424e4af6d tmpfiles: improve warning message and use O_NOCTTY
Mention in the warning message for a failed open on a to be removed file
why systemd-tmpfiles tried to open it.

Also open the file with the O_NOCTTY flag, since it should never become
the controlling terminal.
2024-05-28 21:58:30 +02:00
Mike Yuan
c2c162a636 tmpfiles: use RET_GATHER more, add missing assertions
Note that item_do() now aborts on OOM, since it's
pretty pointless to iterate further if memory allocation
doesn't work.
2024-05-10 18:50:05 +08:00
Mike Yuan
d8f5a31022 tmpfiles: don't compare errno with negative value
Follow-up for 677430b3c7
2024-05-10 18:50:05 +08:00
Mike Yuan
570c940d42 tmpfiles: clean up hardlinks_vulnerable a bit
dangerous_hardlinks() -> hardlinks_protected(),
and the meaning of the function is now in line
with fs.protected_hardlinks value.

Plus, We ship 50-default.conf where the sysctl
is enabled. Mention it in the comment.
2024-05-10 18:50:05 +08:00
Daan De Meyer
677430b3c7 tmpfiles: Don't fail if file does not exist in item_do()
If the file was removed by some other program, we should just go
to the next one without failing. item_do() is only used for recursive
globs instead of fixed paths so skipping on missing files makes sense
(unlike if the path was fixed where we should probably fail).

Fixes #32691 (hopefully)
2024-05-08 12:01:37 +02:00
Luca Boccassi
8707c9b244 gcrypt: dlopenify for libsystemd
gcrypt is used only for journal sealing operations in libsystemd, so it
can be made into a dlopen dependency that is used only on demand. This
allows to reduce the footprint of libsystemd in the most common cases.

Keep systemd-pull and systemd-resolved with normal linking, as they are
executables, and usually built with OpenSSL support anyway.
2024-04-03 11:50:25 +01: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
Mike Yuan
29a438e764 tmpfiles: do 'X' bit check in an ACL-aware manner
Follow-up for 26d98cdd78

I.e. stat() cannot be used here.

Also, before this commit, the 'X' is only applied if
the owner has execute bit set. Now it takes group and
other into consideration too. setfacl(1) also has
the same behavior.
2024-03-07 03:18:46 +08:00
Mike Yuan
83a5db202d tmpfiles: remove one more use of goto and modernization 2024-03-07 03:18:46 +08:00
Antonio Alvarez Feijoo
43aca0d99e extract-word: update remaining calls to extract_many_words
Follow-up to 4f49512695
2024-03-05 12:21:42 +00:00
Lennart Poettering
f4a63ce25f dissect-image: add flag for explicitly enabling userspace verity signature checking
let's make userspace verity signature checking optional. This adds a
dissection flag to enable the logic and patches through all our users to
enable it by default, thus effectively not changing anything from the
status quo ante. However, know we have a knob to turn this off in
certain scenarios.
2024-02-28 16:17:40 +01: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
Yu Watanabe
e40b11be04 fs-util: rename xopenat() -> xopanat_full() 2024-02-16 00:25:37 +09:00
Zbigniew Jędrzejewski-Szmek
983dbcefe8 systemd-tmpfiles: use statx_mount_same
It was pointed out in review that the preexisting code should be updated
(https://github.com/systemd/systemd/pull/30380#discussion_r1426899180).
2024-02-12 13:34:25 +01:00
Zbigniew Jędrzejewski-Szmek
9e90d4f42e tmpfiles: implement --dry-run
The idea is simple: skip the final operation that creates or removes things
or changes the attributes, but otherwise go through the rest of the code.
This results in quite a lot of fairly repetitive conditions in the low-level
code. Another approach would be to print earlier, at a higher level, but then
we'd have less precise information about what is about to happen.
2024-02-12 13:33:30 +01:00
Zbigniew Jędrzejewski-Szmek
117aa0140f tmpfiles: simplify how a helper function is called
No functional change.
2024-02-09 17:57:42 +01:00
Zbigniew Jędrzejewski-Szmek
b1935cc943 tmpfiles: use dir_cleanup() for R and D
... i.e. apply nested config (exclusions and such) when executing R and D.

This fixes a long-standing RFE. The existing logic seems to have been an
accident of implementation. After all, if somebody specifies a config with
'R /foo; x /tmp/bar', then probably the goal is to remove stuff from under /foo,
but keep /tmp/bar. If they just wanted to nuke everything, then would not specify
the second item.

This also makes R and D use O_NOATIME, i.e. the access times of the directories
that are accessed will not be changed by the cleanup.

Obviously, we'll have to add this to NEWS and such.
Looking at the whole tmpfiles.d config in Fedora, this change has no effect.

The test cases are adjusted as appropriate. I also added another test case for
'R'/'D' with a file, just to test this code path more.

Replaces #20641.
Fixes #1633.
2024-02-09 17:57:42 +01:00
Zbigniew Jędrzejewski-Szmek
7eeda1da90 tmpfiles: split out helper to open a directory
In preparation for future commits.
2024-02-09 17:57:41 +01:00
Zbigniew Jędrzejewski-Szmek
db6873bfeb tmpfiles: drop unnecessary assignment 2024-02-09 17:57:41 +01:00
Zbigniew Jędrzejewski-Szmek
9c8a0ca69e tmpfiles: split out verbs in help
One of the three must always be specified, but they buried in a long list of
options in the output of --help. Make them more visible to draw the eye.

Also, drop "marked" from the description. It's supposed to mean "configured",
but it's a strange way to say that, and also it's generally obvious that the
program does what its configuration tells it to, and it's not going to remove
all files found on the system.
2024-02-09 17:57:41 +01:00
Zbigniew Jędrzejewski-Szmek
f7862b2a00 tree-wide: use normal spelling of "reopen"
It's a commonly used verb meaning "to open again".
2024-02-09 17:57:41 +01:00
Zbigniew Jędrzejewski-Szmek
ad36bb9fbb tmpfiles: break long log invocations and comments 2024-02-09 17:57:41 +01:00
Zbigniew Jędrzejewski-Szmek
e5876c29ad tmpfiles: inline variable declarations, use FOREACH_ARRAY and RET_GATHER 2024-02-09 17:57:41 +01:00
Zbigniew Jędrzejewski-Szmek
f6a1346e4e tmpfiles: split out helper to open and read a "config file"
No functional change.

Note that this function will be modified in subsequent commits, and the API
will change.
2024-02-09 17:57:41 +01:00