summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TODO16
-rw-r--r--src/basic/chase.c (renamed from src/basic/chase-symlinks.c)94
-rw-r--r--src/basic/chase.h (renamed from src/basic/chase-symlinks.h)34
-rw-r--r--src/basic/conf-files.c4
-rw-r--r--src/basic/devnum-util.c4
-rw-r--r--src/basic/fileio.c2
-rw-r--r--src/basic/meson.build2
-rw-r--r--src/basic/mkdir.c6
-rw-r--r--src/basic/mountpoint-util.c4
-rw-r--r--src/basic/os-util.c18
-rw-r--r--src/basic/path-util.c13
-rw-r--r--src/basic/stat-util.c4
-rw-r--r--src/basic/unit-file.c6
-rw-r--r--src/basic/user-util.c4
-rw-r--r--src/boot/bootctl-install.c18
-rw-r--r--src/boot/bootctl-status.c14
-rw-r--r--src/boot/pcrphase.c4
-rw-r--r--src/core/dbus-manager.c4
-rw-r--r--src/core/execute.c6
-rw-r--r--src/core/namespace.c10
-rw-r--r--src/core/service.c8
-rw-r--r--src/core/socket.c4
-rw-r--r--src/core/unit.c4
-rw-r--r--src/coredump/coredumpctl.c8
-rw-r--r--src/delta/delta.c8
-rw-r--r--src/dissect/dissect.c8
-rw-r--r--src/firstboot/firstboot.c4
-rw-r--r--src/fstab-generator/fstab-generator.c9
-rw-r--r--src/journal/journalctl.c4
-rw-r--r--src/libsystemd/sd-device/sd-device.c6
-rw-r--r--src/mount/mount-tool.c8
-rw-r--r--src/nspawn/nspawn-bind-user.c6
-rw-r--r--src/nspawn/nspawn-mount.c16
-rw-r--r--src/nspawn/nspawn.c24
-rw-r--r--src/partition/repart.c22
-rw-r--r--src/portable/portable.c4
-rw-r--r--src/portable/portablectl.c4
-rw-r--r--src/shared/bootspec.c10
-rw-r--r--src/shared/discover-image.c12
-rw-r--r--src/shared/dissect-image.c12
-rw-r--r--src/shared/dropin.c4
-rw-r--r--src/shared/find-esp.c14
-rw-r--r--src/shared/install.c8
-rw-r--r--src/shared/mount-util.c4
-rw-r--r--src/shared/specifier.c6
-rw-r--r--src/shared/switch-root.c6
-rw-r--r--src/shared/uid-alloc-range.c4
-rw-r--r--src/shutdown/umount.c4
-rw-r--r--src/sysext/sysext.c18
-rw-r--r--src/systemctl/systemctl-switch-root.c6
-rw-r--r--src/systemctl/systemctl-util.c4
-rw-r--r--src/sysupdate/sysupdate-resource.c6
-rw-r--r--src/sysupdate/sysupdate-transfer.c4
-rw-r--r--src/sysupdate/sysupdate.c4
-rw-r--r--src/sysusers/sysusers.c6
-rw-r--r--src/test/meson.build2
-rw-r--r--src/test/test-chase.c (renamed from src/test/test-chase-symlinks.c)4
-rw-r--r--src/test/test-copy.c4
-rw-r--r--src/test/test-fs-util.c180
-rw-r--r--src/tmpfiles/offline-passwd.c4
-rw-r--r--src/tmpfiles/tmpfiles.c10
-rw-r--r--src/udev/udev-builtin-net_id.c2
-rw-r--r--src/udev/udevadm-wait.c2
-rw-r--r--src/volatile-root/volatile-root.c4
64 files changed, 374 insertions, 384 deletions
diff --git a/TODO b/TODO
index fd7c348f9a..5d2390610e 100644
--- a/TODO
+++ b/TODO
@@ -75,7 +75,7 @@ Janitorial Clean-ups:
* rework mount.c and swap.c to follow proper state enumeration/deserialization
semantics, like we do for device.c now
-* get rid of prefix_roota() and similar, only use chase_symlinks() and related
+* get rid of prefix_roota() and similar, only use chase() and related
calls instead.
* get rid of basename() and replace by path_extract_filename()
@@ -604,13 +604,13 @@ Features:
* Add support for extra verity configuration options to systemd-repart (FEC,
hash type, etc)
-* chase_symlinks(): take inspiration from path_extract_filename() and return
+* chase(): take inspiration from path_extract_filename() and return
O_DIRECTORY if input path contains trailing slash.
-* chase_symlinks(): refuse resolution if trailing slash is specified on input,
+* chase(): refuse resolution if trailing slash is specified on input,
but final node is not a directory
-* chase_symlinks(): add new flag that simply refuses all symlink use in a path,
+* chase(): add new flag that simply refuses all symlink use in a path,
then use that for accessing XBOOTLDR/ESP
* document in boot loader spec that symlinks in XBOOTLDR/ESP are not OK even if
@@ -743,7 +743,7 @@ Features:
* implement varlink introspection
* we should probably drop all use of prefix_roota() and friends, and use
- chase_symlinks() instead
+ chase() instead
* make persistent restarts easier by adding a new setting OpenPersistentFile=
or so, which allows opening one or more files that is "persistent" across
@@ -1261,10 +1261,10 @@ Features:
documented in the pivot_root(2) man page, so that we can drop the /oldroot
temporary dir.
-* special case some calls of chase_symlinks() to use openat2() internally, so
+* special case some calls of chase() to use openat2() internally, so
that the kernel does what we otherwise do.
-* add a new flag to chase_symlinks() that stops chasing once the first missing
+* add a new flag to chase() that stops chasing once the first missing
component is found and then allows the caller to create the rest.
* make use of new glibc 2.32 APIs sigabbrev_np() and strerrorname_np().
@@ -1951,7 +1951,7 @@ Features:
* mount: turn dependency information from /proc/self/mountinfo into dependency information between systemd units.
-* systemd-firstboot: make sure to always use chase_symlinks() before
+* systemd-firstboot: make sure to always use chase() before
reading/writing files
* firstboot: make it useful to be run immediately after yum --installroot to set up a machine. (most specifically, make --copy-root-password work even if /etc/passwd already exists
diff --git a/src/basic/chase-symlinks.c b/src/basic/chase.c
index 3eb43ffa62..3d423e4f88 100644
--- a/src/basic/chase-symlinks.c
+++ b/src/basic/chase.c
@@ -3,7 +3,7 @@
#include <linux/magic.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
@@ -24,7 +24,7 @@ bool unsafe_transition(const struct stat *a, const struct stat *b) {
return a->st_uid != b->st_uid; /* Otherwise we need to stay within the same UID */
}
-static int log_unsafe_transition(int a, int b, const char *path, ChaseSymlinksFlags flags) {
+static int log_unsafe_transition(int a, int b, const char *path, ChaseFlags flags) {
_cleanup_free_ char *n1 = NULL, *n2 = NULL, *user_a = NULL, *user_b = NULL;
struct stat st;
@@ -44,7 +44,7 @@ static int log_unsafe_transition(int a, int b, const char *path, ChaseSymlinksFl
strna(n1), strna(user_a), special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), strna(n2), strna(user_b), path);
}
-static int log_autofs_mount_point(int fd, const char *path, ChaseSymlinksFlags flags) {
+static int log_autofs_mount_point(int fd, const char *path, ChaseFlags flags) {
_cleanup_free_ char *n1 = NULL;
if (!FLAGS_SET(flags, CHASE_WARN))
@@ -57,7 +57,7 @@ static int log_autofs_mount_point(int fd, const char *path, ChaseSymlinksFlags f
strna(n1), path);
}
-static int log_prohibited_symlink(int fd, ChaseSymlinksFlags flags) {
+static int log_prohibited_symlink(int fd, ChaseFlags flags) {
_cleanup_free_ char *n1 = NULL;
assert(fd >= 0);
@@ -72,16 +72,16 @@ static int log_prohibited_symlink(int fd, ChaseSymlinksFlags flags) {
strna(n1));
}
-int chase_symlinks_at(
+int chaseat(
int dir_fd,
const char *path,
- ChaseSymlinksFlags flags,
+ ChaseFlags flags,
char **ret_path,
int *ret_fd) {
_cleanup_free_ char *buffer = NULL, *done = NULL;
_cleanup_close_ int fd = -EBADF, root_fd = -EBADF;
- unsigned max_follow = CHASE_SYMLINKS_MAX; /* how many symlinks to follow before giving up and returning ELOOP */
+ unsigned max_follow = CHASE_MAX; /* how many symlinks to follow before giving up and returning ELOOP */
bool exists = true, append_trail_slash = false;
struct stat previous_stat;
const char *todo;
@@ -107,7 +107,7 @@ int chase_symlinks_at(
path = ".";
/* This function resolves symlinks of the path relative to the given directory file descriptor. If
- * CHASE_SYMLINKS_RESOLVE_IN_ROOT is specified and a directory file descriptor is provided, symlinks
+ * CHASE_AT_RESOLVE_IN_ROOT is specified and a directory file descriptor is provided, symlinks
* are resolved relative to the given directory file descriptor. Otherwise, they are resolved
* relative to the root directory of the host.
*
@@ -471,10 +471,10 @@ chased_one:
return 0;
}
-int chase_symlinks(
+int chase(
const char *path,
const char *original_root,
- ChaseSymlinksFlags flags,
+ ChaseFlags flags,
char **ret_path,
int *ret_fd) {
@@ -531,7 +531,7 @@ int chase_symlinks(
flags |= CHASE_AT_RESOLVE_IN_ROOT;
flags &= ~CHASE_PREFIX_ROOT;
- r = chase_symlinks_at(fd, path, flags, ret_path ? &p : NULL, ret_fd ? &pfd : NULL);
+ r = chaseat(fd, path, flags, ret_path ? &p : NULL, ret_fd ? &pfd : NULL);
if (r < 0)
return r;
@@ -561,10 +561,10 @@ int chase_symlinks(
return r;
}
-int chase_symlinks_and_open(
+int chase_and_open(
const char *path,
const char *root,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
int open_flags,
char **ret_path) {
@@ -583,7 +583,7 @@ int chase_symlinks_and_open(
open_flags | (FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? O_NOFOLLOW : 0),
mode));
- r = chase_symlinks(path, root, CHASE_PARENT|chase_flags, &p, &path_fd);
+ r = chase(path, root, CHASE_PARENT|chase_flags, &p, &path_fd);
if (r < 0)
return r;
assert(path_fd >= 0);
@@ -609,10 +609,10 @@ int chase_symlinks_and_open(
return r;
}
-int chase_symlinks_and_opendir(
+int chase_and_opendir(
const char *path,
const char *root,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
char **ret_path,
DIR **ret_dir) {
@@ -635,7 +635,7 @@ int chase_symlinks_and_opendir(
return 0;
}
- r = chase_symlinks(path, root, chase_flags, ret_path ? &p : NULL, &path_fd);
+ r = chase(path, root, chase_flags, ret_path ? &p : NULL, &path_fd);
if (r < 0)
return r;
assert(path_fd >= 0);
@@ -651,10 +651,10 @@ int chase_symlinks_and_opendir(
return 0;
}
-int chase_symlinks_and_stat(
+int chase_and_stat(
const char *path,
const char *root,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
char **ret_path,
struct stat *ret_stat) {
@@ -672,7 +672,7 @@ int chase_symlinks_and_stat(
return RET_NERRNO(fstatat(AT_FDCWD, path, ret_stat,
FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0));
- r = chase_symlinks(path, root, chase_flags, ret_path ? &p : NULL, &path_fd);
+ r = chase(path, root, chase_flags, ret_path ? &p : NULL, &path_fd);
if (r < 0)
return r;
assert(path_fd >= 0);
@@ -686,10 +686,10 @@ int chase_symlinks_and_stat(
return 0;
}
-int chase_symlinks_and_access(
+int chase_and_access(
const char *path,
const char *root,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
int access_mode,
char **ret_path) {
@@ -706,7 +706,7 @@ int chase_symlinks_and_access(
return RET_NERRNO(faccessat(AT_FDCWD, path, access_mode,
FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0));
- r = chase_symlinks(path, root, chase_flags, ret_path ? &p : NULL, &path_fd);
+ r = chase(path, root, chase_flags, ret_path ? &p : NULL, &path_fd);
if (r < 0)
return r;
assert(path_fd >= 0);
@@ -721,10 +721,10 @@ int chase_symlinks_and_access(
return 0;
}
-int chase_symlinks_and_fopen_unlocked(
+int chase_and_fopen_unlocked(
const char *path,
const char *root,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
const char *open_flags,
char **ret_path,
FILE **ret_file) {
@@ -742,7 +742,7 @@ int chase_symlinks_and_fopen_unlocked(
if (mode_flags < 0)
return mode_flags;
- fd = chase_symlinks_and_open(path, root, chase_flags, mode_flags, ret_path ? &final_path : NULL);
+ fd = chase_and_open(path, root, chase_flags, mode_flags, ret_path ? &final_path : NULL);
if (fd < 0)
return fd;
@@ -756,10 +756,10 @@ int chase_symlinks_and_fopen_unlocked(
return 0;
}
-int chase_symlinks_and_unlink(
+int chase_and_unlink(
const char *path,
const char *root,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
int unlink_flags,
char **ret_path) {
@@ -770,7 +770,7 @@ int chase_symlinks_and_unlink(
assert(path);
assert(!(chase_flags & (CHASE_NONEXISTENT|CHASE_STEP|CHASE_PARENT)));
- fd = chase_symlinks_and_open(path, root, chase_flags|CHASE_PARENT|CHASE_NOFOLLOW, O_PATH|O_DIRECTORY|O_CLOEXEC, &p);
+ fd = chase_and_open(path, root, chase_flags|CHASE_PARENT|CHASE_NOFOLLOW, O_PATH|O_DIRECTORY|O_CLOEXEC, &p);
if (fd < 0)
return fd;
@@ -787,10 +787,10 @@ int chase_symlinks_and_unlink(
return 0;
}
-int chase_symlinks_at_and_open(
+int chase_and_openat(
int dir_fd,
const char *path,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
int open_flags,
char **ret_path) {
@@ -808,7 +808,7 @@ int chase_symlinks_at_and_open(
open_flags | (FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? O_NOFOLLOW : 0),
mode));
- r = chase_symlinks_at(dir_fd, path, chase_flags|CHASE_PARENT, &p, &path_fd);
+ r = chaseat(dir_fd, path, chase_flags|CHASE_PARENT, &p, &path_fd);
if (r < 0)
return r;
@@ -829,10 +829,10 @@ int chase_symlinks_at_and_open(
return r;
}
-int chase_symlinks_at_and_opendir(
+int chase_and_opendirat(
int dir_fd,
const char *path,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
char **ret_path,
DIR **ret_dir) {
@@ -855,7 +855,7 @@ int chase_symlinks_at_and_opendir(
return 0;
}
- r = chase_symlinks_at(dir_fd, path, chase_flags, ret_path ? &p : NULL, &path_fd);
+ r = chaseat(dir_fd, path, chase_flags, ret_path ? &p : NULL, &path_fd);
if (r < 0)
return r;
assert(path_fd >= 0);
@@ -871,10 +871,10 @@ int chase_symlinks_at_and_opendir(
return 0;
}
-int chase_symlinks_at_and_stat(
+int chase_and_statat(
int dir_fd,
const char *path,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
char **ret_path,
struct stat *ret_stat) {
@@ -892,7 +892,7 @@ int chase_symlinks_at_and_stat(
return RET_NERRNO(fstatat(AT_FDCWD, path, ret_stat,
FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0));
- r = chase_symlinks_at(dir_fd, path, chase_flags, ret_path ? &p : NULL, &path_fd);
+ r = chaseat(dir_fd, path, chase_flags, ret_path ? &p : NULL, &path_fd);
if (r < 0)
return r;
assert(path_fd >= 0);
@@ -906,10 +906,10 @@ int chase_symlinks_at_and_stat(
return 0;
}
-int chase_symlinks_at_and_access(
+int chase_and_accessat(
int dir_fd,
const char *path,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
int access_mode,
char **ret_path) {
@@ -926,7 +926,7 @@ int chase_symlinks_at_and_access(
return RET_NERRNO(faccessat(AT_FDCWD, path, access_mode,
FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0));
- r = chase_symlinks_at(dir_fd, path, chase_flags, ret_path ? &p : NULL, &path_fd);
+ r = chaseat(dir_fd, path, chase_flags, ret_path ? &p : NULL, &path_fd);
if (r < 0)
return r;
assert(path_fd >= 0);
@@ -941,10 +941,10 @@ int chase_symlinks_at_and_access(
return 0;
}
-int chase_symlinks_at_and_fopen_unlocked(
+int chase_and_fopenat_unlocked(
int dir_fd,
const char *path,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
const char *open_flags,
char **ret_path,
FILE **ret_file) {
@@ -962,7 +962,7 @@ int chase_symlinks_at_and_fopen_unlocked(
if (mode_flags < 0)
return mode_flags;
- fd = chase_symlinks_at_and_open(dir_fd, path, chase_flags, mode_flags, ret_path ? &final_path : NULL);
+ fd = chase_and_openat(dir_fd, path, chase_flags, mode_flags, ret_path ? &final_path : NULL);
if (fd < 0)
return fd;
@@ -976,10 +976,10 @@ int chase_symlinks_at_and_fopen_unlocked(
return 0;
}
-int chase_symlinks_at_and_unlink(
+int chase_and_unlinkat(
int dir_fd,
const char *path,
- ChaseSymlinksFlags chase_flags,
+ ChaseFlags chase_flags,
int unlink_flags,
char **ret_path) {
@@ -990,7 +990,7 @@ int chase_symlinks_at_and_unlink(
assert(path);
assert(!(chase_flags & (CHASE_NONEXISTENT|CHASE_STEP|CHASE_PARENT)));
- fd = chase_symlinks_at_and_open(dir_fd, path, chase_flags|CHASE_PARENT|CHASE_NOFOLLOW, O_PATH|O_DIRECTORY|O_CLOEXEC, &p);
+ fd = chase_and_openat(dir_fd, path, chase_flags|CHASE_PARENT|CHASE_NOFOLLOW, O_PATH|O_DIRECTORY|O_CLOEXEC, &p);
if (fd < 0)
return fd;
diff --git a/src/basic/chase-symlinks.h b/src/basic/chase.h
index de7910a5e6..c94cbde8fe 100644
--- a/src/basic/chase-symlinks.h
+++ b/src/basic/chase.h
@@ -6,7 +6,7 @@
#include "stat-util.h"
-typedef enum ChaseSymlinksFlags {
+typedef enum ChaseFlags {
CHASE_PREFIX_ROOT = 1 << 0, /* The specified path will be prefixed by the specified root before beginning the iteration */
CHASE_NONEXISTENT = 1 << 1, /* It's OK if the path doesn't actually exist. */
CHASE_NO_AUTOFS = 1 << 2, /* Return -EREMOTE if autofs mount point found */
@@ -25,27 +25,27 @@ typedef enum ChaseSymlinksFlags {
* file descriptor will point to the parent directory. */
CHASE_MKDIR_0755 = 1 << 11, /* Create any missing parent directories in the given path. */
CHASE_EXTRACT_FILENAME = 1 << 12, /* Only return the last component of the resolved path */
-} ChaseSymlinksFlags;
+} ChaseFlags;
bool unsafe_transition(const struct stat *a, const struct stat *b);
/* How many iterations to execute before returning -ELOOP */
-#define CHASE_SYMLINKS_MAX 32
+#define CHASE_MAX 32
-int chase_symlinks(const char *path_with_prefix, const char *root, ChaseSymlinksFlags chase_flags, char **ret_path, int *ret_fd);
+int chase(const char *path_with_prefix, const char *root, ChaseFlags chase_flags, char **ret_path, int *ret_fd);
-int chase_symlinks_and_open(const char *path, const char *root, ChaseSymlinksFlags chase_flags, int open_flags, char **ret_path);
-int chase_symlinks_and_opendir(const char *path, const char *root, ChaseSymlinksFlags chase_flags, char **ret_path, DIR **ret_dir);
-int chase_symlinks_and_stat(const char *path, const char *root, ChaseSymlinksFlags chase_flags, char **ret_path, struct stat *ret_stat);
-int chase_symlinks_and_access(const char *path, const char *root, ChaseSymlinksFlags chase_flags, int access_mode, char **ret_path);
-int chase_symlinks_and_fopen_unlocked(const char *path, const char *root, ChaseSymlinksFlags chase_flags, const char *open_flags, char **ret_path, FILE **ret_file);
-int chase_symlinks_and_unlink(const char *path, const char *root, ChaseSymlinksFlags chase_flags, int unlink_flags, char **ret_path);
+int chase_and_open(const char *path, const char *root, ChaseFlags chase_flags, int open_flags, char **ret_path);
+int chase_and_opendir(const char *path, const char *root, ChaseFlags chase_flags, char **ret_path, DIR **ret_dir);
+int chase_and_stat(const char *path, const char *root, ChaseFlags chase_flags, char **ret_path, struct stat *ret_stat);
+int chase_and_access(const char *path, const char *root, ChaseFlags chase_flags, int access_mode, char **ret_path);
+int chase_and_fopen_unlocked(const char *path, const char *root, ChaseFlags chase_flags, const char *open_flags, char **ret_path, FILE **ret_file);
+int chase_and_unlink(const char *path, const char *root, ChaseFlags chase_flags, int unlink_flags, char **ret_path);
-int chase_symlinks_at(int dir_fd, const char *path, ChaseSymlinksFlags flags, char **ret_path, int *ret_fd);
+int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int *ret_fd);
-int chase_symlinks_at_and_open(int dir_fd, const char *path, ChaseSymlinksFlags chase_flags, int open_flags, char **ret_path);
-int chase_symlinks_at_and_opendir(int dir_fd, const char *path, ChaseSymlinksFlags chase_flags, char **ret_path, DIR **ret_dir);
-int chase_symlinks_at_and_stat(int dir_fd, const char *path, ChaseSymlinksFlags chase_flags, char **ret_path, struct stat *ret_stat);
-int chase_symlinks_at_and_access(int dir_fd, const char *path, ChaseSymlinksFlags chase_flags, int access_mode, char **ret_path);
-int chase_symlinks_at_and_fopen_unlocked(int dir_fd, const char *path, ChaseSymlinksFlags chase_flags, const char *open_flags, char **ret_path, FILE **ret_file);
-int chase_symlinks_at_and_unlink(int dir_fd, const char *path, ChaseSymlinksFlags chase_flags, int unlink_flags, char **ret_path);
+int chase_and_openat(int dir_fd, const char *path, ChaseFlags chase_flags, int open_flags, char **ret_path);
+int chase_and_opendirat(int dir_fd, const char *path, ChaseFlags chase_flags, char **ret_path, DIR **ret_dir);
+int chase_and_statat(int dir_fd, const char *path, ChaseFlags chase_flags, char **ret_path, struct stat *ret_stat);
+int chase_and_accessat(int dir_fd, const char *path, ChaseFlags chase_flags, int access_mode, char **ret_path);
+int chase_and_fopenat_unlocked(int dir_fd, const char *path, ChaseFlags chase_flags, const char *open_flags, char **ret_path, FILE **ret_file);
+int chase_and_unlinkat(int dir_fd, const char *path, ChaseFlags chase_flags, int unlink_flags, char **ret_path);
diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c
index d64277b806..215e7951dc 100644
--- a/src/basic/conf-files.c
+++ b/src/basic/conf-files.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "chase-symlinks.h"
+#include "chase.h"
#include "conf-files.h"
#include "constants.h"
#include "dirent-util.h"
@@ -38,7 +38,7 @@ static int files_add(
assert(masked);
assert(path);
- r = chase_symlinks_and_opendir(path, root, CHASE_PREFIX_ROOT, &dirpath, &dir);
+ r = chase_and_opendir(path, root, CHASE_PREFIX_ROOT, &dirpath, &dir);
if (r == -ENOENT)
return 0;
if (r < 0)
diff --git a/src/basic/devnum-util.c b/src/basic/devnum-util.c
index bd1b4d6c39..de02255eef 100644
--- a/src/basic/devnum-util.c
+++ b/src/basic/devnum-util.c
@@ -3,7 +3,7 @@
#include <string.h>
#include <sys/stat.h>
-#include "chase-symlinks.h"
+#include "chase.h"
#include "devnum-util.h"
#include "parse-util.h"
#include "path-util.h"
@@ -92,7 +92,7 @@ int device_path_make_canonical(mode_t mode, dev_t devnum, char **ret) {
if (r < 0)
return r;
- return chase_symlinks(p, NULL, 0, ret, NULL);
+ return chase(p, NULL, 0, ret, NULL);
}
int device_path_parse_major_minor(const char *path, mode_t *ret_mode, dev_t *ret_devnum) {
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index c75981528e..340f9b4860 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -13,7 +13,7 @@
#include <unistd.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
diff --git a/src/basic/meson.build b/src/basic/meson.build
index 5f616c1893..ee94337140 100644
--- a/src/basic/meson.build
+++ b/src/basic/meson.build
@@ -14,7 +14,7 @@ basic_sources = files(
'cap-list.c',
'capability-util.c',
'cgroup-util.c',
- 'chase-symlinks.c',
+ 'chase.c',
'chattr-util.c',
'conf-files.c',
'devnum-util.c',
diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c
index 2257a1452f..3b7cf7a0bf 100644
--- a/src/basic/mkdir.c
+++ b/src/basic/mkdir.c
@@ -5,7 +5,7 @@
#include <string.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "fd-util.h"
#include "format-util.h"
#include "fs-util.h"
@@ -47,7 +47,7 @@ int mkdirat_safe_internal(
if ((flags & MKDIR_FOLLOW_SYMLINK) && S_ISLNK(st.st_mode)) {
_cleanup_free_ char *p = NULL;
- r = chase_symlinks_at(dir_fd, path, CHASE_NONEXISTENT, &p, NULL);
+ r = chaseat(dir_fd, path, CHASE_NONEXISTENT, &p, NULL);
if (r < 0)
return r;
if (r == 0)
@@ -234,7 +234,7 @@ int mkdir_p_root(const char *root, const char *p, uid_t uid, gid_t gid, mode_t m
if (r < 0)
return r;
- dfd = chase_symlinks_and_open(pp, root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_DIRECTORY, NULL);
+ dfd = chase_and_open(pp, root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_DIRECTORY, NULL);
if (dfd < 0)
return dfd;
}
diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c
index 24e38a34e8..ad22894a59 100644
--- a/src/basic/mountpoint-util.c
+++ b/src/basic/mountpoint-util.c
@@ -8,7 +8,7 @@
#endif
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "fd-util.h"
#include "fileio.h"
#include "filesystems.h"
@@ -341,7 +341,7 @@ int path_is_mount_point(const char *t, const char *root, int flags) {
* /bin -> /usr/bin/ and /usr is a mount point, then the parent that we
* look at needs to be /usr, not /. */
if (flags & AT_SYMLINK_FOLLOW) {
- r = chase_symlinks(t, root, CHASE_TRAIL_SLASH, &canonical, NULL);
+ r = chase(t, root, CHASE_TRAIL_SLASH, &canonical, NULL);
if (r < 0)
return r;
diff --git a/src/basic/os-util.c b/src/basic/os-util.c
index bf844e5b7f..c8b23b10e4 100644
--- a/src/basic/os-util.c
+++ b/src/basic/os-util.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "dirent-util.h"
#include "env-file.h"
#include "env-util.h"
@@ -108,9 +108,7 @@ int open_extension_release(const char *root, const char *extension, bool relax_e
"The extension name %s is invalid.", extension);
extension_full_path = strjoina("/usr/lib/extension-release.d/extension-release.", extension);
- r = chase_symlinks(extension_full_path, root, CHASE_PREFIX_ROOT,
- ret_path ? &q : NULL,
- ret_fd ? &fd : NULL);
+ r = chase(extension_full_path, root, CHASE_PREFIX_ROOT, ret_path ? &q : NULL, ret_fd ? &fd : NULL);
log_full_errno_zerook(LOG_DEBUG, MIN(r, 0), "Checking for %s: %m", extension_full_path);
/* Cannot find the expected extension-release file? The image filename might have been
@@ -122,8 +120,8 @@ int open_extension_release(const char *root, const char *extension, bool relax_e
_cleanup_free_ char *extension_release_dir_path = NULL;
_cleanup_closedir_ DIR *extension_release_dir = NULL;
- r = chase_symlinks_and_opendir("/usr/lib/extension-release.d/", root, CHASE_PREFIX_ROOT,
- &extension_release_dir_path, &extension_release_dir);
+ r = chase_and_opendir("/usr/lib/extension-release.d/", root, CHASE_PREFIX_ROOT,
+ &extension_release_dir_path, &extension_release_dir);
if (r < 0)
return log_debug_errno(r, "Cannot open %s/usr/lib/extension-release.d/, ignoring: %m", root);
@@ -192,14 +190,10 @@ int open_extension_release(const char *root, const char *extension, bool relax_e
} else {
const char *var = secure_getenv("SYSTEMD_OS_RELEASE");
if (var)
- r = chase_symlinks(var, root, 0,
- ret_path ? &q : NULL,
- ret_fd ? &fd : NULL);
+ r = chase(var, root, 0, ret_path ? &q : NULL, ret_fd ? &fd : NULL);
else
FOREACH_STRING(path, "/etc/os-release", "/usr/lib/os-release") {
- r = chase_symlinks(path, root, CHASE_PREFIX_ROOT,
- ret_path ? &q : NULL,
- ret_fd ? &fd : NULL);
+ r = chase(path, root, CHASE_PREFIX_ROOT, ret_path ? &q : NULL, ret_fd ? &fd : NULL);
if (r != -ENOENT)
break;
}
diff --git a/src/basic/path-util.c b/src/basic/path-util.c
index 40a819d47d..ae0b25d155 100644
--- a/src/basic/path-util.c
+++ b/src/basic/path-util.c
@@ -8,7 +8,7 @@
#include <unistd.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "extract-word.h"
#include "fd-util.h"
#include "fs-util.h"
@@ -285,7 +285,7 @@ char **path_strv_resolve(char **l, const char *root) {
} else
t = *s;
- r = chase_symlinks(t, root, 0, &u, NULL);
+ r = chase(t, root, 0, &u, NULL);
if (r == -ENOENT) {
if (root) {
u = TAKE_PTR(orig);
@@ -621,16 +621,13 @@ static int find_executable_impl(const char *name, const char *root, char **ret_f
assert(name);
- /* Function chase_symlinks() is invoked only when root is not NULL, as using it regardless of
+ /* Function chase() is invoked only when root is not NULL, as using it regardless of
* root value would alter the behavior of existing callers for example: /bin/sleep would become
* /usr/bin/sleep when find_executables is called. Hence, this function should be invoked when
* needed to avoid unforeseen regression or other complicated changes. */
if (root) {
- r = chase_symlinks(name,
- root,
- CHASE_PREFIX_ROOT,
- &path_name,
- /* ret_fd= */ NULL); /* prefix root to name in case full paths are not specified */
+ /* prefix root to name in case full paths are not specified */
+ r = chase(name, root, CHASE_PREFIX_ROOT, &path_name, /* ret_fd= */ NULL);
if (r < 0)
return r;
diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c
index 42cefed48d..150605e86d 100644
--- a/src/basic/stat-util.c
+++ b/src/basic/stat-util.c
@@ -8,7 +8,7 @@
#include <unistd.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "dirent-util.h"
#include "errno-util.h"
#include "fd-util.h"
@@ -145,7 +145,7 @@ int null_or_empty_path_with_root(const char *fn, const char *root) {
if (path_equal_ptr(path_startswith(fn, root ?: "/"), "dev/null"))
return true;
- r = chase_symlinks_and_stat(fn, root, CHASE_PREFIX_ROOT, NULL, &st);
+ r = chase_and_stat(fn, root, CHASE_PREFIX_ROOT, NULL, &st);
if (r < 0)
return r;
diff --git a/src/basic/unit-file.c b/src/basic/unit-file.c
index 1f79a2735e..70b7eb1606 100644
--- a/src/basic/unit-file.c
+++ b/src/basic/unit-file.c
@@ -2,7 +2,7 @@
#include "sd-id128.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "dirent-util.h"
#include "fd-util.h"
#include "fs-util.h"
@@ -322,7 +322,7 @@ int unit_file_resolve_symlink(
}
/* Get rid of "." and ".." components in target path */
- r = chase_symlinks(target, root_dir, CHASE_NOFOLLOW | CHASE_NONEXISTENT, &simplified, NULL);
+ r = chase(target, root_dir, CHASE_NOFOLLOW | CHASE_NONEXISTENT, &simplified, NULL);
if (r < 0)
return log_warning_errno(r, "Failed to resolve symlink %s/%s pointing to %s: %m",
dir, filename, target);
@@ -432,7 +432,7 @@ int unit_file_build_name_map(
if (r < 0)
return log_oom();
- r = chase_symlinks(*dir, NULL, 0, &resolved_dir, NULL);
+ r = chase(*dir, NULL, 0, &resolved_dir, NULL);
if (r < 0) {
if (r != -ENOENT)
log_warning_errno(r, "Failed to resolve symlink %s, ignoring: %m", *dir);
diff --git a/src/basic/user-util.c b/src/basic/user-util.c
index 0a47947d34..551e98b427 100644
--- a/src/basic/user-util.c
+++ b/src/basic/user-util.c
@@ -13,7 +13,7 @@
#include "sd-messages.h"
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
@@ -161,7 +161,7 @@ const char* default_root_shell(const char *root) {
* will be /bin/bash. Fall back to /bin/sh if DEFAULT_USER_SHELL is not found,
* or any access errors. */
- int r = chase_symlinks(DEFAULT_USER_SHELL, root, CHASE_PREFIX_ROOT, NULL, NULL);
+ int r = chase(DEFAULT_USER_SHELL, root, CHASE_PREFIX_ROOT, NULL, NULL);
if (r < 0 && r != -ENOENT)
log_debug_errno(r, "Failed to look up shell '%s%s%s': %m",
strempty(root), root ? "/" : "", DEFAULT_USER_SHELL);
diff --git a/src/boot/bootctl-install.c b/src/boot/bootctl-install.c
index 617d0abde0..dc7ea8c5ca 100644
--- a/src/boot/bootctl-install.c
+++ b/src/boot/bootctl-install.c
@@ -4,7 +4,7 @@
#include "bootctl-install.h"
#include "bootctl-random-seed.h"
#include "bootctl-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "copy.h"
#include "dirent-util.h"
#include "efi-api.h"
@@ -337,10 +337,10 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) {
if (!p)
return log_oom();
- r = chase_symlinks(p, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &source_path, NULL);
+ r = chase(p, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &source_path, NULL);
/* If we had a root directory to try, we didn't find it and we are in auto mode, retry on the host */
if (r == -ENOENT && root && arg_install_source == ARG_INSTALL_SOURCE_AUTO)
- r = chase_symlinks(p, NULL, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &source_path, NULL);
+ r = chase(p, NULL, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &source_path, NULL);
if (r < 0)
return log_error_errno(r,
"Failed to resolve path %s%s%s: %m",
@@ -352,7 +352,7 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) {
if (!q)
return log_oom();
- r = chase_symlinks(q, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_NONEXISTENT, &dest_path, NULL);
+ r = chase(q, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_NONEXISTENT, &dest_path, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve path %s under directory %s: %m", q, esp_path);
@@ -369,7 +369,7 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) {
v = strjoina("/EFI/BOOT/BOOT", e);
ascii_strupper(strrchr(v, '/') + 1);
- r = chase_symlinks(v, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_NONEXISTENT, &default_dest_path, NULL);
+ r = chase(v, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_NONEXISTENT, &default_dest_path, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve path %s under directory %s: %m", v, esp_path);
@@ -387,10 +387,10 @@ static int install_binaries(const char *esp_path, const char *arch, bool force)
_cleanup_free_ char *path = NULL;
int r;
- r = chase_symlinks_and_opendir(BOOTLIBDIR, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &path, &d);
+ r = chase_and_opendir(BOOTLIBDIR, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &path, &d);
/* If we had a root directory to try, we didn't find it and we are in auto mode, retry on the host */
if (r == -ENOENT && root && arg_install_source == ARG_INSTALL_SOURCE_AUTO)
- r = chase_symlinks_and_opendir(BOOTLIBDIR, NULL, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &path, &d);
+ r = chase_and_opendir(BOOTLIBDIR, NULL, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &path, &d);
if (r < 0)
return log_error_errno(r, "Failed to open boot loader directory %s%s: %m", strempty(root), BOOTLIBDIR);
@@ -665,7 +665,7 @@ static int install_variables(
return 0;
}
- r = chase_symlinks_and_access(path, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL);
+ r = chase_and_access(path, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL);
if (r == -ENOENT)
return 0;
if (r < 0)
@@ -831,7 +831,7 @@ static int remove_boot_efi(const char *esp_path) {
_cleanup_free_ char *p = NULL;
int r, c = 0;
- r = chase_symlinks_and_opendir("/EFI/BOOT", esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &p, &d);
+ r = chase_and_opendir("/EFI/BOOT", esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &p, &d);
if (r == -ENOENT)
return 0;
if (r < 0)
diff --git a/src/boot/bootctl-status.c b/src/boot/bootctl-status.c
index ce97b013cf..cc0c3ad34a 100644
--- a/src/boot/bootctl-status.c
+++ b/src/boot/bootctl-status.c
@@ -7,7 +7,7 @@
#include "bootctl-status.h"
#include "bootctl-util.h"
#include "bootspec.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "devnum-util.h"
#include "dirent-util.h"
#include "efi-api.h"
@@ -200,7 +200,7 @@ static int enumerate_binaries(
assert(previous);
assert(is_first);
- r = chase_symlinks_and_opendir(path, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &p, &d);
+ r = chase_and_opendir(path, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &p, &d);
if (r == -ENOENT)
return 0;
if (r < 0)
@@ -560,7 +560,7 @@ static void deref_unlink_file(Hashmap *known_files, const char *fn, const char *
return;
if (arg_dry_run) {
- r = chase_symlinks_and_access(fn, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, &path);
+ r = chase_and_access(fn, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, &path);
if (r < 0)
log_info_errno(r, "Unable to determine whether \"%s\" exists, ignoring: %m", fn);
else
@@ -568,7 +568,7 @@ static void deref_unlink_file(Hashmap *known_files, const char *fn, const char *
return;
}
- r = chase_symlinks_and_unlink(fn, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, 0, &path);
+ r = chase_and_unlink(fn, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, 0, &path);
if (r >= 0)
log_info("Removed \"%s\"", path);
else if (r != -ENOENT)
@@ -576,7 +576,7 @@ static void deref_unlink_file(Hashmap *known_files, const char *fn, const char *
_cleanup_free_ char *d = NULL;
if (path_extract_directory(fn, &d) >= 0 && !path_equal(d, "/")) {
- r = chase_symlinks_and_unlink(d, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, AT_REMOVEDIR, NULL);
+ r = chase_and_unlink(d, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, AT_REMOVEDIR, NULL);
if (r < 0 && !IN_SET(r, -ENOTEMPTY, -ENOENT))
log_warning_errno(r, "Failed to remove directory \"%s\", ignoring: %m", d);
}
@@ -672,7 +672,7 @@ static int unlink_entry(const BootConfig *config, const char *root, const char *
if (arg_dry_run)
log_info("Would remove \"%s\"", e->path);
else {
- r = chase_symlinks_and_unlink(e->path, root, CHASE_PROHIBIT_SYMLINKS, 0, NULL);
+ r = chase_and_unlink(e->path, root, CHASE_PROHIBIT_SYMLINKS, 0, NULL);
if (r < 0)
return log_error_errno(r, "Failed to remove \"%s\": %m", e->path);
@@ -734,7 +734,7 @@ static int cleanup_orphaned_files(
if (r < 0)
return log_error_errno(r, "Failed to count files in %s: %m", root);
- dir_fd = chase_symlinks_and_open(arg_entry_token, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS,
+ dir_fd = chase_and_open(arg_entry_token, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS,
O_DIRECTORY|O_CLOEXEC, &full);
if (dir_fd == -ENOENT)
return 0;
diff --git a/src/boot/pcrphase.c b/src/boot/pcrphase.c
index 896e248653..afa474c883 100644
--- a/src/boot/pcrphase.c
+++ b/src/boot/pcrphase.c
@@ -8,7 +8,7 @@
#include "blkid-util.h"
#include "blockdev-util.h"
#include "build.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "efi-loader.h"
#include "efivars.h"
#include "escape.h"
@@ -259,7 +259,7 @@ static int run(int argc, char *argv[]) {
if (optind != argc)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Expected no argument.");
- dfd = chase_symlinks_and_open(arg_file_system, NULL, 0, O_DIRECTORY|O_CLOEXEC, &normalized);
+ dfd = chase_and_open(arg_file_system, NULL, 0, O_DIRECTORY|O_CLOEXEC, &normalized);
if (dfd < 0)
return log_error_errno(dfd, "Failed to open path '%s': %m", arg_file_system);
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index ca65bbf106..c88ef93443 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -11,7 +11,7 @@
#include "bus-common-errors.h"
#include "bus-get-properties.h"
#include "bus-log-control-api.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "data-fd-util.h"
#include "dbus-cgroup.h"
#include "dbus-execute.h"
@@ -1768,7 +1768,7 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
"Path to init binary '%s' not absolute.", init);
- r = chase_symlinks_and_access(init, root, CHASE_PREFIX_ROOT, X_OK, NULL);
+ r = chase_and_access(init, root, CHASE_PREFIX_ROOT, X_OK, NULL);
if (r == -EACCES)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
"Init binary %s is not executable.", init);
diff --git a/src/core/execute.c b/src/core/execute.c
index f8ac4705e7..bfdd2026c6 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -46,7 +46,7 @@
#include "cap-list.h"
#include "capability-util.h"
#include "cgroup-setup.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "chown-recursive.h"
#include "constants.h"
#include "cpu-set-util.h"
@@ -2602,7 +2602,7 @@ static int setup_exec_directory(
* since they all support the private/ symlink logic at least in some
* configurations, see above. */
- r = chase_symlinks(target, NULL, 0, &target_resolved, NULL);
+ r = chase(target, NULL, 0, &target_resolved, NULL);
if (r < 0)
goto fail;
@@ -2613,7 +2613,7 @@ static int setup_exec_directory(
}
/* /var/lib or friends may be symlinks. So, let's chase them also. */
- r = chase_symlinks(q, NULL, CHASE_NONEXISTENT, &q_resolved, NULL);
+ r = chase(q, NULL, CHASE_NONEXISTENT, &q_resolved, NULL);
if (r < 0)
goto fail;
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 90c0f84420..c75a2cb29f 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -13,7 +13,7 @@
#include "alloc-util.h"
#include "base-filesystem.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "dev-setup.h"
#include "devnum-util.h"
#include "env-util.h"
@@ -1312,13 +1312,13 @@ static int follow_symlink(
* a time by specifying CHASE_STEP. This function returns 0 if we resolved one step, and > 0 if we reached the
* end and already have a fully normalized name. */
- r = chase_symlinks(mount_entry_path(m), root_directory, CHASE_STEP|CHASE_NONEXISTENT, &target, NULL);
+ r = chase(mount_entry_path(m), root_directory, CHASE_STEP|CHASE_NONEXISTENT, &target, NULL);
if (r < 0)
return log_debug_errno(r, "Failed to chase symlinks '%s': %m", mount_entry_path(m));
if (r > 0) /* Reached the end, nothing more to resolve */
return 1;
- if (m->n_followed >= CHASE_SYMLINKS_MAX) /* put a boundary on things */
+ if (m->n_followed >= CHASE_MAX) /* put a boundary on things */
return log_debug_errno(SYNTHETIC_ERRNO(ELOOP),
"Symlink loop on '%s'.",
mount_entry_path(m));
@@ -1453,9 +1453,9 @@ static int apply_one_mount(
/* Since mount() will always follow symlinks we chase the symlinks on our own first. Note
* that bind mount source paths are always relative to the host root, hence we pass NULL as
- * root directory to chase_symlinks() here. */
+ * root directory to chase() here. */
- r = chase_symlinks(mount_entry_source(m), NULL, CHASE_TRAIL_SLASH, &chased, NULL);
+ r = chase(mount_entry_source(m), NULL, CHASE_TRAIL_SLASH, &chased, NULL);
if (r == -ENOENT && m->ignore) {
log_debug_errno(r, "Path %s does not exist, ignoring.", mount_entry_source(m));
return 0;
diff --git a/src/core/service.c b/src/core/service.c
index f8f5d6b1ec..21d1bf6595 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -12,7 +12,7 @@
#include "bus-error.h"
#include "bus-kernel.h"
#include "bus-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "constants.h"
#include "dbus-service.h"
#include "dbus-unit.h"
@@ -1007,21 +1007,21 @@ static int service_load_pid_file(Service *s, bool may_warn) {
prio = may_warn ? LOG_INFO : LOG_DEBUG;
- r = chase_symlinks(s->pid_file, NULL, CHASE_SAFE, NULL, &fd);
+ r = chase(s->pid_file, NULL, CHASE_SAFE, NULL, &fd);
if (r == -ENOLINK) {
log_unit_debug_errno(UNIT(s), r,
"Potentially unsafe symlink chain, will now retry with relaxed checks: %s", s->pid_file);
questionable_pid_file = true;
- r = chase_symlinks(s->pid_file, NULL, 0, NULL, &fd);
+ r = chase(s->pid_file, NULL, 0, NULL, &fd);
}
if (r < 0)
return log_unit_full_errno(UNIT(s), prio, fd,
"Can't open PID file %s (yet?) after %s: %m", s->pid_file, service_state_to_string(s->state));
/* Let's read the PID file now that we chased it down. But we need to convert the O_PATH fd
- * chase_symlinks() returned us into a proper fd first. */
+ * chase() returned us into a proper fd first. */
r = read_one_line_file(FORMAT_PROC_FD_PATH(fd), &k);
if (r < 0)
return log_unit_error_errno(UNIT(s), r,
diff --git a/src/core/socket.c b/src/core/socket.c
index 307a8f2061..6b153a92fa 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -14,7 +14,7 @@
#include "bpf-firewall.h"
#include "bus-error.h"
#include "bus-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "constants.h"
#include "copy.h"
#include "dbus-socket.h"
@@ -1434,7 +1434,7 @@ static int socket_determine_selinux_label(Socket *s, char **ret) {
if (!c)
goto no_label;
- r = chase_symlinks(c->path, SERVICE(service)->exec_context.root_directory, CHASE_PREFIX_ROOT, &path, NULL);
+ r = chase(c->path, SERVICE(service)->exec_context.root_directory, CHASE_PREFIX_ROOT, &path, NULL);
if (r < 0)
goto no_label;
diff --git a/src/core/unit.c b/src/core/unit.c
index a9dffdf2b9..0418593d25 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -17,7 +17,7 @@
#include "bus-util.h"
#include "cgroup-setup.h"
#include "cgroup-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "core-varlink.h"
#include "dbus-unit.h"
#include "dbus.h"
@@ -4894,7 +4894,7 @@ int unit_fail_if_noncanonical(Unit *u, const char* where) {
assert(u);
assert(where);
- r = chase_symlinks(where, NULL, CHASE_NONEXISTENT, &canonical_where, NULL);
+ r = chase(where, NULL, CHASE_NONEXISTENT, &canonical_where, NULL);
if (r < 0) {
log_unit_debug_errno(u, r, "Failed to check %s for symlinks, ignoring: %m", where);
return 0;
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c
index 909ffc8d8b..60da536d4e 100644
--- a/src/coredump/coredumpctl.c
+++ b/src/coredump/coredumpctl.c
@@ -15,7 +15,7 @@
#include "bus-error.h"
#include "bus-locator.h"
#include "bus-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "compress.h"
#include "constants.h"
#include "dissect-image.h"
@@ -505,13 +505,13 @@ static int resolve_filename(const char *root, char **p) {
if (!*p)
return 0;
- r = chase_symlinks(*p, root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved, NULL);
+ r = chase(*p, root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve \"%s%s\": %m", strempty(root), *p);
free_and_replace(*p, resolved);
- /* chase_symlinks() with flag CHASE_NONEXISTENT will return 0 if the file doesn't exist and 1 if it does.
+ /* chase() with flag CHASE_NONEXISTENT will return 0 if the file doesn't exist and 1 if it does.
* Return that to the caller
*/
return r;
@@ -981,7 +981,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
return r;
assert(r > 0);
- r = chase_symlinks_and_access(filename, arg_root, CHASE_PREFIX_ROOT, F_OK, &resolved);
+ r = chase_and_access(filename, arg_root, CHASE_PREFIX_ROOT, F_OK, &resolved);
if (r < 0)
return log_error_errno(r, "Cannot access \"%s%s\": %m", strempty(arg_root), filename);
diff --git a/src/delta/delta.c b/src/delta/delta.c
index db6e957fc9..eee2111aba 100644
--- a/src/delta/delta.c
+++ b/src/delta/delta.c
@@ -7,7 +7,7 @@
#include "alloc-util.h"
#include "build.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "dirent-util.h"
#include "fd-util.h"
#include "fs-util.h"
@@ -75,11 +75,11 @@ static int equivalent(const char *a, const char *b) {
_cleanup_free_ char *x = NULL, *y = NULL;
int r;
- r = chase_symlinks(a, NULL, CHASE_TRAIL_SLASH, &x, NULL);
+ r = chase(a, NULL, CHASE_TRAIL_SLASH, &x, NULL);
if (r < 0)
return r;
- r = chase_symlinks(b, NULL, CHASE_TRAIL_SLASH, &y, NULL);
+ r = chase(b, NULL, CHASE_TRAIL_SLASH, &y, NULL);
if (r < 0)
return r;
@@ -376,7 +376,7 @@ static int should_skip_path(const char *prefix, const char *suffix) {
if (!dirname)
return -ENOMEM;
- if (chase_symlinks(dirname, NULL, 0, &target, NULL) < 0)
+ if (chase(dirname, NULL, 0, &target, NULL) < 0)
return false;
NULSTR_FOREACH(p, prefixes) {
diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c
index 2658b2da60..ff00c4f567 100644
--- a/src/dissect/dissect.c
+++ b/src/dissect/dissect.c
@@ -13,7 +13,7 @@
#include "architecture.h"
#include "blockdev-util.h"
#include "build.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "copy.h"
#include "device-util.h"
#include "devnum-util.h"
@@ -1237,7 +1237,7 @@ static int action_list_or_mtree_or_copy(DissectedImage *m, LoopDevice *d) {
case ACTION_COPY_FROM: {
_cleanup_close_ int source_fd = -EBADF, target_fd = -EBADF;
- source_fd = chase_symlinks_and_open(arg_source, mounted_dir, CHASE_PREFIX_ROOT|CHASE_WARN, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
+ source_fd = chase_and_open(arg_source, mounted_dir, CHASE_PREFIX_ROOT|CHASE_WARN, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
if (source_fd < 0)
return log_error_errno(source_fd, "Failed to open source path '%s' in image '%s': %m", arg_source, arg_image);
@@ -1294,7 +1294,7 @@ static int action_list_or_mtree_or_copy(DissectedImage *m, LoopDevice *d) {
return log_error_errno(r, "Failed to extract filename from target path '%s': %m", arg_target);
is_dir = r == O_DIRECTORY;
- r = chase_symlinks(dn, mounted_dir, CHASE_PREFIX_ROOT|CHASE_WARN, NULL, &dfd);
+ r = chase(dn, mounted_dir, CHASE_PREFIX_ROOT|CHASE_WARN, NULL, &dfd);
if (r < 0)
return log_error_errno(r, "Failed to open '%s': %m", dn);
@@ -1393,7 +1393,7 @@ static int action_umount(const char *path) {
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
int r;
- fd = chase_symlinks_and_open(path, NULL, 0, O_DIRECTORY, &canonical);
+ fd = chase_and_open(path, NULL, 0, O_DIRECTORY, &canonical);
if (fd == -ENOTDIR)
return log_error_errno(SYNTHETIC_ERRNO(ENOTDIR), "'%s' is not a directory", path);
if (fd < 0)
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index 8f3e6a1265..3973de8931 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -10,7 +10,7 @@
#include "alloc-util.h"
#include "ask-password-api.h"
#include "build.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "copy.h"
#include "creds-util.h"
#include "dissect-image.h"
@@ -689,7 +689,7 @@ static int find_shell(const char *path, const char *root) {
if (!valid_shell(path))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "%s is not a valid shell", path);
- r = chase_symlinks(path, root, CHASE_PREFIX_ROOT, NULL, NULL);
+ r = chase(path, root, CHASE_PREFIX_ROOT, NULL, NULL);
if (r < 0) {
const char *p;
p = prefix_roota(root, path);
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 28cd5f05f1..69effacaa2 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -7,7 +7,7 @@
#include "alloc-util.h"
#include "bus-error.h"
#include "bus-locator.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "efi-loader.h"
#include "env-util.h"
#include "fd-util.h"
@@ -723,12 +723,11 @@ static int parse_fstab(bool initrd) {
* where a symlink refers to another mount target; this works assuming the sub-mountpoint
* target is the final directory.
*
- * FIXME: when chase_symlinks() learns to chase non-existent paths, use this here and
+ * FIXME: when chase() learns to chase non-existent paths, use this here and
* drop the prefixing with /sysroot on error below.
*/
- k = chase_symlinks(where, initrd ? "/sysroot" : NULL,
- CHASE_PREFIX_ROOT | CHASE_NONEXISTENT,
- &canonical_where, NULL);
+ k = chase(where, initrd ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT,
+ &canonical_where, NULL);
if (k < 0) {
/* If we can't canonicalize, continue as if it wasn't a symlink */
log_debug_errno(k, "Failed to read symlink target for %s, using as-is: %m", where);
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 59736143bc..69b40e68ea 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -23,7 +23,7 @@
#include "bus-error.h"
#include "bus-util.h"
#include "catalog.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "chattr-util.h"
#include "constants.h"
#include "dissect-image.h"
@@ -1112,7 +1112,7 @@ static int add_matches(sd_journal *j, char **args) {
_cleanup_free_ char *p = NULL, *t = NULL, *t2 = NULL, *interpreter = NULL;
struct stat st;
- r = chase_symlinks(*i, NULL, CHASE_TRAIL_SLASH, &p, NULL);
+ r = chase(*i, NULL, CHASE_TRAIL_SLASH, &p, NULL);
if (r < 0)
return log_error_errno(r, "Couldn't canonicalize path: %m");
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index 8c65ee3469..e86ec3e75b 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -8,7 +8,7 @@
#include "sd-device.h"
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "device-internal.h"
#include "device-private.h"
#include "device-util.h"
@@ -150,7 +150,7 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
/* The input path maybe a symlink located outside of /sys. Let's try to chase the symlink at first.
* The primary usecase is that e.g. /proc/device-tree is a symlink to /sys/firmware/devicetree/base.
* By chasing symlinks in the path at first, we can call sd_device_new_from_path() with such path. */
- r = chase_symlinks(_syspath, NULL, 0, &syspath, &fd);
+ r = chase(_syspath, NULL, 0, &syspath, &fd);
if (r == -ENOENT)
/* the device does not exist (any more?) */
return log_debug_errno(SYNTHETIC_ERRNO(ENODEV),
@@ -163,7 +163,7 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
char *p;
/* /sys is a symlink to somewhere sysfs is mounted on? In that case, we convert the path to real sysfs to "/sys". */
- r = chase_symlinks("/sys", NULL, 0, &real_sys, NULL);
+ r = chase("/sys", NULL, 0, &real_sys, NULL);
if (r < 0)
return log_debug_errno(r, "sd-device: Failed to chase symlink /sys: %m");
diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c
index 5cb1cd5526..5f5d84bb97 100644
--- a/src/mount/mount-tool.c
+++ b/src/mount/mount-tool.c
@@ -10,7 +10,7 @@
#include "bus-locator.h"
#include "bus-unit-util.h"
#include "bus-wait-for-jobs.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "device-util.h"
#include "dirent-util.h"
#include "escape.h"
@@ -384,7 +384,7 @@ static int parse_argv(int argc, char *argv[]) {
if (!u)
return log_oom();
- r = chase_symlinks(u, NULL, 0, &arg_mount_what, NULL);
+ r = chase(u, NULL, 0, &arg_mount_what, NULL);
if (r < 0)
return log_error_errno(r, "Failed to make path %s absolute: %m", u);
} else {
@@ -401,7 +401,7 @@ static int parse_argv(int argc, char *argv[]) {
if (argc > optind+1) {
if (arg_transport == BUS_TRANSPORT_LOCAL) {
- r = chase_symlinks(argv[optind+1], NULL, CHASE_NONEXISTENT, &arg_mount_where, NULL);
+ r = chase(argv[optind+1], NULL, CHASE_NONEXISTENT, &arg_mount_where, NULL);
if (r < 0)
return log_error_errno(r, "Failed to make path %s absolute: %m", argv[optind+1]);
} else {
@@ -1010,7 +1010,7 @@ static int action_umount(
if (!u)
return log_oom();
- r = chase_symlinks(u, NULL, 0, &p, NULL);
+ r = chase(u, NULL, 0, &p, NULL);
if (r < 0) {
r2 = log_error_errno(r, "Failed to make path %s absolute: %m", argv[i]);
continue;
diff --git a/src/nspawn/nspawn-bind-user.c b/src/nspawn/nspawn-bind-user.c
index 2e3c3c3072..0a8653033d 100644
--- a/src/nspawn/nspawn-bind-user.c
+++ b/src/nspawn/nspawn-bind-user.c
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include "chase-symlinks.h"
+#include "chase.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
@@ -21,7 +21,7 @@ static int check_etc_passwd_collisions(
assert(directory);
assert(name || uid_is_valid(uid));
- r = chase_symlinks_and_fopen_unlocked("/etc/passwd", directory, CHASE_PREFIX_ROOT, "re", NULL, &f);
+ r = chase_and_fopen_unlocked("/etc/passwd", directory, CHASE_PREFIX_ROOT, "re", NULL, &f);
if (r == -ENOENT)
return 0; /* no user database? then no user, hence no collision */
if (r < 0)
@@ -54,7 +54,7 @@ static int check_etc_group_collisions(
assert(directory);
assert(name || gid_is_valid(gid));
- r = chase_symlinks_and_fopen_unlocked("/etc/group", directory, CHASE_PREFIX_ROOT, "re", NULL, &f);
+ r = chase_and_fopen_unlocked("/etc/group", directory, CHASE_PREFIX_ROOT, "re", NULL, &f);
if (r == -ENOENT)
return 0; /* no group database? then no group, hence no collision */
if (r < 0)
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c
index f190239cad..ac9dc5116e 100644
--- a/src/nspawn/nspawn-mount.c
+++ b/src/nspawn/nspawn-mount.c
@@ -4,7 +4,7 @@
#include <linux/magic.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "escape.h"
#include "fd-util.h"
#include "format-util.h"
@@ -636,7 +636,7 @@ int mount_all(const char *dest,
if (!tmpfs_tmp && FLAGS_SET(mount_table[k].mount_settings, MOUNT_APPLY_TMPFS_TMP))
continue;
- r = chase_symlinks(mount_table[k].where, dest, CHASE_NONEXISTENT|CHASE_PREFIX_ROOT, &where, NULL);
+ r = chase(mount_table[k].where, dest, CHASE_NONEXISTENT|CHASE_PREFIX_ROOT, &where, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, mount_table[k].where);
@@ -695,7 +695,7 @@ int mount_all(const char *dest,
* mounts to be created within the container image before we transition into it. Note
* that MOUNT_IN_USERNS is run after we transitioned hence prefixing is not ncessary
* for those. */
- r = chase_symlinks(mount_table[k].what, dest, CHASE_PREFIX_ROOT, &prefixed, NULL);
+ r = chase(mount_table[k].what, dest, CHASE_PREFIX_ROOT, &prefixed, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, mount_table[k].what);
}
@@ -779,7 +779,7 @@ static int mount_bind(const char *dest, CustomMount *m, uid_t uid_shift, uid_t u
if (stat(m->source, &source_st) < 0)
return log_error_errno(errno, "Failed to stat %s: %m", m->source);
- r = chase_symlinks(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
+ r = chase(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, m->destination);
if (r > 0) { /* Path exists already? */
@@ -844,7 +844,7 @@ static int mount_tmpfs(const char *dest, CustomMount *m, uid_t uid_shift, const
assert(dest);
assert(m);
- r = chase_symlinks(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
+ r = chase(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, m->destination);
if (r == 0) { /* Doesn't exist yet? */
@@ -884,7 +884,7 @@ static int mount_overlay(const char *dest, CustomMount *m) {
assert(dest);
assert(m);
- r = chase_symlinks(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
+ r = chase(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, m->destination);
if (r == 0) { /* Doesn't exist yet? */
@@ -926,7 +926,7 @@ static int mount_inaccessible(const char *dest, CustomMount *m) {
assert(dest);
assert(m);
- r = chase_symlinks_and_stat(m->destination, dest, CHASE_PREFIX_ROOT, &where, &st);
+ r = chase_and_stat(m->destination, dest, CHASE_PREFIX_ROOT, &where, &st);
if (r < 0) {
log_full_errno(m->graceful ? LOG_DEBUG : LOG_ERR, r, "Failed to resolve %s/%s: %m", dest, m->destination);
return m->graceful ? 0 : r;
@@ -956,7 +956,7 @@ static int mount_arbitrary(const char *dest, CustomMount *m) {
assert(dest);
assert(m);
- r = chase_symlinks(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
+ r = chase(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, m->destination);
if (r == 0) { /* Doesn't exist yet? */
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index f872b2e8f6..9fbacb2713 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -34,7 +34,7 @@
#include "cap-list.h"
#include "capability-util.h"
#include "cgroup-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "common-signal.h"
#include "copy.h"
#include "cpu-set-util.h"
@@ -1958,7 +1958,7 @@ static int setup_timezone(const char *dest) {
if (m == TIMEZONE_OFF)
return 0;
- r = chase_symlinks("/etc", dest, CHASE_PREFIX_ROOT, &etc, NULL);
+ r = chase("/etc", dest, CHASE_PREFIX_ROOT, &etc, NULL);
if (r < 0) {
log_warning_errno(r, "Failed to resolve /etc path in container, ignoring: %m");
return 0;
@@ -1989,7 +1989,7 @@ static int setup_timezone(const char *dest) {
return 0; /* Already pointing to the right place? Then do nothing .. */
check = strjoina(dest, "/usr/share/zoneinfo/", z);
- r = chase_symlinks(check, dest, 0, NULL, NULL);
+ r = chase(check, dest, 0, NULL, NULL);
if (r < 0)
log_debug_errno(r, "Timezone %s does not exist (or is not accessible) in container, not creating symlink: %m", z);
else {
@@ -2016,7 +2016,7 @@ static int setup_timezone(const char *dest) {
_cleanup_free_ char *resolved = NULL;
int found;
- found = chase_symlinks(where, dest, CHASE_NONEXISTENT, &resolved, NULL);
+ found = chase(where, dest, CHASE_NONEXISTENT, &resolved, NULL);
if (found < 0) {
log_warning_errno(found, "Failed to resolve /etc/localtime path in container, ignoring: %m");
return 0;
@@ -2123,7 +2123,7 @@ static int setup_resolv_conf(const char *dest) {
if (m == RESOLV_CONF_OFF)
return 0;
- r = chase_symlinks("/etc", dest, CHASE_PREFIX_ROOT, &etc, NULL);
+ r = chase("/etc", dest, CHASE_PREFIX_ROOT, &etc, NULL);
if (r < 0) {
log_warning_errno(r, "Failed to resolve /etc path in container, ignoring: %m");
return 0;
@@ -2151,7 +2151,7 @@ static int setup_resolv_conf(const char *dest) {
_cleanup_free_ char *resolved = NULL;
int found;
- found = chase_symlinks(where, dest, CHASE_NONEXISTENT, &resolved, NULL);
+ found = chase(where, dest, CHASE_NONEXISTENT, &resolved, NULL);
if (found < 0) {
log_warning_errno(found, "Failed to resolve /etc/resolv.conf path in container, ignoring: %m");
return 0;
@@ -3094,7 +3094,7 @@ static int determine_names(void) {
return 0;
}
-static int chase_symlinks_and_update(char **p, unsigned flags) {
+static int chase_and_update(char **p, unsigned flags) {
char *chased;
int r;
@@ -3103,7 +3103,7 @@ static int chase_symlinks_and_update(char **p, unsigned flags) {
if (!*p)
return 0;
- r = chase_symlinks(*p, NULL, flags, &chased, NULL);
+ r = chase(*p, NULL, flags, &chased, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve path %s: %m", *p);
@@ -5534,7 +5534,7 @@ static int run(int argc, char *argv[]) {
if (arg_ephemeral) {
_cleanup_free_ char *np = NULL;
- r = chase_symlinks_and_update(&arg_directory, 0);
+ r = chase_and_update(&arg_directory, 0);
if (r < 0)
goto finish;
@@ -5585,7 +5585,7 @@ static int run(int argc, char *argv[]) {
free_and_replace(arg_directory, np);
remove_directory = true;
} else {
- r = chase_symlinks_and_update(&arg_directory, arg_template ? CHASE_NONEXISTENT : 0);
+ r = chase_and_update(&arg_directory, arg_template ? CHASE_NONEXISTENT : 0);
if (r < 0)
goto finish;
@@ -5600,7 +5600,7 @@ static int run(int argc, char *argv[]) {
}
if (arg_template) {
- r = chase_symlinks_and_update(&arg_template, 0);
+ r = chase_and_update(&arg_template, 0);
if (r < 0)
goto finish;
@@ -5676,7 +5676,7 @@ static int run(int argc, char *argv[]) {
assert(arg_image);
assert(!arg_template);
- r = chase_symlinks_and_update(&arg_image, 0);
+ r = chase_and_update(&arg_image, 0);
if (r < 0)
goto finish;
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 44c8384e1c..43f2901016 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -20,7 +20,7 @@
#include "blockdev-util.h"
#include "btrfs-util.h"
#include "build.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "conf-files.h"
#include "conf-parser.h"
#include "constants.h"
@@ -3828,7 +3828,7 @@ static int do_copy_files(Partition *p, const char *root, Hashmap *denylist) {
if (rfd < 0)
return rfd;
- sfd = chase_symlinks_and_open(*source, arg_root, CHASE_PREFIX_ROOT, O_PATH|O_DIRECTORY|O_CLOEXEC|O_NOCTTY, NULL);
+ sfd = chase_and_open(*source, arg_root, CHASE_PREFIX_ROOT, O_PATH|O_DIRECTORY|O_CLOEXEC|O_NOCTTY, NULL);
if (sfd < 0)
return log_error_errno(sfd, "Failed to open source file '%s%s': %m", strempty(arg_root), *source);
@@ -3842,7 +3842,7 @@ static int do_copy_files(Partition *p, const char *root, Hashmap *denylist) {
STRV_FOREACH_PAIR(source, target, p->copy_files) {
_cleanup_close_ int sfd = -EBADF, pfd = -EBADF, tfd = -EBADF;
- sfd = chase_symlinks_and_open(*source, arg_root, CHASE_PREFIX_ROOT, O_CLOEXEC|O_NOCTTY, NULL);
+ sfd = chase_and_open(*source, arg_root, CHASE_PREFIX_ROOT, O_CLOEXEC|O_NOCTTY, NULL);
if (sfd < 0)
return log_error_errno(sfd, "Failed to open source file '%s%s': %m", strempty(arg_root), *source);
@@ -3852,7 +3852,7 @@ static int do_copy_files(Partition *p, const char *root, Hashmap *denylist) {
return log_error_errno(r, "Failed to check type of source file '%s': %m", *source);
/* We are looking at a directory */
- tfd = chase_symlinks_and_open(*target, root, CHASE_PREFIX_ROOT, O_RDONLY|O_DIRECTORY|O_CLOEXEC, NULL);
+ tfd = chase_and_open(*target, root, CHASE_PREFIX_ROOT, O_RDONLY|O_DIRECTORY|O_CLOEXEC, NULL);
if (tfd < 0) {
_cleanup_free_ char *dn = NULL, *fn = NULL;
@@ -3871,7 +3871,7 @@ static int do_copy_files(Partition *p, const char *root, Hashmap *denylist) {
if (r < 0)
return log_error_errno(r, "Failed to create parent directory '%s': %m", dn);
- pfd = chase_symlinks_and_open(dn, root, CHASE_PREFIX_ROOT, O_RDONLY|O_DIRECTORY|O_CLOEXEC, NULL);
+ pfd = chase_and_open(dn, root, CHASE_PREFIX_ROOT, O_RDONLY|O_DIRECTORY|O_CLOEXEC, NULL);
if (pfd < 0)
return log_error_errno(pfd, "Failed to open parent directory of target: %m");
@@ -3911,7 +3911,7 @@ static int do_copy_files(Partition *p, const char *root, Hashmap *denylist) {
if (r < 0)
return log_error_errno(r, "Failed to create parent directory: %m");
- pfd = chase_symlinks_and_open(dn, root, CHASE_PREFIX_ROOT, O_RDONLY|O_DIRECTORY|O_CLOEXEC, NULL);
+ pfd = chase_and_open(dn, root, CHASE_PREFIX_ROOT, O_RDONLY|O_DIRECTORY|O_CLOEXEC, NULL);
if (pfd < 0)
return log_error_errno(pfd, "Failed to open parent directory of target: %m");
@@ -4042,7 +4042,7 @@ static int add_exclude_path(const char *path, Hashmap **denylist, DenyType type)
if (!st)
return log_oom();
- r = chase_symlinks_and_stat(path, arg_root, CHASE_PREFIX_ROOT, NULL, st);
+ r = chase_and_stat(path, arg_root, CHASE_PREFIX_ROOT, NULL, st);
if (r == -ENOENT)
return 0;
if (r < 0)
@@ -4908,7 +4908,7 @@ static int context_read_seed(Context *context, const char *root) {
if (!arg_randomize) {
_cleanup_close_ int fd = -EBADF;
- fd = chase_symlinks_and_open("/etc/machine-id", root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC, NULL);
+ fd = chase_and_open("/etc/machine-id", root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC, NULL);
if (fd == -ENOENT)
log_info("No machine ID set, using randomized partition UUIDs.");
else if (fd < 0)
@@ -5123,7 +5123,7 @@ static int find_backing_devno(
assert(path);
- r = chase_symlinks(path, root, CHASE_PREFIX_ROOT, &resolved, NULL);
+ r = chase(path, root, CHASE_PREFIX_ROOT, &resolved, NULL);
if (r < 0)
return r;
@@ -5297,7 +5297,7 @@ static int context_open_copy_block_paths(
if (p->copy_blocks_path) {
- source_fd = chase_symlinks_and_open(p->copy_blocks_path, p->copy_blocks_root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_NONBLOCK, &opened);
+ source_fd = chase_and_open(p->copy_blocks_path, p->copy_blocks_root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_NONBLOCK, &opened);
if (source_fd < 0)
return log_error_errno(source_fd, "Failed to open '%s': %m", p->copy_blocks_path);
@@ -6175,7 +6175,7 @@ static int acquire_root_devno(
assert(ret);
assert(ret_fd);
- fd = chase_symlinks_and_open(p, root, CHASE_PREFIX_ROOT, mode, &found_path);
+ fd = chase_and_open(p, root, CHASE_PREFIX_ROOT, mode, &found_path);
if (fd < 0)
return fd;
diff --git a/src/portable/portable.c b/src/portable/portable.c
index 664c873ca7..8a3211166e 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -4,7 +4,7 @@
#include "bus-common-errors.h"
#include "bus-error.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "conf-files.h"
#include "copy.h"
#include "data-fd-util.h"
@@ -244,7 +244,7 @@ static int extract_now(
_cleanup_free_ char *resolved = NULL;
_cleanup_closedir_ DIR *d = NULL;
- r = chase_symlinks_and_opendir(*i, where, 0, &resolved, &d);
+ r = chase_and_opendir(*i, where, 0, &resolved, &d);
if (r < 0) {
log_debug_errno(r, "Failed to open unit path '%s', ignoring: %m", *i);
continue;
diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c
index 6a638c35c5..d390a9295d 100644
--- a/src/portable/portablectl.c
+++ b/src/portable/portablectl.c
@@ -11,7 +11,7 @@
#include "bus-locator.h"
#include "bus-unit-util.h"
#include "bus-wait-for-jobs.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "constants.h"
#include "dirent-util.h"
#include "env-file.h"
@@ -84,7 +84,7 @@ static int determine_image(const char *image, bool permit_non_existing, char **r
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"Operations on images by path not supported when connecting to remote systems.");
- r = chase_symlinks(image, NULL, CHASE_TRAIL_SLASH | (permit_non_existing ? CHASE_NONEXISTENT : 0), ret, NULL);
+ r = chase(image, NULL, CHASE_TRAIL_SLASH | (permit_non_existing ? CHASE_NONEXISTENT : 0), ret, NULL);
if (r < 0)
return log_error_errno(r, "Cannot normalize specified image path '%s': %m", image);
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
index 9dddb0e289..0d8a8aa0f6 100644
--- a/src/shared/bootspec.c
+++ b/src/shared/bootspec.c
@@ -4,7 +4,7 @@
#include "bootspec-fundamental.h"
#include "bootspec.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "conf-files.h"
#include "devnum-util.h"
#include "dirent-util.h"
@@ -507,7 +507,7 @@ static int boot_loader_read_conf_path(BootConfig *config, const char *root, cons
assert(config);
assert(path);
- r = chase_symlinks_and_fopen_unlocked(path, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, "re", &full, &f);
+ r = chase_and_fopen_unlocked(path, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, "re", &full, &f);
if (r == -ENOENT)
return 0;
if (r < 0)
@@ -592,7 +592,7 @@ static int boot_entries_find_type1(
assert(root);
assert(dir);
- dir_fd = chase_symlinks_and_open(dir, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, O_DIRECTORY|O_CLOEXEC, &full);
+ dir_fd = chase_and_open(dir, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, O_DIRECTORY|O_CLOEXEC, &full);
if (dir_fd == -ENOENT)
return 0;
if (dir_fd < 0)
@@ -854,7 +854,7 @@ static int boot_entries_find_unified(
assert(config);
assert(dir);
- r = chase_symlinks_and_opendir(dir, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &full, &d);
+ r = chase_and_opendir(dir, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, &full, &d);
if (r == -ENOENT)
return 0;
if (r < 0)
@@ -1269,7 +1269,7 @@ static void boot_entry_file_list(
assert(p);
assert(ret_status);
- int status = chase_symlinks_and_access(p, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL);
+ int status = chase_and_access(p, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL);
/* Note that this shows two '/' between the root and the file. This is intentional to highlight (in
* the absence of color support) to the user that the boot loader is only interested in the second
diff --git a/src/shared/discover-image.c b/src/shared/discover-image.c
index 1f5b11f5f4..fa018cb912 100644
--- a/src/shared/discover-image.c
+++ b/src/shared/discover-image.c
@@ -14,7 +14,7 @@
#include "alloc-util.h"
#include "btrfs-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "chattr-util.h"
#include "copy.h"
#include "dirent-util.h"
@@ -459,7 +459,7 @@ int image_find(ImageClass class,
struct stat st;
int flags;
- r = chase_symlinks_and_opendir(path, root, CHASE_PREFIX_ROOT, &resolved, &d);
+ r = chase_and_opendir(path, root, CHASE_PREFIX_ROOT, &resolved, &d);
if (r == -ENOENT)
continue;
if (r < 0)
@@ -556,7 +556,7 @@ int image_discover(
_cleanup_free_ char *resolved = NULL;
_cleanup_closedir_ DIR *d = NULL;
- r = chase_symlinks_and_opendir(path, root, CHASE_PREFIX_ROOT, &resolved, &d);
+ r = chase_and_opendir(path, root, CHASE_PREFIX_ROOT, &resolved, &d);
if (r == -ENOENT)
continue;
if (r < 0)
@@ -1149,7 +1149,7 @@ int image_read_metadata(Image *i) {
_cleanup_free_ char *hostname = NULL;
_cleanup_free_ char *path = NULL;
- r = chase_symlinks("/etc/hostname", i->path, CHASE_PREFIX_ROOT|CHASE_TRAIL_SLASH, &path, NULL);
+ r = chase("/etc/hostname", i->path, CHASE_PREFIX_ROOT|CHASE_TRAIL_SLASH, &path, NULL);
if (r < 0 && r != -ENOENT)
log_debug_errno(r, "Failed to chase /etc/hostname in image %s: %m", i->name);
else if (r >= 0) {
@@ -1160,7 +1160,7 @@ int image_read_metadata(Image *i) {
path = mfree(path);
- r = chase_symlinks("/etc/machine-id", i->path, CHASE_PREFIX_ROOT|CHASE_TRAIL_SLASH, &path, NULL);
+ r = chase("/etc/machine-id", i->path, CHASE_PREFIX_ROOT|CHASE_TRAIL_SLASH, &path, NULL);
if (r < 0 && r != -ENOENT)
log_debug_errno(r, "Failed to chase /etc/machine-id in image %s: %m", i->name);
else if (r >= 0) {
@@ -1178,7 +1178,7 @@ int image_read_metadata(Image *i) {
path = mfree(path);
- r = chase_symlinks("/etc/machine-info", i->path, CHASE_PREFIX_ROOT|CHASE_TRAIL_SLASH, &path, NULL);
+ r = chase("/etc/machine-info", i->path, CHASE_PREFIX_ROOT|CHASE_TRAIL_SLASH, &path, NULL);
if (r < 0 && r != -ENOENT)
log_debug_errno(r, "Failed to chase /etc/machine-info in image %s: %m", i->name);
else if (r >= 0) {
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
index 2502e3a0eb..2920a51dc2 100644
--- a/src/shared/dissect-image.c
+++ b/src/shared/dissect-image.c
@@ -26,7 +26,7 @@
#include "blkid-util.h"
#include "blockdev-util.h"
#include "btrfs-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "conf-files.h"
#include "constants.h"
#include "copy.h"
@@ -1650,7 +1650,7 @@ static int mount_partition(
if (r < 0 && r != -EROFS)
return r;
- r = chase_symlinks(directory, where, CHASE_PREFIX_ROOT, &chased, NULL);
+ r = chase(directory, where, CHASE_PREFIX_ROOT, &chased, NULL);
if (r < 0)
return r;
@@ -1828,7 +1828,7 @@ int dissected_image_mount(
/* Mount the ESP to /efi if it exists. If it doesn't exist, use /boot instead, but only if it
* exists and is empty, and we didn't already mount the XBOOTLDR partition into it. */
- r = chase_symlinks("/efi", where, CHASE_PREFIX_ROOT, NULL, NULL);
+ r = chase("/efi", where, CHASE_PREFIX_ROOT, NULL, NULL);
if (r < 0) {
if (r != -ENOENT)
return r;
@@ -1838,7 +1838,7 @@ int dissected_image_mount(
if (!xbootldr_mounted) {
_cleanup_free_ char *p = NULL;
- r = chase_symlinks("/boot", where, CHASE_PREFIX_ROOT, &p, NULL);
+ r = chase("/boot", where, CHASE_PREFIX_ROOT, &p, NULL);
if (r < 0) {
if (r != -ENOENT)
return r;
@@ -3062,7 +3062,7 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
"/lib/systemd/systemd", /* systemd on /usr non-merged systems */
"/sbin/init") { /* traditional path the Linux kernel invokes */
- r = chase_symlinks(init, t, CHASE_PREFIX_ROOT, NULL, NULL);
+ r = chase(init, t, CHASE_PREFIX_ROOT, NULL, NULL);
if (r < 0) {
if (r != -ENOENT)
log_debug_errno(r, "Failed to resolve %s, ignoring: %m", init);
@@ -3081,7 +3081,7 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
default:
NULSTR_FOREACH(p, paths[k]) {
- fd = chase_symlinks_and_open(p, t, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
+ fd = chase_and_open(p, t, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
if (fd >= 0)
break;
}
diff --git a/src/shared/dropin.c b/src/shared/dropin.c
index 375a3ca600..d46e838044 100644
--- a/src/shared/dropin.c
+++ b/src/shared/dropin.c
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "conf-files.h"
#include "dirent-util.h"
#include "dropin.h"
@@ -105,7 +105,7 @@ static int unit_file_add_dir(
/* This adds [original_root]/path to dirs, if it exists. */
- r = chase_symlinks(path, original_root, 0, &chased, NULL);
+ r = chase(path, original_root, 0, &chased, NULL);
if (r == -ENOENT) /* Ignore -ENOENT, after all most units won't have a drop-in dir. */
return 0;
if (r == -ENAMETOOLONG) {
diff --git a/src/shared/find-esp.c b/src/shared/find-esp.c
index d474bb41a0..f6abe51de5 100644
--- a/src/shared/find-esp.c
+++ b/src/shared/find-esp.c
@@ -9,7 +9,7 @@
#include "alloc-util.h"
#include "blkid-util.h"
#include "btrfs-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "device-util.h"
#include "devnum-util.h"
#include "env-util.h"
@@ -457,7 +457,7 @@ int find_esp_and_warn(
*/
if (path) {
- r = chase_symlinks(path, root, CHASE_PREFIX_ROOT, &p, NULL);
+ r = chase(path, root, CHASE_PREFIX_ROOT, &p, NULL);
if (r < 0)
return log_error_errno(r,
"Failed to resolve path %s%s%s: %m",
@@ -476,7 +476,7 @@ int find_esp_and_warn(
if (path) {
struct stat st;
- r = chase_symlinks(path, root, CHASE_PREFIX_ROOT, &p, NULL);
+ r = chase(path, root, CHASE_PREFIX_ROOT, &p, NULL);
if (r < 0)
return log_error_errno(r,
"Failed to resolve path %s%s%s: %m",
@@ -513,7 +513,7 @@ int find_esp_and_warn(
}
FOREACH_STRING(dir, "/efi", "/boot", "/boot/efi") {
- r = chase_symlinks(dir, root, CHASE_PREFIX_ROOT, &p, NULL);
+ r = chase(dir, root, CHASE_PREFIX_ROOT, &p, NULL);
if (r == -ENOENT)
continue;
if (r < 0)
@@ -759,7 +759,7 @@ int find_xbootldr_and_warn(
/* Similar to find_esp_and_warn(), but finds the XBOOTLDR partition. Returns the same errors. */
if (path) {
- r = chase_symlinks(path, root, CHASE_PREFIX_ROOT, &p, NULL);
+ r = chase(path, root, CHASE_PREFIX_ROOT, &p, NULL);
if (r < 0)
return log_error_errno(r,
"Failed to resolve path %s%s%s: %m",
@@ -778,7 +778,7 @@ int find_xbootldr_and_warn(
if (path) {
struct stat st;
- r = chase_symlinks(path, root, CHASE_PREFIX_ROOT, &p, NULL);
+ r = chase(path, root, CHASE_PREFIX_ROOT, &p, NULL);
if (r < 0)
return log_error_errno(r,
"Failed to resolve path %s%s%s: %m",
@@ -804,7 +804,7 @@ int find_xbootldr_and_warn(
goto found;
}
- r = chase_symlinks("/boot", root, CHASE_PREFIX_ROOT, &p, NULL);
+ r = chase("/boot", root, CHASE_PREFIX_ROOT, &p, NULL);
if (r == -ENOENT)
return -ENOKEY;
if (r < 0)
diff --git a/src/shared/install.c b/src/shared/install.c
index 8060dcc251..79f9ea9b0e 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -10,7 +10,7 @@
#include <unistd.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "conf-files.h"
#include "conf-parser.h"
#include "constants.h"
@@ -686,7 +686,7 @@ static int remove_marked_symlinks_fd(
if (!found) {
_cleanup_free_ char *dest = NULL;
- q = chase_symlinks(p, lp->root_dir, CHASE_NONEXISTENT, &dest, NULL);
+ q = chase(p, lp->root_dir, CHASE_NONEXISTENT, &dest, NULL);
if (q == -ENOENT)
continue;
if (q < 0) {
@@ -1379,7 +1379,7 @@ static int unit_file_load(
if (!(flags & SEARCH_LOAD))
return 0;
- fd = chase_symlinks_and_open(path, root_dir, 0, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
+ fd = chase_and_open(path, root_dir, 0, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
if (fd < 0)
return fd;
}
@@ -1918,7 +1918,7 @@ static int install_info_symlink_alias(
if (!alias_path)
return -ENOMEM;
- q = chase_symlinks(alias_path, lp->root_dir, CHASE_NONEXISTENT, NULL, NULL);
+ q = chase(alias_path, lp->root_dir, CHASE_NONEXISTENT, NULL, NULL);
if (q < 0 && q != -ENOENT) {
r = r < 0 ? r : q;
continue;
diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c
index e583261f45..1eac51b81e 100644
--- a/src/shared/mount-util.c
+++ b/src/shared/mount-util.c
@@ -12,7 +12,7 @@
#endif
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "dissect-image.h"
#include "exec-util.h"
#include "extract-word.h"
@@ -844,7 +844,7 @@ static int mount_in_namespace(
if (r < 0)
return log_debug_errno(r == -ENOENT ? SYNTHETIC_ERRNO(EOPNOTSUPP) : r, "Target does not allow propagation of mount points");
- r = chase_symlinks(src, NULL, 0, &chased_src_path, &chased_src_fd);
+ r = chase(src, NULL, 0, &chased_src_path, &chased_src_fd);
if (r < 0)
return log_debug_errno(r, "Failed to resolve source path of %s: %m", src);
log_debug("Chased source path of %s to %s", src, chased_src_path);
diff --git a/src/shared/specifier.c b/src/shared/specifier.c
index 200e4ad9b8..65e555f716 100644
--- a/src/shared/specifier.c
+++ b/src/shared/specifier.c
@@ -10,7 +10,7 @@
#include "alloc-util.h"
#include "architecture.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "fd-util.h"
#include "format-util.h"
#include "fs-util.h"
@@ -134,7 +134,7 @@ int specifier_real_path(char specifier, const void *data, const char *root, cons
if (!path)
return -ENOENT;
- return chase_symlinks(path, root, 0, ret, NULL);
+ return chase(path, root, 0, ret, NULL);
}
int specifier_real_directory(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
@@ -190,7 +190,7 @@ int specifier_machine_id(char specifier, const void *data, const char *root, con
if (root) {
_cleanup_close_ int fd = -EBADF;
- fd = chase_symlinks_and_open("/etc/machine-id", root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
+ fd = chase_and_open("/etc/machine-id", root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
if (fd < 0)
/* Translate error for missing os-release file to EUNATCH. */
return fd == -ENOENT ? -EUNATCH : fd;
diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c
index 2aa30bd9f0..8dc93c2822 100644
--- a/src/shared/switch-root.c
+++ b/src/shared/switch-root.c
@@ -9,7 +9,7 @@
#include <unistd.h>
#include "base-filesystem.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "fd-util.h"
#include "initrd-util.h"
#include "log.h"
@@ -53,7 +53,7 @@ int switch_root(const char *new_root,
old_root_fd = safe_close(old_root_fd);
/* Determine where we shall place the old root after the transition */
- r = chase_symlinks(old_root_after, new_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved_old_root_after, NULL);
+ r = chase(old_root_after, new_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved_old_root_after, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve %s/%s: %m", new_root, old_root_after);
if (r == 0) /* Doesn't exist yet. Let's create it */
@@ -69,7 +69,7 @@ int switch_root(const char *new_root,
FOREACH_STRING(path, "/sys", "/dev", "/run", "/proc") {
_cleanup_free_ char *chased = NULL;
- r = chase_symlinks(path, new_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &chased, NULL);
+ r = chase(path, new_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &chased, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve %s/%s: %m", new_root, path);
if (r > 0) {
diff --git a/src/shared/uid-alloc-range.c b/src/shared/uid-alloc-range.c
index 1953119422..fe7f158c41 100644
--- a/src/shared/uid-alloc-range.c
+++ b/src/shared/uid-alloc-range.c
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include "chase-symlinks.h"
+#include "chase.h"
#include "fd-util.h"
#include "fileio.h"
#include "missing_threads.h"
@@ -40,7 +40,7 @@ int read_login_defs(UGIDAllocationRange *ret_defs, const char *path, const char
if (!path)
path = "/etc/login.defs";
- r = chase_symlinks_and_fopen_unlocked(path, root, CHASE_PREFIX_ROOT, "re", NULL, &f);
+ r = chase_and_fopen_unlocked(path, root, CHASE_PREFIX_ROOT, "re", NULL, &f);
if (r == -ENOENT)
goto defaults;
if (r < 0)
diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c
index bae4d9d023..ebd5a754c5 100644
--- a/src/shutdown/umount.c
+++ b/src/shutdown/umount.c
@@ -23,7 +23,7 @@
#include "alloc-util.h"
#include "blockdev-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "constants.h"
#include "device-util.h"
#include "dirent-util.h"
@@ -788,7 +788,7 @@ static int mount_points_list_umount(MountPoint **head, bool *changed, bool last_
* /run/shutdown/mounts from there.
*/
if (!resolved_mounts_path)
- (void) chase_symlinks("/run/shutdown/mounts", NULL, 0, &resolved_mounts_path, NULL);
+ (void) chase("/run/shutdown/mounts", NULL, 0, &resolved_mounts_path, NULL);
if (!path_equal(dirname, resolved_mounts_path)) {
char newpath[STRLEN("/run/shutdown/mounts/") + 16 + 1];
diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c
index 4553e90a50..539ab5e639 100644
--- a/src/sysext/sysext.c
+++ b/src/sysext/sysext.c
@@ -9,7 +9,7 @@
#include "build.h"
#include "capability-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "devnum-util.h"
#include "discover-image.h"
#include "dissect-image.h"
@@ -131,7 +131,7 @@ static int unmerge(void) {
STRV_FOREACH(p, arg_hierarchies) {
_cleanup_free_ char *resolved = NULL;
- r = chase_symlinks(*p, arg_root, CHASE_PREFIX_ROOT, &resolved, NULL);
+ r = chase(*p, arg_root, CHASE_PREFIX_ROOT, &resolved, NULL);
if (r == -ENOENT) {
log_debug_errno(r, "Hierarchy '%s%s' does not exist, ignoring.", strempty(arg_root), *p);
continue;
@@ -179,7 +179,7 @@ static int verb_status(int argc, char **argv, void *userdata) {
_cleanup_strv_free_ char **l = NULL;
struct stat st;
- r = chase_symlinks(*p, arg_root, CHASE_PREFIX_ROOT, &resolved, NULL);
+ r = chase(*p, arg_root, CHASE_PREFIX_ROOT, &resolved, NULL);
if (r == -ENOENT) {
log_debug_errno(r, "Hierarchy '%s%s' does not exist, ignoring.", strempty(arg_root), *p);
continue;
@@ -297,7 +297,7 @@ static int merge_hierarchy(
/* Resolve the path of the host's version of the hierarchy, i.e. what we want to use as lowest layer
* in the overlayfs stack. */
- r = chase_symlinks(hierarchy, arg_root, CHASE_PREFIX_ROOT, &resolved_hierarchy, NULL);
+ r = chase(hierarchy, arg_root, CHASE_PREFIX_ROOT, &resolved_hierarchy, NULL);
if (r == -ENOENT)
log_debug_errno(r, "Hierarchy '%s' on host doesn't exist, not merging.", hierarchy);
else if (r < 0)
@@ -336,7 +336,7 @@ static int merge_hierarchy(
STRV_FOREACH(p, paths) {
_cleanup_free_ char *resolved = NULL;
- r = chase_symlinks(hierarchy, *p, CHASE_PREFIX_ROOT, &resolved, NULL);
+ r = chase(hierarchy, *p, CHASE_PREFIX_ROOT, &resolved, NULL);
if (r == -ENOENT) {
log_debug_errno(r, "Hierarchy '%s' in extension '%s' doesn't exist, not merging.", hierarchy, *p);
continue;
@@ -428,7 +428,7 @@ static int validate_version(
/* Insist that extension images do not overwrite the underlying OS release file (it's fine if
* they place one in /etc/os-release, i.e. where things don't matter, as they aren't
* merged.) */
- r = chase_symlinks("/usr/lib/os-release", root, CHASE_PREFIX_ROOT, NULL, NULL);
+ r = chase("/usr/lib/os-release", root, CHASE_PREFIX_ROOT, NULL, NULL);
if (r < 0) {
if (r != -ENOENT)
return log_error_errno(r, "Failed to determine whether /usr/lib/os-release exists in the extension image: %m");
@@ -649,7 +649,7 @@ static int merge_subprocess(Hashmap *images, const char *workspace) {
STRV_FOREACH(h, arg_hierarchies) {
_cleanup_free_ char *resolved = NULL;
- r = chase_symlinks(*h, arg_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved, NULL);
+ r = chase(*h, arg_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve hierarchy '%s%s': %m", strempty(arg_root), *h);
@@ -691,7 +691,7 @@ static int merge_subprocess(Hashmap *images, const char *workspace) {
continue;
}
- r = chase_symlinks(*h, arg_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved, NULL);
+ r = chase(*h, arg_root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve hierarchy '%s%s': %m", strempty(arg_root), *h);
@@ -781,7 +781,7 @@ static int verb_merge(int argc, char **argv, void *userdata) {
STRV_FOREACH(p, arg_hierarchies) {
_cleanup_free_ char *resolved = NULL;
- r = chase_symlinks(*p, arg_root, CHASE_PREFIX_ROOT, &resolved, NULL);
+ r = chase(*p, arg_root, CHASE_PREFIX_ROOT, &resolved, NULL);
if (r == -ENOENT) {
log_debug_errno(r, "Hierarchy '%s%s' does not exist, ignoring.", strempty(arg_root), *p);
continue;
diff --git a/src/systemctl/systemctl-switch-root.c b/src/systemctl/systemctl-switch-root.c
index 5c71d3d97f..8cfcaf8935 100644
--- a/src/systemctl/systemctl-switch-root.c
+++ b/src/systemctl/systemctl-switch-root.c
@@ -3,7 +3,7 @@
#include "argv-util.h"
#include "bus-error.h"
#include "bus-locator.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "parse-util.h"
#include "path-util.h"
#include "proc-cmdline.h"
@@ -21,11 +21,11 @@ static int same_file_in_root(
struct stat sta, stb;
int r;
- r = chase_symlinks_and_stat(a, root, CHASE_PREFIX_ROOT, NULL, &sta);
+ r = chase_and_stat(a, root, CHASE_PREFIX_ROOT, NULL, &sta);
if (r < 0)
return r;
- r = chase_symlinks_and_stat(b, root, CHASE_PREFIX_ROOT, NULL, &stb);
+ r = chase_and_stat(b, root, CHASE_PREFIX_ROOT, NULL, &stb);
if (r < 0)
return r;
diff --git a/src/systemctl/systemctl-util.c b/src/systemctl/systemctl-util.c
index 6e87b18494..b6b28a113d 100644
--- a/src/systemctl/systemctl-util.c
+++ b/src/systemctl/systemctl-util.c
@@ -10,7 +10,7 @@
#include "bus-locator.h"
#include "bus-map-properties.h"
#include "bus-unit-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "dropin.h"
#include "env-util.h"
#include "exit-status.h"
@@ -422,7 +422,7 @@ int unit_file_find_path(LookupPaths *lp, const char *unit_name, char **ret_unit_
if (!path)
return log_oom();
- r = chase_symlinks(path, arg_root, 0, &lpath, NULL);
+ r = chase(path, arg_root, 0, &lpath, NULL);
if (r == -ENOENT)
continue;
if (r == -ENOMEM)
diff --git a/src/sysupdate/sysupdate-resource.c b/src/sysupdate/sysupdate-resource.c
index 6c05d245f8..c918de79cc 100644
--- a/src/sysupdate/sysupdate-resource.c
+++ b/src/sysupdate/sysupdate-resource.c
@@ -6,7 +6,7 @@
#include "alloc-util.h"
#include "blockdev-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "device-util.h"
#include "devnum-util.h"
#include "dirent-util.h"
@@ -563,7 +563,7 @@ int resource_resolve_path(
_cleanup_free_ char *resolved = NULL;
struct stat st;
- r = chase_symlinks(rr->path, root, CHASE_PREFIX_ROOT, &resolved, &fd);
+ r = chase(rr->path, root, CHASE_PREFIX_ROOT, &resolved, &fd);
if (r < 0)
return log_error_errno(r, "Failed to resolve '%s': %m", rr->path);
@@ -599,7 +599,7 @@ int resource_resolve_path(
} else if (RESOURCE_IS_FILESYSTEM(rr->type) && root) {
_cleanup_free_ char *resolved = NULL;
- r = chase_symlinks(rr->path, root, CHASE_PREFIX_ROOT, &resolved, NULL);
+ r = chase(rr->path, root, CHASE_PREFIX_ROOT, &resolved, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve '%s': %m", rr->path);
diff --git a/src/sysupdate/sysupdate-transfer.c b/src/sysupdate/sysupdate-transfer.c
index 0c3d65a00d..6789f48967 100644
--- a/src/sysupdate/sysupdate-transfer.c
+++ b/src/sysupdate/sysupdate-transfer.c
@@ -4,7 +4,7 @@
#include "alloc-util.h"
#include "blockdev-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "conf-parser.h"
#include "dirent-util.h"
#include "fd-util.h"
@@ -1211,7 +1211,7 @@ int transfer_install_instance(
assert_not_reached();
if (resolve_link_path && root) {
- r = chase_symlinks(link_path, root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved, NULL);
+ r = chase(link_path, root, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &resolved, NULL);
if (r < 0)
return log_error_errno(r, "Failed to resolve current symlink path '%s': %m", link_path);
diff --git a/src/sysupdate/sysupdate.c b/src/sysupdate/sysupdate.c
index 4ad901e080..6cb09dae50 100644
--- a/src/sysupdate/sysupdate.c
+++ b/src/sysupdate/sysupdate.c
@@ -6,7 +6,7 @@
#include "build.h"
#include "bus-error.h"
#include "bus-locator.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "conf-files.h"
#include "constants.h"
#include "dirent-util.h"
@@ -1106,7 +1106,7 @@ static int verb_components(int argc, char **argv, void *userdata) {
_cleanup_closedir_ DIR *d = NULL;
_cleanup_free_ char *p = NULL;
- r = chase_symlinks_and_opendir(*i, arg_root, CHASE_PREFIX_ROOT, &p, &d);
+ r = chase_and_opendir(*i, arg_root, CHASE_PREFIX_ROOT, &p, &d);
if (r == -ENOENT)
continue;
if (r < 0)
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 70abcfa131..f9f694bd54 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -5,7 +5,7 @@
#include "alloc-util.h"
#include "build.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "conf-files.h"
#include "constants.h"
#include "copy.h"
@@ -1571,7 +1571,7 @@ static int item_equivalent(Item *a, Item *b) {
!(is_nologin_shell(a_shell) && is_nologin_shell(b_shell))) {
_cleanup_free_ char *pa = NULL, *pb = NULL;
- r = chase_symlinks(a_shell, arg_root, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &pa, NULL);
+ r = chase(a_shell, arg_root, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &pa, NULL);
if (r < 0) {
log_full_errno(ERRNO_IS_RESOURCE(r) ? LOG_ERR : LOG_DEBUG,
r, "Failed to look up path '%s%s%s': %m",
@@ -1579,7 +1579,7 @@ static int item_equivalent(Item *a, Item *b) {
return ERRNO_IS_RESOURCE(r) ? r : false;
}
- r = chase_symlinks(b_shell, arg_root, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &pb, NULL);
+ r = chase(b_shell, arg_root, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &pb, NULL);
if (r < 0) {
log_full_errno(ERRNO_IS_RESOURCE(r) ? LOG_ERR : LOG_DEBUG,
r, "Failed to look up path '%s%s%s': %m",
diff --git a/src/test/meson.build b/src/test/meson.build
index 8d815edea5..e93851790e 100644
--- a/src/test/meson.build
+++ b/src/test/meson.build
@@ -263,7 +263,7 @@ tests += [
'base' : test_core_base,
},
{
- 'sources' : files('test-chase-symlinks.c'),
+ 'sources' : files('test-chase.c'),
'type' : 'manual',
},
{
diff --git a/src/test/test-chase-symlinks.c b/src/test/test-chase.c
index d94173f27b..d65fbe1d74 100644
--- a/src/test/test-chase-symlinks.c
+++ b/src/test/test-chase.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <getopt.h>
-#include "chase-symlinks.h"
+#include "chase.h"
#include "fd-util.h"
#include "log.h"
#include "main-func.h"
@@ -97,7 +97,7 @@ static int run(int argc, char **argv) {
printf("%s ", argv[i]);
fflush(stdout);
- r = chase_symlinks(argv[i], arg_root, arg_flags, &p, arg_open ? &fd : NULL);
+ r = chase(argv[i], arg_root, arg_flags, &p, arg_open ? &fd : NULL);
if (r < 0)
log_error_errno(r, "failed: %m");
else {
diff --git a/src/test/test-copy.c b/src/test/test-copy.c
index d3f37ea9e3..4cd83dbeea 100644
--- a/src/test/test-copy.c
+++ b/src/test/test-copy.c
@@ -4,7 +4,7 @@
#include <unistd.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "copy.h"
#include "fd-util.h"
#include "fileio.h"
@@ -224,7 +224,7 @@ TEST(copy_tree) {
assert_se(f = strjoin(original_dir, *p));
assert_se(l = strjoin(copy_dir, *ll));
- assert_se(chase_symlinks(l, NULL, 0, &target, NULL) == 1);
+ assert_se(chase(l, NULL, 0, &target, NULL) == 1);
assert_se(path_equal(f, target));
}
diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c
index 0f942f6dcb..d79d9603d3 100644
--- a/src/test/test-fs-util.c
+++ b/src/test/test-fs-util.c
@@ -3,7 +3,7 @@
#include <unistd.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "copy.h"
#include "dirent-util.h"
#include "fd-util.h"
@@ -28,7 +28,7 @@
static const char *arg_test_dir = NULL;
-TEST(chase_symlinks) {
+TEST(chase) {
_cleanup_free_ char *result = NULL, *pwd = NULL;
_cleanup_close_ int pfd = -EBADF;
char *temp;
@@ -66,45 +66,45 @@ TEST(chase_symlinks) {
/* Paths that use symlinks underneath the "root" */
- r = chase_symlinks(p, NULL, 0, &result, NULL);
+ r = chase(p, NULL, 0, &result, NULL);
assert_se(r > 0);
assert_se(path_equal(result, "/usr"));
result = mfree(result);
pslash = strjoina(p, "/");
- r = chase_symlinks(pslash, NULL, 0, &result, NULL);
+ r = chase(pslash, NULL, 0, &result, NULL);
assert_se(r > 0);
assert_se(path_equal(result, "/usr/"));
result = mfree(result);
- r = chase_symlinks(p, temp, 0, &result, NULL);
+ r = chase(p, temp, 0, &result, NULL);
assert_se(r == -ENOENT);
- r = chase_symlinks(pslash, temp, 0, &result, NULL);
+ r = chase(pslash, temp, 0, &result, NULL);
assert_se(r == -ENOENT);
q = strjoina(temp, "/usr");
- r = chase_symlinks(p, temp, CHASE_NONEXISTENT, &result, NULL);
+ r = chase(p, temp, CHASE_NONEXISTENT, &result, NULL);
assert_se(r == 0);
assert_se(path_equal(result, q));
result = mfree(result);
qslash = strjoina(q, "/");
- r = chase_symlinks(pslash, temp, CHASE_NONEXISTENT, &result, NULL);
+ r = chase(pslash, temp, CHASE_NONEXISTENT, &result, NULL);
assert_se(r == 0);
assert_se(path_equal(result, qslash));
result = mfree(result);
assert_se(mkdir(q, 0700) >= 0);
- r = chase_symlinks(p, temp, 0, &result, NULL);
+ r = chase(p, temp, 0, &result, NULL);
assert_se(r > 0);
assert_se(path_equal(result, q));
result = mfree(result);
- r = chase_symlinks(pslash, temp, 0, &result, NULL);
+ r = chase(pslash, temp, 0, &result, NULL);
assert_se(r > 0);
assert_se(path_equal(result, qslash));
result = mfree(result);
@@ -112,12 +112,12 @@ TEST(chase_symlinks) {
p = strjoina(temp, "/slash");
assert_se(symlink("/", p) >= 0);
- r = chase_symlinks(p, NULL, 0, &result, NULL);
+ r = chase(p, NULL, 0, &result, NULL);
assert_se(r > 0);
assert_se(path_equal(result, "/"));
result = mfree(result);
- r = chase_symlinks(p, temp, 0, &result, NULL);
+ r = chase(p, temp, 0, &result, NULL);
assert_se(r > 0);
assert_se(path_equal(result, temp));
result = mfree(result);
@@ -127,21 +127,21 @@ TEST(chase_symlinks) {
p = strjoina(temp, "/6dots");
assert_se(symlink("../../..", p) >= 0);
- r = chase_symlinks(p, temp, 0, &result, NULL);
+ r = chase(p, temp, 0, &result, NULL);
assert_se(r > 0 && path_equal(result, temp));
result = mfree(result);
p = strjoina(temp, "/6dotsusr");
assert_se(symlink("../../../usr", p) >= 0);
- r = chase_symlinks(p, temp, 0, &result, NULL);
+ r = chase(p, temp, 0, &result, NULL);
assert_se(r > 0 && path_equal(result, q));
result = mfree(result);
p = strjoina(temp, "/top/8dotsusr");
assert_se(symlink("../../../../usr", p) >= 0);
- r = chase_symlinks(p, temp, 0, &result, NULL);
+ r = chase(p, temp, 0, &result, NULL);
assert_se(r > 0 && path_equal(result, q));
result = mfree(result);
@@ -150,13 +150,13 @@ TEST(chase_symlinks) {
p = strjoina(temp, "/slashslash");
assert_se(symlink("///usr///", p) >= 0);
- r = chase_symlinks(p, NULL, 0, &result, NULL);
+ r = chase(p, NULL, 0, &result, NULL);
assert_se(r > 0);
assert_se(path_equal(result, "/usr"));
assert_se(streq(result, "/usr")); /* we guarantee that we drop redundant slashes */
result = mfree(result);
- r = chase_symlinks(p, temp, 0, &result, NULL);
+ r = chase(p, temp, 0, &result, NULL);
assert_se(r > 0);
assert_se(path_equal(result, q));
result = mfree(result);
@@ -175,48 +175,48 @@ TEST(chase_symlinks) {
assert_se(symlink("/", p) >= 0);
/* Fail when user-owned directories contain root-owned subdirectories. */
- r = chase_symlinks(p, temp, CHASE_SAFE, &result, NULL);
+ r = chase(p, temp, CHASE_SAFE, &result, NULL);
assert_se(r == -ENOLINK);
result = mfree(result);
/* Allow this when the user-owned directories are all in the "root". */
- r = chase_symlinks(p, q, CHASE_SAFE, &result, NULL);
+ r = chase(p, q, CHASE_SAFE, &result, NULL);
assert_se(r > 0);
result = mfree(result);
}
/* Paths using . */
- r = chase_symlinks("/etc/./.././", NULL, 0, &result, NULL);
+ r = chase("/etc/./.././", NULL, 0, &result, NULL);
assert_se(r > 0);
assert_se(path_equal(result, "/"));
result = mfree(result);
- r = chase_symlinks("/etc/./.././", "/etc", 0, &result, NULL);
+ r = chase("/etc/./.././", "/etc", 0, &result, NULL);
assert_se(r > 0 && path_equal(result, "/etc"));
result = mfree(result);
- r = chase_symlinks("/../.././//../../etc", NULL, 0, &result, NULL);
+ r = chase("/../.././//../../etc", NULL, 0, &result, NULL);
assert_se(r > 0);
assert_se(streq(result, "/etc"));
result = mfree(result);
- r = chase_symlinks("/../.././//../../test-chase.fsldajfl", NULL, CHASE_NONEXISTENT, &result, NULL);
+ r = chase("/../.././//../../test-chase.fsldajfl", NULL, CHASE_NONEXISTENT, &result, NULL);
assert_se(r == 0);
assert_se(streq(result, "/test-chase.fsldajfl"));
result = mfree(result);
- r = chase_symlinks("/../.././//../../etc", "/", CHASE_PREFIX_ROOT, &result, NULL);
+ r = chase("/../.././//../../etc", "/", CHASE_PREFIX_ROOT, &result, NULL);
assert_se(r > 0);
assert_se(streq(result, "/etc"));
result = mfree(result);
- r = chase_symlinks("/../.././//../../test-chase.fsldajfl", "/", CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &result, NULL);
+ r = chase("/../.././//../../test-chase.fsldajfl", "/", CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &result, NULL);
assert_se(r == 0);
assert_se(streq(result, "/test-chase.fsldajfl"));
result = mfree(result);
- r = chase_symlinks("/etc/machine-id/foo", NULL, 0, &result, NULL);
+ r = chase("/etc/machine-id/foo", NULL, 0, &result, NULL);
assert_se(IN_SET(r, -ENOTDIR, -ENOENT));
result = mfree(result);
@@ -224,25 +224,25 @@ TEST(chase_symlinks) {
p = strjoina(temp, "/recursive-symlink");
assert_se(symlink("recursive-symlink", p) >= 0);
- r = chase_symlinks(p, NULL, 0, &result, NULL);
+ r = chase(p, NULL, 0, &result, NULL);
assert_se(r == -ELOOP);
/* Path which doesn't exist */
p = strjoina(temp, "/idontexist");
- r = chase_symlinks(p, NULL, 0, &result, NULL);
+ r = chase(p, NULL, 0, &result, NULL);
assert_se(r == -ENOENT);
- r = chase_symlinks(p, NULL, CHASE_NONEXISTENT, &result, NULL);
+ r = chase(p, NULL, CHASE_NONEXISTENT, &result, NULL);
assert_se(r == 0);
assert_se(path_equal(result, p));
result = mfree(result);
p = strjoina(temp, "/idontexist/meneither");
- r = chase_symlinks(p, NULL, 0, &result, NULL);
+ r = chase(p, NULL, 0, &result, NULL);
assert_se(r == -ENOENT);
- r = chase_symlinks(p, NULL, CHASE_NONEXISTENT, &result, NULL);
+ r = chase(p, NULL, CHASE_NONEXISTENT, &result, NULL);
assert_se(r == 0);
assert_se(path_equal(result, p));
result = mfree(result);
@@ -254,7 +254,7 @@ TEST(chase_symlinks) {
assert_se(chdir(temp) >= 0);
p = "this/is/a/relative/path";
- r = chase_symlinks(p, NULL, CHASE_NONEXISTENT, &result, NULL);
+ r = chase(p, NULL, CHASE_NONEXISTENT, &result, NULL);
assert_se(r == 0);
p = strjoina(temp, "/", p);
@@ -262,7 +262,7 @@ TEST(chase_symlinks) {
result = mfree(result);
p = "this/is/a/relative/path";
- r = chase_symlinks(p, temp, CHASE_NONEXISTENT, &result, NULL);
+ r = chase(p, temp, CHASE_NONEXISTENT, &result, NULL);
assert_se(r == 0);
p = strjoina(temp, "/", p);
@@ -274,17 +274,17 @@ TEST(chase_symlinks) {
/* Path which doesn't exist, but contains weird stuff */
p = strjoina(temp, "/idontexist/..");
- r = chase_symlinks(p, NULL, 0, &result, NULL);
+ r = chase(p, NULL, 0, &result, NULL);
assert_se(r == -ENOENT);
- r = chase_symlinks(p, NULL, CHASE_NONEXISTENT, &result, NULL);
+ r = chase(p, NULL, CHASE_NONEXISTENT, &result, NULL);
assert_se(r == -ENOENT);
p = strjoina(temp, "/target");
q = strjoina(temp, "/top");
assert_se(symlink(q, p) >= 0);
p = strjoina(temp, "/target/idontexist");
- r = chase_symlinks(p, NULL, 0, &result, NULL);
+ r = chase(p, NULL, 0, &result, NULL);
assert_se(r == -ENOENT);
if (geteuid() == 0) {
@@ -294,29 +294,29 @@ TEST(chase_symlinks) {
q = strjoina(p, "/priv2");
assert_se(mkdir(q, 0755) >= 0);
- assert_se(chase_symlinks(q, NULL, CHASE_SAFE, NULL, NULL) >= 0);
+ assert_se(chase(q, NULL, CHASE_SAFE, NULL, NULL) >= 0);
assert_se(chown(q, UID_NOBODY, GID_NOBODY) >= 0);
- assert_se(chase_symlinks(q, NULL, CHASE_SAFE, NULL, NULL) >= 0);
+ assert_se(chase(q, NULL, CHASE_SAFE, NULL, NULL) >= 0);
assert_se(chown(p, UID_NOBODY, GID_NOBODY) >= 0);
- assert_se(chase_symlinks(q, NULL, CHASE_SAFE, NULL, NULL) >= 0);
+ assert_se(chase(q, NULL, CHASE_SAFE, NULL, NULL) >= 0);
assert_se(chown(q, 0, 0) >= 0);
- assert_se(chase_symlinks(q, NULL, CHASE_SAFE, NULL, NULL) == -ENOLINK);
+ assert_se(chase(q, NULL, CHASE_SAFE, NULL, NULL) == -ENOLINK);
assert_se(rmdir(q) >= 0);
assert_se(symlink("/etc/passwd", q) >= 0);
- assert_se(chase_symlinks(q, NULL, CHASE_SAFE, NULL, NULL) == -ENOLINK);
+ assert_se(chase(q, NULL, CHASE_SAFE, NULL, NULL) == -ENOLINK);
assert_se(chown(p, 0, 0) >= 0);
- assert_se(chase_symlinks(q, NULL, CHASE_SAFE, NULL, NULL) >= 0);
+ assert_se(chase(q, NULL, CHASE_SAFE, NULL, NULL) >= 0);
}
p = strjoina(temp, "/machine-id-test");
assert_se(symlink("/usr/../etc/./machine-id", p) >= 0);
- r = chase_symlinks(p, NULL, 0, NULL, &pfd);
+ r = chase(p, NULL, 0, NULL, &pfd);
if (r != -ENOENT && sd_id128_get_machine(NULL) >= 0) {
_cleanup_close_ int fd = -EBADF;
sd_id128_t a, b;
@@ -333,7 +333,7 @@ TEST(chase_symlinks) {
}
assert_se(lstat(p, &st) >= 0);
- r = chase_symlinks_and_unlink(p, NULL, 0, 0, &result);
+ r = chase_and_unlink(p, NULL, 0, 0, &result);
assert_se(r == 0);
assert_se(path_equal(result, p));
result = mfree(result);
@@ -344,7 +344,7 @@ TEST(chase_symlinks) {
p = strjoina(temp, "/target");
q = strjoina(temp, "/symlink");
assert_se(symlink(p, q) >= 0);
- r = chase_symlinks(q, NULL, CHASE_NOFOLLOW, &result, &pfd);
+ r = chase(q, NULL, CHASE_NOFOLLOW, &result, &pfd);
assert_se(r >= 0);
assert_se(pfd >= 0);
assert_se(path_equal(result, q));
@@ -358,7 +358,7 @@ TEST(chase_symlinks) {
assert_se(symlink("s2", q) >= 0);
p = strjoina(temp, "/s2");
assert_se(symlink("nonexistent", p) >= 0);
- r = chase_symlinks(q, NULL, CHASE_NOFOLLOW, &result, &pfd);
+ r = chase(q, NULL, CHASE_NOFOLLOW, &result, &pfd);
assert_se(r >= 0);
assert_se(pfd >= 0);
assert_se(path_equal(result, q));
@@ -370,42 +370,42 @@ TEST(chase_symlinks) {
/* Test CHASE_STEP */
p = strjoina(temp, "/start");
- r = chase_symlinks(p, NULL, CHASE_STEP, &result, NULL);
+ r = chase(p, NULL, CHASE_STEP, &result, NULL);
assert_se(r == 0);
p = strjoina(temp, "/top/dot/dotdota");
assert_se(streq(p, result));
result = mfree(result);
- r = chase_symlinks(p, NULL, CHASE_STEP, &result, NULL);
+ r = chase(p, NULL, CHASE_STEP, &result, NULL);
assert_se(r == 0);
p = strjoina(temp, "/top/dotdota");
assert_se(streq(p, result));
result = mfree(result);
- r = chase_symlinks(p, NULL, CHASE_STEP, &result, NULL);
+ r = chase(p, NULL, CHASE_STEP, &result, NULL);
assert_se(r == 0);
p = strjoina(temp, "/top/../a");
assert_se(streq(p, result));
result = mfree(result);
- r = chase_symlinks(p, NULL, CHASE_STEP, &result, NULL);
+ r = chase(p, NULL, CHASE_STEP, &result, NULL);
assert_se(r == 0);
p = strjoina(temp, "/a");
assert_se(streq(p, result));
result = mfree(result);
- r = chase_symlinks(p, NULL, CHASE_STEP, &result, NULL);
+ r = chase(p, NULL, CHASE_STEP, &result, NULL);
assert_se(r == 0);
p = strjoina(temp, "/b");
assert_se(streq(p, result));
result = mfree(result);
- r = chase_symlinks(p, NULL, CHASE_STEP, &result, NULL);
+ r = chase(p, NULL, CHASE_STEP, &result, NULL);
assert_se(r == 0);
assert_se(streq("/usr", result));
result = mfree(result);
- r = chase_symlinks("/usr", NULL, CHASE_STEP, &result, NULL);
+ r = chase("/usr", NULL, CHASE_STEP, &result, NULL);
assert_se(r > 0);
assert_se(streq("/usr", result));
result = mfree(result);
@@ -414,25 +414,25 @@ TEST(chase_symlinks) {
p = strjoina("/etc/..", temp, "/self");
assert_se(symlink(".", p) >= 0);
q = strjoina(p, "/top/dot/dotdota");
- r = chase_symlinks(q, p, 0, &result, NULL);
+ r = chase(q, p, 0, &result, NULL);
assert_se(r > 0);
assert_se(path_equal(path_startswith(result, p), "usr"));
result = mfree(result);
/* Test CHASE_PROHIBIT_SYMLINKS */
- assert_se(chase_symlinks("top/dot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, NULL, NULL) == -EREMCHG);
- assert_se(chase_symlinks("top/dot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_WARN, NULL, NULL) == -EREMCHG);
- assert_se(chase_symlinks("top/dotdot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, NULL, NULL) == -EREMCHG);
- assert_se(chase_symlinks("top/dotdot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_WARN, NULL, NULL) == -EREMCHG);
- assert_se(chase_symlinks("top/dot/dot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, NULL, NULL) == -EREMCHG);
- assert_se(chase_symlinks("top/dot/dot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_WARN, NULL, NULL) == -EREMCHG);
+ assert_se(chase("top/dot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, NULL, NULL) == -EREMCHG);
+ assert_se(chase("top/dot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_WARN, NULL, NULL) == -EREMCHG);
+ assert_se(chase("top/dotdot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, NULL, NULL) == -EREMCHG);
+ assert_se(chase("top/dotdot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_WARN, NULL, NULL) == -EREMCHG);
+ assert_se(chase("top/dot/dot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, NULL, NULL) == -EREMCHG);
+ assert_se(chase("top/dot/dot", temp, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_WARN, NULL, NULL) == -EREMCHG);
cleanup:
assert_se(rm_rf(temp, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
}
-TEST(chase_symlinks_at) {
+TEST(chase_at) {
_cleanup_(rm_rf_physical_and_freep) char *t = NULL;
_cleanup_close_ int tfd = -EBADF, fd = -EBADF;
_cleanup_free_ char *result = NULL;
@@ -449,7 +449,7 @@ TEST(chase_symlinks_at) {
assert_se(symlinkat("/usr", tfd, "abc") >= 0);
p = strjoina(t, "/abc");
- assert_se(chase_symlinks_at(AT_FDCWD, p, CHASE_AT_RESOLVE_IN_ROOT, &result, NULL) >= 0);
+ assert_se(chaseat(AT_FDCWD, p, CHASE_AT_RESOLVE_IN_ROOT, &result, NULL) >= 0);
assert_se(streq(result, "/usr"));
result = mfree(result);
@@ -459,16 +459,16 @@ TEST(chase_symlinks_at) {
assert_se(fd = openat(tfd, "def", O_CREAT|O_CLOEXEC, 0700) >= 0);
fd = safe_close(fd);
assert_se(symlinkat("/def", tfd, "qed") >= 0);
- assert_se(chase_symlinks_at(tfd, "qed", CHASE_AT_RESOLVE_IN_ROOT, &result, NULL) >= 0);
+ assert_se(chaseat(tfd, "qed", CHASE_AT_RESOLVE_IN_ROOT, &result, NULL) >= 0);
assert_se(streq(result, "def"));
result = mfree(result);
- assert_se(chase_symlinks_at(tfd, "/qed", CHASE_AT_RESOLVE_IN_ROOT, &result, NULL) >= 0);
+ assert_se(chaseat(tfd, "/qed", CHASE_AT_RESOLVE_IN_ROOT, &result, NULL) >= 0);
assert_se(streq(result, "def"));
result = mfree(result);
/* Valid directory file descriptor without CHASE_AT_RESOLVE_IN_ROOT should resolve symlinks against
* host's root. */
- assert_se(chase_symlinks_at(tfd, "/qed", 0, NULL, NULL) == -ENOENT);
+ assert_se(chaseat(tfd, "/qed", 0, NULL, NULL) == -ENOENT);
/* Test CHASE_PARENT */
@@ -480,115 +480,115 @@ TEST(chase_symlinks_at) {
* symlink target and not the symlink itself. But if we add CHASE_NOFOLLOW, we get the parent
* directory of the symlink itself. */
- assert_se(chase_symlinks_at(tfd, "chase/parent", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT, &result, &fd) >= 0);
+ assert_se(chaseat(tfd, "chase/parent", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT, &result, &fd) >= 0);
assert_se(faccessat(fd, "def", F_OK, 0) >= 0);
assert_se(streq(result, "def"));
fd = safe_close(fd);
result = mfree(result);
- assert_se(chase_symlinks_at(tfd, "chase/parent", CHASE_AT_RESOLVE_IN_ROOT|CHASE_PARENT|CHASE_NOFOLLOW, &result, &fd) >= 0);
+ assert_se(chaseat(tfd, "chase/parent", CHASE_AT_RESOLVE_IN_ROOT|CHASE_PARENT|CHASE_NOFOLLOW, &result, &fd) >= 0);
assert_se(faccessat(fd, "parent", F_OK, AT_SYMLINK_NOFOLLOW) >= 0);
assert_se(streq(result, "chase/parent"));
fd = safe_close(fd);
result = mfree(result);
- assert_se(chase_symlinks_at(tfd, "chase", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT, &result, &fd) >= 0);
+ assert_se(chaseat(tfd, "chase", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT, &result, &fd) >= 0);
assert_se(faccessat(fd, "chase", F_OK, 0) >= 0);
assert_se(streq(result, "chase"));
fd = safe_close(fd);
result = mfree(result);
- assert_se(chase_symlinks_at(tfd, "/", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT, &result, NULL) >= 0);
+ assert_se(chaseat(tfd, "/", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT, &result, NULL) >= 0);
assert_se(streq(result, "."));
result = mfree(result);
- assert_se(chase_symlinks_at(tfd, ".", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT, &result, NULL) >= 0);
+ assert_se(chaseat(tfd, ".", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT, &result, NULL) >= 0);
assert_se(streq(result, "."));
result = mfree(result);
/* Test CHASE_MKDIR_0755 */
- assert_se(chase_symlinks_at(tfd, "m/k/d/i/r", CHASE_MKDIR_0755|CHASE_NONEXISTENT, &result, NULL) >= 0);
+ assert_se(chaseat(tfd, "m/k/d/i/r", CHASE_MKDIR_0755|CHASE_NONEXISTENT, &result, NULL) >= 0);
assert_se(faccessat(tfd, "m/k/d/i", F_OK, 0) >= 0);
assert_se(RET_NERRNO(faccessat(tfd, "m/k/d/i/r", F_OK, 0)) == -ENOENT);
assert_se(streq(result, "m/k/d/i/r"));
result = mfree(result);
- assert_se(chase_symlinks_at(tfd, "m/../q", CHASE_MKDIR_0755|CHASE_NONEXISTENT, &result, NULL) >= 0);
+ assert_se(chaseat(tfd, "m/../q", CHASE_MKDIR_0755|CHASE_NONEXISTENT, &result, NULL) >= 0);
assert_se(faccessat(tfd, "m", F_OK, 0) >= 0);
assert_se(RET_NERRNO(faccessat(tfd, "q", F_OK, 0)) == -ENOENT);
assert_se(streq(result, "q"));
result = mfree(result);
- assert_se(chase_symlinks_at(tfd, "i/../p", CHASE_MKDIR_0755, NULL, NULL) == -ENOENT);
+ assert_se(chaseat(tfd, "i/../p", CHASE_MKDIR_0755, NULL, NULL) == -ENOENT);
/* Test CHASE_FILENAME */
- assert_se(chase_symlinks_at(tfd, "chase/parent", CHASE_AT_RESOLVE_IN_ROOT|CHASE_PARENT|CHASE_NOFOLLOW|CHASE_EXTRACT_FILENAME, &result, &fd) >= 0);
+ assert_se(chaseat(tfd, "chase/parent", CHASE_AT_RESOLVE_IN_ROOT|CHASE_PARENT|CHASE_NOFOLLOW|CHASE_EXTRACT_FILENAME, &result, &fd) >= 0);
assert_se(faccessat(fd, result, F_OK, AT_SYMLINK_NOFOLLOW) >= 0);
assert_se(streq(result, "parent"));
fd = safe_close(fd);
result = mfree(result);
- assert_se(chase_symlinks_at(tfd, "chase", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT|CHASE_EXTRACT_FILENAME, &result, &fd) >= 0);
+ assert_se(chaseat(tfd, "chase", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT|CHASE_EXTRACT_FILENAME, &result, &fd) >= 0);
assert_se(faccessat(fd, result, F_OK, 0) >= 0);
assert_se(streq(result, "chase"));
fd = safe_close(fd);
result = mfree(result);
- assert_se(chase_symlinks_at(tfd, "/", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT|CHASE_EXTRACT_FILENAME, &result, NULL) >= 0);
+ assert_se(chaseat(tfd, "/", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT|CHASE_EXTRACT_FILENAME, &result, NULL) >= 0);
assert_se(streq(result, "."));
result = mfree(result);
- assert_se(chase_symlinks_at(tfd, ".", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT|CHASE_EXTRACT_FILENAME, &result, NULL) >= 0);
+ assert_se(chaseat(tfd, ".", CHASE_PARENT|CHASE_AT_RESOLVE_IN_ROOT|CHASE_EXTRACT_FILENAME, &result, NULL) >= 0);
assert_se(streq(result, "."));
result = mfree(result);
- /* Test chase_symlinks_at_and_open() */
+ /* Test chase_and_openat() */
- fd = chase_symlinks_at_and_open(tfd, "o/p/e/n/f/i/l/e", CHASE_MKDIR_0755, O_CREAT|O_EXCL|O_CLOEXEC, NULL);
+ fd = chase_and_openat(tfd, "o/p/e/n/f/i/l/e", CHASE_MKDIR_0755, O_CREAT|O_EXCL|O_CLOEXEC, NULL);
assert_se(fd >= 0);
assert_se(fd_verify_regular(fd) >= 0);
fd = safe_close(fd);
- fd = chase_symlinks_at_and_open(tfd, "o/p/e/n/d/i/r", CHASE_MKDIR_0755, O_DIRECTORY|O_CREAT|O_EXCL|O_CLOEXEC, NULL);
+ fd = chase_and_openat(tfd, "o/p/e/n/d/i/r", CHASE_MKDIR_0755, O_DIRECTORY|O_CREAT|O_EXCL|O_CLOEXEC, NULL);
assert_se(fd >= 0);
assert_se(fd_verify_directory(fd) >= 0);
fd = safe_close(fd);
- /* Test chase_symlinks_at_and_opendir() */
+ /* Test chase_and_openatdir() */
- assert_se(chase_symlinks_at_and_opendir(tfd, "o/p/e/n/d/i", 0, &result, &dir) >= 0);
+ assert_se(chase_and_opendirat(tfd, "o/p/e/n/d/i", 0, &result, &dir) >= 0);
FOREACH_DIRENT(de, dir, assert_not_reached())
assert_se(streq(de->d_name, "r"));
assert_se(streq(result, "o/p/e/n/d/i"));
result = mfree(result);
- /* Test chase_symlinks_at_and_stat() */
+ /* Test chase_at_and_stat() */
- assert_se(chase_symlinks_at_and_stat(tfd, "o/p", 0, &result, &st) >= 0);
+ assert_se(chase_and_statat(tfd, "o/p", 0, &result, &st) >= 0);
assert_se(stat_verify_directory(&st) >= 0);
assert_se(streq(result, "o/p"));
result = mfree(result);
- /* Test chase_symlinks_at_and_access() */
+ /* Test chase_at_and_access() */
- assert_se(chase_symlinks_at_and_access(tfd, "o/p/e", 0, F_OK, &result) >= 0);
+ assert_se(chase_and_accessat(tfd, "o/p/e", 0, F_OK, &result) >= 0);
assert_se(streq(result, "o/p/e"));
result = mfree(result);
- /* Test chase_symlinks_at_and_fopen_unlocked() */
+ /* Test chase_at_and_fopen_unlocked() */
- assert_se(chase_symlinks_at_and_fopen_unlocked(tfd, "o/p/e/n/f/i/l/e", 0, "re", &result, &f) >= 0);
+ assert_se(chase_and_fopenat_unlocked(tfd, "o/p/e/n/f/i/l/e", 0, "re", &result, &f) >= 0);
assert_se(fread(&(char[1]) {}, 1, 1, f) == 0);
assert_se(feof(f));
f = safe_fclose(f);
assert_se(streq(result, "o/p/e/n/f/i/l/e"));
result = mfree(result);
- /* Test chase_symlinks_at_and_unlink() */
+ /* Test chase_at_and_unlink() */
- assert_se(chase_symlinks_at_and_unlink(tfd, "o/p/e/n/f/i/l/e", 0, 0, &result) >= 0);
+ assert_se(chase_and_unlinkat(tfd, "o/p/e/n/f/i/l/e", 0, 0, &result) >= 0);
assert_se(streq(result, "o/p/e/n/f/i/l/e"));
result = mfree(result);
}
diff --git a/src/tmpfiles/offline-passwd.c b/src/tmpfiles/offline-passwd.c
index fe866f8ca1..edf0dfb73d 100644
--- a/src/tmpfiles/offline-passwd.c
+++ b/src/tmpfiles/offline-passwd.c
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#include "chase-symlinks.h"
+#include "chase.h"
#include "fd-util.h"
#include "offline-passwd.h"
#include "path-util.h"
@@ -13,7 +13,7 @@ static int open_passwd_file(const char *root, const char *fname, FILE **ret_file
_cleanup_close_ int fd = -EBADF;
_cleanup_fclose_ FILE *f = NULL;
- fd = chase_symlinks_and_open(fname, root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC, &p);
+ fd = chase_and_open(fname, root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC, &p);
if (fd < 0)
return fd;
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 73beff063b..c3741088c3 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -22,7 +22,7 @@
#include "btrfs-util.h"
#include "build.h"
#include "capability-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "chattr-util.h"
#include "conf-files.h"
#include "constants.h"
@@ -982,7 +982,7 @@ static int path_open_parent_safe(const char *path, bool allow_failure) {
path,
allow_failure ? ", ignoring" : "");
- r = chase_symlinks(dn, arg_root, allow_failure ? CHASE_SAFE : CHASE_SAFE|CHASE_WARN, NULL, &fd);
+ r = chase(dn, arg_root, allow_failure ? CHASE_SAFE : CHASE_SAFE|CHASE_WARN, NULL, &fd);
if (r == -ENOLINK) /* Unsafe symlink: already covered by CHASE_WARN */
return r;
if (r < 0)
@@ -1007,7 +1007,7 @@ static int path_open_safe(const char *path) {
if (!path_is_normalized(path))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to open invalid path '%s'.", path);
- r = chase_symlinks(path, arg_root, CHASE_SAFE|CHASE_WARN|CHASE_NOFOLLOW, NULL, &fd);
+ r = chase(path, arg_root, CHASE_SAFE|CHASE_WARN|CHASE_NOFOLLOW, NULL, &fd);
if (r == -ENOLINK)
return r; /* Unsafe symlink: already covered by CHASE_WARN */
if (r < 0)
@@ -1824,7 +1824,7 @@ static int empty_directory(Item *i, const char *path, CreationMode creation) {
assert(i);
assert(i->type == EMPTY_DIRECTORY);
- r = chase_symlinks(path, arg_root, CHASE_SAFE|CHASE_WARN, NULL, &fd);
+ r = chase(path, arg_root, CHASE_SAFE|CHASE_WARN, NULL, &fd);
if (r == -ENOLINK) /* Unsafe symlink: already covered by CHASE_WARN */
return r;
if (r == -ENOENT) {
@@ -2789,7 +2789,7 @@ static int process_item(Item *i, OperationMask operation) {
path = _path;
}
- r = chase_symlinks(path, arg_root, CHASE_NO_AUTOFS|CHASE_NONEXISTENT|CHASE_WARN, NULL, NULL);
+ r = chase(path, arg_root, CHASE_NO_AUTOFS|CHASE_NONEXISTENT|CHASE_WARN, NULL, NULL);
if (r == -EREMOTE) {
log_notice_errno(r, "Skipping %s", i->path); /* We log the configured path, to not confuse the user. */
return 0;
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index a48d5dedf8..5e2b69d6f7 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -23,7 +23,7 @@
#include <linux/pci_regs.h>
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "device-private.h"
#include "device-util.h"
#include "dirent-util.h"
diff --git a/src/udev/udevadm-wait.c b/src/udev/udevadm-wait.c
index 544c94616d..0ec7099eb0 100644
--- a/src/udev/udevadm-wait.c
+++ b/src/udev/udevadm-wait.c
@@ -6,7 +6,7 @@
#include "sd-event.h"
#include "alloc-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "device-monitor-private.h"
#include "device-util.h"
#include "errno-util.h"
diff --git a/src/volatile-root/volatile-root.c b/src/volatile-root/volatile-root.c
index bf0b1decb4..27be7bdf56 100644
--- a/src/volatile-root/volatile-root.c
+++ b/src/volatile-root/volatile-root.c
@@ -4,7 +4,7 @@
#include "alloc-util.h"
#include "blockdev-util.h"
-#include "chase-symlinks.h"
+#include "chase.h"
#include "devnum-util.h"
#include "escape.h"
#include "main-func.h"
@@ -21,7 +21,7 @@ static int make_volatile(const char *path) {
assert(path);
- r = chase_symlinks("/usr", path, CHASE_PREFIX_ROOT, &old_usr, NULL);
+ r = chase("/usr", path, CHASE_PREFIX_ROOT, &old_usr, NULL);
if (r < 0)
return log_error_errno(r, "/usr not available in old root: %m");