Commit Graph

667 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
1ae9b0cfa8 basic/glyph-util: rename "special glyph" to just "glyph"
Admittedly, some of our glyphs _are_ special, e.g. "O=" for SPECIAL_GLYPH_TOUCH ;)
But we don't need this in the name. The very long names make some invocations
very wordy, e.g. special_glyph(SPECIAL_GLYPH_SLIGHTLY_UNHAPPY_SMILEY).
Also, I want to add GLYPH_SPACE, which is not special at all.
2025-03-15 14:40:39 +01:00
Yu Watanabe
b8790a875e tmpfiles: ignore ENOENT when file is removed during setting parmission and friends
After a file matches with a glob pattern, the file may be removed or
renamed before opening it. Let's ignore the error in such case.

Fixes #30938.
2025-03-11 18:52:28 +09:00
Yu Watanabe
5c9feb2d6e tree-wide: drop unnecessary break in default branch 2025-03-06 11:42:20 +01:00
Yu Watanabe
ec32732043 basic: introduce our own sys/mount.h implementation
To resolve conflict with sys/mount.h and linux/mount.h or linux/fs.h.

The conflict between sys/mount.h and linux/mount.h is resolved in
glibc-2.37 (774058d72942249f71d74e7f2b639f77184160a6), but our baseline
is still glibc-2.31. Also, even with the version or newer, still
sys/mount.h conflicts with linux/fs.h, which is included by
linux/btrfs.h.

This introduces our own implementation of sys/mount.h, that can be
simultaneously included with linux/mount.h and linux/fs.h. This also
imports linux/fs.h, linux/mount.h, and several other dependent headers.
The introduced sys/mount.h header itself may not be enough simple, but
by using the header, we can drop most of workarounds in other source files.
2025-03-04 02:24:49 +09:00
Daan De Meyer
daa2547e31 Add a few more bypass environment variables
When we're building ParticleOS images, we don't want the package
manager (or mkosi) to run systemd-sysusers, systemd-tmpfiles or
systemctl preset so let's add a few more bypass environment
variables that we can set to have execution of these skipped like
we already have $SYSTEMD_HWDB_UPDATE_BYPASS and $KERNEL_INSTALL_BYPASS.
2025-03-01 16:22:53 +01:00
Yu Watanabe
d5ddc0e0d3 stat-util: drop statx_fallback()
Now both our required baseline of glibc and kernel support statx.
2025-03-01 00:33:32 +09:00
Yu Watanabe
4424e6c811 tree-wide: drop workarounds for statx()
struct statx in glibc header was introduced in glibc-2.28
(fd70af45528d59a00eb3190ef6706cb299488fcd), but at that time,
sys/stat.h conflicts with linux/stat.h. Since glibc-2.30
(5dad6ffbb2b76215cfcd38c3001778536ada8e8a), sys/stat.h includes
linux/stat.h if exists.

Since now our baseline of glibc is 2.31. Hence, we can drop workarounds
for struct statx by importing linux/stat.h from newer kernel (v6.14-rc4).
2025-03-01 00:33:28 +09:00
Yu Watanabe
914d1ec171 tmpfiles: fix output value assignment
Fixes a bug in 7eeda1da90 (v256).
2025-02-28 23:38:02 +09:00
Yu Watanabe
5dbd751ccc tmpfiles: 3 trivial cleanups (#36332) 2025-02-10 02:33:33 +09:00
Mike Yuan
8dc4f9a944 tmpfiles: drop redundant proc_mounted() check
Follow-up for 01131684ac

After the mentioned commit, the execution of tmpfiles
is aborted without /proc/. No need to check for individual
operations.
2025-02-09 15:39:25 +01:00
Mike Yuan
7b66a950db tmpfiles: use prefix_roota() where appropriate 2025-02-09 15:39:24 +01:00
Mike Yuan
6f91e7a3be tmpfiles: fix copypasta in create_symlink() (FIFO -> symlink) 2025-02-09 15:39:22 +01:00
Mike Yuan
61b3d116ee tmpfiles,chown-recursive: port to xsetxattr()/xremovexattr() 2025-02-09 14:51:04 +01:00
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