Commit Graph

4772 Commits

Author SHA1 Message Date
Lennart Poettering
d45dee7c00 chase-symlinks: don't insist on absolute paths if CHASE_PREFIX_ROOT is set
There's little reason to require this, given that we can just say that
if a relative path is specified it is to be read relative to the root.

This fixes a bootctl bug introduced by
3730dc5d5b which didn't bother prefixing
paths as necessary.
2022-09-20 13:52:01 +02:00
Yu Watanabe
f1d93b84bc mkdir: chase_symlinks_and_stat() does not return 0
This reverts commits e22916e61d and
1e146d7382.
2022-09-19 22:54:05 +09:00
Yu Watanabe
5b4671ec47 Merge pull request #24646 from yuwata/udev-node-symlink_atomic
udev: introduce symlink_atomic_full() and use it
2022-09-19 05:25:58 +09:00
Yu Watanabe
28f9bcd65a path-util: add examples for path_make_relative() and path_make_relative_parent()
Addresses https://github.com/systemd/systemd/pull/24646#discussion_r973691797.
2022-09-19 00:30:29 +09:00
Yu Watanabe
ee3455cf11 fd-util: rename CLOSE_AND_REPLACE() -> close_and_replace()
We have free_and_replace() and friends, they are all named with lower
letters, even they are macros, not functions.
For consistency, let's rename CLOSE_AND_REPLACE() with lower letters.

This also mekes the macro used more places.
2022-09-17 09:54:41 +02:00
Yu Watanabe
8dcc66cefc uid-range: tie up number and array of uid range entries
This renames UidRange -> UidRangeEntry, and reintroduces UidRange which
contains the array of UidRangeEntry and its size.
No fucntional changes, just refactoring.
2022-09-16 20:56:58 +09:00
Yu Watanabe
6cc6cd9289 uid-range: make uid_range_intersect() take two UidRange objects
No functional changes, just refactoring.
2022-09-16 20:52:47 +09:00
Yu Watanabe
f6c13f9f95 uid-range: optimize to load uid_map file
If uid_map contains many lines, then the previous logic takes O(n^2 log n),
This makes O(n log n).
2022-09-16 20:52:36 +09:00
Yu Watanabe
b5739767da uid-range: escape from loop earlier
The array of uid range entries are already sorted. Hence, if x and y are
does not have intersection, then the remaining entries neither have
intersection with x.
2022-09-16 20:50:00 +09:00
Yu Watanabe
34eeba475d uid-range: sort uid range entries in uid_range_coalesce()
As the logic in uid_range_coalesce() assumes the array of entries are
already sorted.
No functional changes, just refactoring.
2022-09-16 20:49:55 +09:00
Yu Watanabe
7cf337c50f uid-range: use parse_uid_range() 2022-09-16 20:48:53 +09:00
Yu Watanabe
590d81002b fs-util,label: introduce symlink_atomic_full() and symlink_atomic_full_label()
These new functions optionally create symlink of relative path.
2022-09-14 06:22:09 +09:00
Yu Watanabe
449375d2ad fs-util: use path_make_relative_parent() at one more place 2022-09-14 06:22:09 +09:00
David Tardon
995340074e tree-wide: use ASSERT_PTR more 2022-09-13 08:13:27 +02:00
Yu Watanabe
75a5a143bb Merge pull request #23043 from yuwata/udev-node-use-flock
udev-node: use flock() for symlink stack directory
2022-09-12 23:40:34 +09:00
Guillaume W. Bres
b3fe33ff52 basic/missing_loop.h: fix missing lo_flags LO_FLAGS_DIRECT_IO 2022-09-08 18:46:19 +01:00
Yu Watanabe
a30d3c0134 uid-range: move to src/basic/
To make the functions defined in the files usable by libsystemd library.
2022-09-08 11:08:43 +09:00
Yu Watanabe
6f2cea06bf Merge pull request #24467 from qdeslandes/nspawn_rootidmap
nspawn: add rootidmap as --bind option
2022-09-06 03:45:53 +09:00
Lennart Poettering
11a1ac5978 parse-util: make safe_atou8() just a wrapper around safe_atou8_full()
As in the previous commit: it's just a wrapper around the same
strtoul(), hence let's just share some more code.
2022-09-05 18:17:18 +02:00
Lennart Poettering
c74101200c parse-util: make safe_atou16_full() just a wrapper around safe_atou_full()
Both are fancy wrappers around strtoul() anyway, not more, hence let's
just make them a wrapper around each other, too, to simplify things a
lot.
2022-09-05 18:17:18 +02:00
Quentin Deslandes
1aa18710af nspawn: rename RemountIdmapFlags enum to RemountIdmapping
This enum should be used to define various idmapping modes for bind
mounts which might be incompatible. Changing its name and the values
name to reflect that.
2022-09-05 15:49:26 +01:00
Yu Watanabe
8ba24727c5 tmpfile-util: truncate original filename if the result filename is too long
This also verify that the extra string does not contain '/'.
2022-09-03 09:47:31 +09:00
Yu Watanabe
d4f60bdc11 path-util: introduce path_make_relative_parent() 2022-09-03 05:01:51 +09:00
Lennart Poettering
f1ee066840 log: don't attempt to duplicate closed fd
if the console fd is not open we shouldn#t try to move it out of the 0…2
range.

Fixes: #24535
Alternative-for: #24537
2022-09-03 03:06:18 +09:00
Johannes Schauer Marin Rodrigues
3fa8a1148a sysusers: make sp_lstchg shadow field reproducible
If the environment variable SOURCE_DATE_EPOCH is set, use its value
instead of the current time.
2022-09-02 07:17:25 +02:00
Lennart Poettering
6eeadaa141 path-util: return error if fnmatch() fails 2022-08-31 17:31:11 +02:00
Lennart Poettering
8812f8fc65 hashmap: add comment explaining that set_fnmatch() handles fnmatch() errors as non-matches 2022-08-31 15:13:42 +02:00
Jan Janssen
63b9838639 tree-wide: Mark some constants as unsigned
All these are really unsigned and used as such. This silences some
-Wformat-signedness warnings with gcc.
2022-08-30 12:03:33 +02:00
Yu Watanabe
69a20cc3e4 Merge pull request #23888 from topimiettinen/networkd-netlabel-v2
network: NetLabel integration
2022-08-30 07:30:49 +09:00
Lennart Poettering
bcfc0e8872 strv: modernize strv_fnmatch() a bit 2022-08-30 01:09:12 +09:00
Topi Miettinen
5b198025de sd-netlink: add NetLabel support 2022-08-29 14:23:17 +09:00
Topi Miettinen
3f36b9ed47 basic: generate netmasks for IPv6 and generic IP family addresses
Added functions to generate netmasks for IPv6 and generic IP family addresses.
2022-08-29 14:23:17 +09:00
Yu Watanabe
4492b5d804 devnum-util: split-out device_path_make_inaccessible() 2022-08-28 09:08:21 +09:00
Devendra Tewari
0f79b3469f systemd-growfs: use sd_device_new_from_devnum()
Use sd_device_new_from_devnum() instead of
device_path_make_major_minor_sysfs().
2022-08-26 20:33:03 +01:00
Yu Watanabe
72715f3d13 virt: fix alignment
Follow-up for f555830674.
2022-08-25 16:23:05 +00:00
Devendra Tewari
aa181897cf systemd-growfs: remove dependency on udev symlinks
systemd-growfs currently requires that udev ran first to work (because
/dev/block/ symlinks must exist) but that is not what happens when
we're not using initrd and systemd is PID1.
2022-08-24 21:42:16 +01:00
Lennart Poettering
782c6e5c90 time-util: fix overflow condition in usec_sub_signed()
If the delta specified is INT64_MIN, and we negate that we'd end up at
INT64_MAX+1 which is outside of the int64_t type. Hence let's treat this
case specifically to avoid unintended overflows.
2022-08-24 21:41:40 +01:00
Richard Phibel
34683dbdd0 journald: use rate-limited logging to log 'Failed to write entry' message 2022-08-24 21:39:20 +01:00
Luca Boccassi
298b3de6d4 Merge pull request #24370 from keszybz/sysusers-equivs
Use /bin/bash for root shell and suppress some warnings from sysusers
2022-08-24 21:35:28 +01:00
Zbigniew Jędrzejewski-Szmek
8795d9bacd basic/user-util: rename output param to ret, shorten code 2022-08-24 10:02:46 +02:00
Zbigniew Jędrzejewski-Szmek
36bac2dcba basic/user-util: avoid filesystem access check
The check of u==UID_NOBODY is just a register comparison, but
synthesize_nobody() requires a system call, so let's invert the order in the
condition. Since most calls into this module are not for nobody, we should
save one syscall in the common case.
2022-08-24 10:02:46 +02:00
Zbigniew Jędrzejewski-Szmek
8a7adccbdb various: try to use DEFAULT_USER_SHELL for root too
/bin/sh as a shell is punishing. There is no good reason to make
the occasional root login unpleasant.

Since /bin/sh is usually /bin/bash in compat mode, i.e. if one is
available, the other will be too, /bin/bash is almost as good as a default.
But to avoid a regression in the situation where /bin/bash (or
DEFAULT_USER_SHELL) is not installed, we check with access() and fall back
to /bin/sh. This should make this change in behaviour less risky.

(FWIW, e.g. Fedora/RHEL use /bin/bash as default for root.)

This is a follow-up of sorts for 53350c7bba,
which added the default-user-shell option, but most likely with the idea
of using /bin/bash less ;)

Fixes #24369.
2022-08-24 10:02:46 +02:00
Lennart Poettering
e820ca0193 Merge pull request #24071 from bluca/path_trigger_report
path/timer units: export env vars and D-Bus properties with reason that triggered the job
2022-08-24 09:35:59 +02:00
Zhaofeng Li
f555830674 virt: Support detection of Apple Virtualization.framework guests 2022-08-24 09:34:54 +02:00
Luca Boccassi
f52faaf923 glob: add glob_first(), returns first match
Note that which match is returned depends on the system and is
not guaranteed to be stable
2022-08-23 20:04:41 +01:00
Lennart Poettering
15e2182fb3 mkdir: don't allow us to get confused by symlinks in mkdir_p_root()'s chowning logic 2022-08-23 15:10:15 +02:00
Lennart Poettering
e08c10a424 path-util: drop the now unused dirname_malloc() 2022-08-23 15:10:15 +02:00
Lennart Poettering
45519d13a4 tree-wide: port things dirname_malloc() → path_extract_directory() 2022-08-23 15:10:15 +02:00
Lennart Poettering
81a7eac1f7 chase-symlinks: refuse more chase_symlink() flags in the open/stat flavours
These flags make no sense when we try to access the final inode, hence
refuse.
2022-08-22 19:25:00 +01:00
Lennart Poettering
1d1c226f6c conf-files: port conf_files_list() over to chase_symlinks() from prefix_roota() 2022-08-22 14:08:48 +02:00