Commit Graph
5545 Commits
Author SHA1 Message Date
Lennart Poettering 33b2da2d5b btrfs: use ERRNO_IS_NOT_SUPPORTED() where appropriate 2023-08-16 14:30:51 +02:00
Lennart Poettering f5254d0047 btrfs: drop O_PATH from dir_fd passed to btrfs_subvol_make() if needed
Let's make sure btrfs_subvol_make() can operate on O_PATH fds, just like
mkdirat().

Fixes a bunch of tmpfiles errors at boot if we try to create btrfs
subvols, introduced by e54c79ccc2

Fixes: e54c79ccc2
2023-08-16 14:29:20 +02:00
Daan De Meyer c81e350c03 Merge pull request #28833 from DaanDeMeyer/copy-subvolume
repart: Add Subvolumes= setting
2023-08-15 09:53:02 +02:00
Daan De Meyer 4419735822 fd-util: Use /proc/pid/fd instead of /proc/self/fd
Currently, we mount via file descriptors using /proc/self/fd. This
works, but it means that in /proc/mounts and various other files,
the source of the mount will be listed as /proc/self/fd/xxx. For other
software that parses these files, /proc/self/fd/xxx doesn't mean anything,
or worse, it means the completely wrong thing, as it will refer to one of
their own file descriptors instead.

Let's improve the situation by using /proc/pid/fd instead. This allows
processes parsing /proc/mounts to do the right thing more often than not.
One scenario where even this doesn't work if when containers are involved,
as with the pid namespace unshared, even /proc/pid/fd will mean the wrong
thing, but it's no worse than /proc/self/fd which will always means the wrong
thing.

This also doesn't work if we mount via file descriptor and then exit, as the pid will
be gone, but it does work as long as the process that did the mount is alive, which
makes it useful for systemd-dissect --with for example if the program we run in the
image wants to parse /proc/mounts.
2023-08-14 22:43:12 +02:00
Daan De Meyer c55a97f1fd mkdir: Add support for creating subvolumes to mkdir_p_root()
We pass in the paths which should be subvolumes and try to create
those as subvolumes if we can.
2023-08-14 18:46:08 +02:00
Daan De Meyer bc6a6130ac fs-util: Add XO_SUBVOLUME flag for xopenat()
When specified, xopenat() will try to create a btrfs subvolume and
fall back to creating a regular directory.
2023-08-14 18:46:08 +02:00
Daan De Meyer e54c79ccc2 btrfs-util: Move subvolume creation to basic/btrfs.h
Also make btrfs_subvol_make() an openat style function.
2023-08-14 18:46:08 +02:00
Daan De Meyer 6819924c30 path-util: Make ret argument optional for path_extract_directory() 2023-08-14 18:46:06 +02:00
Yu Watanabe 88321d5d77 Merge pull request #28809 from YHNdnzj/proc-cmdline-true-when-missing
proc-cmdline: introduce PROC_CMDLINE_TRUE_WHEN_MISSING and use it where appropriate
2023-08-13 19:25:22 +09:00
Sam James 0b4e0943a0 basic: add comment for LFS assert in dirent-util.h
Followup to eb29296937 as promised; requested
by lennart at https://github.com/systemd/systemd/pull/27599#discussion_r1192619263.
2023-08-13 10:40:36 +01:00
Mike Yuan 60499ed1c8 proc-cmdline: do assert on flags earlier 2023-08-13 12:52:15 +08:00
Mike Yuan 97d5f09bd2 proc-cmdline: introduce PROC_CMDLINE_TRUE_WHEN_MISSING 2023-08-13 12:52:15 +08:00
Lennart Poettering 82ee54b2d8 iovec-util: add iovw_isempty() helper
Follow-up for: 3746131aac
2023-08-11 21:51:17 +01:00
Yu Watanabe 3746131aac io-util: introduce iovw_append() helper function 2023-08-11 06:08:36 +09:00
Lennart Poettering 6257e2fb1a coredump: use a cleanup handler for destroying iovw objects 2023-08-10 12:10:47 +02:00
Luca Boccassi 4051fc1d54 Merge pull request #28734 from loongarch64/dev-wu-main
seccomp: add LoongArch 64bit support
2023-08-09 20:20:03 +01:00
Lennart Poettering d1e8e8b5ae tree-wide: drop _pure_ + _const_ from local, static functions
This is supposed to be a help for compilers to apply optimizations on
functions where they can't determine whether they are const/pure on
their own. For static, local functions the compiler can do this on its
own easily however, hence the decoration with pure/const is just noise.
Let's drop it, and let the compiler to its thing better.

(Use it for exported functions, since compilers can't 'reach-over' into
other modules to determine if they are pure, except if LTO is used)
2023-08-10 00:01:04 +08:00
Xiaotian Wu f106a63952 LoongArch: Replace __loongarch64 with __loongarch_lp64
`__loongarch64` is no longer used for historical reasons and should be replaced by `__loongarch_lp64` in new code.

https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html#_cc_preprocessor_built_in_macro_definitions
2023-08-09 20:44:57 +08:00
Yu Watanabe 3787934b54 proc-cmdline: make proc_cmdline_get_bool() take flags
All other command line parsers takes flags. Let's make
proc_cmdline_get_bool() also take flags. Though, currently,
no flag is set by the caller.
2023-08-09 17:46:41 +09:00
Dan Streetman 900e73f80e openssl: add ecc_pkey_new(), ecc_pkey_from_curve_x_y(), ecc_pkey_to_curve_x_y()
Add function to create openssl pkey from ECC curve and point, and function to
get curve id and x/y point from existing ECC pkey. Also add function to create
new ECC key for specified curve.

Also add DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO() to handle case when func() is
a macro, not a function symbol; specifically in this case it is used for
OPENSSL_free() which is a macro.
2023-08-04 10:57:08 -04:00
OMOJOLA JOSHUA fc7eb1325b Add tool to display emergency log message full-screen on boot failure. 2023-08-04 00:24:54 +01:00
Khem Raj 213ddf2d05 include sys/file.h for LOCK_EX
Fixes
| ../git/src/basic/user-util.c:708:30: error: use of undeclared identifier 'LOCK_EX'; did you mean 'LOCK_BSD'?
|   708 |         r = unposix_lock(fd, LOCK_EX);
|       |                              ^~~~~~~
|       |                              LOCK_BSD

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2023-08-02 19:49:15 +01:00
Luca Boccassi 241dbc6e99 Merge pull request #28423 from dvdhrm/pr/memfd
basic/memfd: untangle historic `sealed` property
2023-08-01 15:33:24 +01:00
David Rheinsberg 6968841056 basic/memfd: fix memfd_map() seal test
Private mappings are required when F_SEAL_WRITE is set on a memfd,
because otherwise you could end up with writable mappings through
mprotect() and other calls. This is a limitation of the kernel
implementation, and might be lifted by future extensions.

Regardless, the current code tests for the full `is_sealed()` before
using MAP_PRIVATE. This might end up using MAP_SHARED for write-sealed
memfds, which will be refused by the kernel.

Fix this and make memfd_map() check for exactly `F_SEAL_WRITE`.
2023-08-01 10:14:50 +02:00
David Rheinsberg 4d90300371 basic/memfd: add fcntl() wrappers
Add wrappers around GET/ADD_SEALS to allow future use outside of the
current `memfd_get/set_sealed()` helpers.
2023-08-01 10:14:49 +02:00
David Rheinsberg e1007a928a basic/memfd: reduce default seals to historic set
Rather than always setting all seals, make `memfd_set_seals()` employ
the original set of seals, that is: SEAL+GROW+SHRINK+WRITE

Historically, the memfd code was used with the out-of-tree memfd
patches, which merely supported a single seal ("SEALED", which
effectively was GROW+SHRINK+WRITE). When the code was adapted to the
upstream memfd seals, it was extended to the full seal set. With more
and more seals being added upstream, this because more problematic. In
particular, it is unclear what the function really is meant to achieve.

Instead of just adding all seals, the function is returned to its
original purpose: seal the memfd so futher modifications to its content
are prevented.
2023-08-01 10:13:51 +02:00
David Rheinsberg d268b22b25 basic/memfd: drop test for F_SEAL_SEAL
With `F_SEAL_SEAL` a memfd can disable further sealing operations,
effectively sealing the set of seals. Testing for it ensures that no
further seals can be added, it never prevents seals from being dropped,
since seals cannot be dropped, ever.

Now testing for `F_SEAL_SEAL` makes sense if you want to ensure that
some seals are *not* set. That is, you either test for the entire set of
seals to match a local set, or you verify that a specific seal is not
set. Neither is what we are doing, so it feels wrong requiring it to be
set.

By dropping the requirement for `F_SEAL_SEAL`, the same FD can be shared
with other entities while retaining the ability to further restrict the
set of seals later on (e.g., being able to mark a region as executable
later on, and then adding `F_SEAL_EXEC`).
2023-08-01 10:13:46 +02:00
Daan De Meyer 7e5bf8981f Merge pull request #28474 from yuwata/chase-fix
chase: handle ".." more carefully
2023-07-31 10:46:19 +02:00
Luca Boccassi 6c0ac118d2 Merge pull request #28567 from yuwata/meson-versiondep
meson:  cleanups for version dependency
2023-07-30 23:40:51 +01:00
Yu Watanabe 9701be563a in-addr-util: introduce PTR_TO_IN4_ADDR() and IN4_ADDR_TO_PTR()
These should be useful when an IPv4 address is used as a key of a
hashmap.
2023-07-30 23:15:53 +09:00
Yu Watanabe 40c7d3c713 meson: unconditionally add version dependency for all executables and libraries
Otherwise, we can easily forget the dependency.
No functional change, just refactoring.
2023-07-30 05:36:22 +09:00
Yu Watanabe bdb577f545 tree-wide: drop unnecessary inclusion of version.h 2023-07-30 04:56:38 +09:00
Yu Watanabe 4445242a1e chase: propagate error in dir_fd_is_root()
Otherwise, if it fails, chaseat() may return unexpected result and
triggers an assertion in chase().
2023-07-29 22:09:32 +09:00
Yu Watanabe 83c57d8cde chase: check root path in more detail
In chaseat() we call dir_fd_is_root() several places, and the final
result depends on it. If the root path specified to `chase()` is not
normalized but points to "/", e.g. "/../", assertions in `chaseat()` or
`chase()` may be triggered.
2023-07-29 22:09:28 +09:00
Yu Watanabe 4de5b4e375 chase: carefully handle result of extracting parent directory
Should not change any behavior.
2023-07-29 21:58:30 +09:00
Yu Watanabe 1c13bdf342 chase: add two more assertions
When 'need_absolute' is true, 'done' should always contain "/" at the
beginning, and thus should not be NULL.
2023-07-29 21:58:30 +09:00
Yu Watanabe b7e957d30f chase: drop CHASE_AT_RESOLVE_IN_ROOT earlier
The flag will be anyway dropped in chaseat(), but let's shortcut.
2023-07-29 21:58:29 +09:00
Yu Watanabe 5f0bae7bff chase: fix CHASE_STEP with ".." 2023-07-29 21:58:29 +09:00
Yu Watanabe 00a050b395 chase: reuse "done" to open fd of starting point
For readability that 'done' and 'fd' are always consistent with each other.

- dir_fd == AT_FDCWD:
  - path is absolute:
    - previous: fd = open("/")
    - current:  fd = openat(AT_FDCWD, "/")
  - path is relative:
    - previous: fd = openat(AT_FDCWD, ".")
    - current:  fd = openat(AT_FDCWD, ".")
- dir_fd >= 0:
  - dir_fd points to "/":
    - previous: fd = openat(dir_fd, ".")
    - current:  fd = openat(dir_fd, "/")
  - dir_fd does not point to "/":
    - previous: fd = openat(dir_fd, ".")
    - current:  fd = openat(dir_fd, ".")

Hence, this should not change any behavior. Just refactoring.
2023-07-29 21:58:29 +09:00
Luca Boccassi e72b28eb7a Merge pull request #28557 from bluca/utils
utils: add serialize_bool_elide() and send/receive helpers for FD array
2023-07-29 12:39:06 +01:00
Luca Boccassi fc3fe92bc8 Merge pull request #28508 from yuwata/network-next-dhcp4
network: several cleanups and fixes for DHCPv4 client
2023-07-29 12:15:38 +01:00
Luca Boccassi 598d2428e1 socket-util: add send/receive helpers for FD array 2023-07-29 11:25:05 +01:00
Luca Boccassi b0d3095fd6 Drop split-usr and unmerged-usr support
As previously announced, execute order 66:

https://lists.freedesktop.org/archives/systemd-devel/2022-September/048352.html

The meson options split-usr, rootlibdir and rootprefix become no-ops
that print a warning if they are set to anything other than the
default values. We can remove them in a future release.
2023-07-28 19:34:03 +01:00
Daan De Meyer 7ccb171c4c Merge pull request #28359 from keszybz/ret-gather
Add RET_GATHER macro to make continue-but-remember-first-error functions easier
2023-07-28 14:28:35 +02:00
Luca Boccassi de06b9a1b9 Merge pull request #28430 from keszybz/cleanups
Various small cleanups
2023-07-28 09:56:28 +01:00
Luca Boccassi 46021aaaa6 Merge pull request #28417 from bluca/coverity
Some coverity fixes
2023-07-28 09:56:08 +01:00
Yu Watanabe 45e76094ab in-addr-util: introduce in_addr_prefix_covers_full() and friends 2023-07-28 05:15:11 +09:00
Yu Watanabe bb2e3c90fc missing: include linux/types.h for __s64 and __u64
Fixes #28529.
2023-07-26 21:39:56 +01:00
Yu Watanabe 68a4fc8b53 fd-util: do not call statx() twice when it does not provide mount ID
Previously, in path_is_root_at(), if statx() does not provide mount ID,
path_get_mnt_id_at() was called, but it also calls statx(). Let's avoid
the second trial.
2023-07-22 02:22:06 +09:00
Yu Watanabe bd96111d5f fd-util: make path_is_root_at() not fail even when /proc is mounted
path_get_mnt_id_at() -> fd_fdinfo_mnt_id() may return -EOPNOTSUPP when
/proc is mounted, and -ENOSYS otherwise, when an old kernel is used.
2023-07-22 02:20:27 +09:00