]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
chase-symlinks: Rename chase_symlinks() to chase()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 21 Mar 2023 20:17:22 +0000 (21:17 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 24 Mar 2023 12:43:51 +0000 (13:43 +0100)
Chasing symlinks is a core function that's used in a lot of places
so it deservers a less verbose names so let's rename it to chase()
and chaseat().

We also slightly change the pattern used for the chaseat() helpers
so we get chase_and_openat() and similar.

64 files changed:
TODO
src/basic/chase.c [moved from src/basic/chase-symlinks.c with 92% similarity]
src/basic/chase.h [moved from src/basic/chase-symlinks.h with 52% similarity]
src/basic/conf-files.c
src/basic/devnum-util.c
src/basic/fileio.c
src/basic/meson.build
src/basic/mkdir.c
src/basic/mountpoint-util.c
src/basic/os-util.c
src/basic/path-util.c
src/basic/stat-util.c
src/basic/unit-file.c
src/basic/user-util.c
src/boot/bootctl-install.c
src/boot/bootctl-status.c
src/boot/pcrphase.c
src/core/dbus-manager.c
src/core/execute.c
src/core/namespace.c
src/core/service.c
src/core/socket.c
src/core/unit.c
src/coredump/coredumpctl.c
src/delta/delta.c
src/dissect/dissect.c
src/firstboot/firstboot.c
src/fstab-generator/fstab-generator.c
src/journal/journalctl.c
src/libsystemd/sd-device/sd-device.c
src/mount/mount-tool.c
src/nspawn/nspawn-bind-user.c
src/nspawn/nspawn-mount.c
src/nspawn/nspawn.c
src/partition/repart.c
src/portable/portable.c
src/portable/portablectl.c
src/shared/bootspec.c
src/shared/discover-image.c
src/shared/dissect-image.c
src/shared/dropin.c
src/shared/find-esp.c
src/shared/install.c
src/shared/mount-util.c
src/shared/specifier.c
src/shared/switch-root.c
src/shared/uid-alloc-range.c
src/shutdown/umount.c
src/sysext/sysext.c
src/systemctl/systemctl-switch-root.c
src/systemctl/systemctl-util.c
src/sysupdate/sysupdate-resource.c
src/sysupdate/sysupdate-transfer.c
src/sysupdate/sysupdate.c
src/sysusers/sysusers.c
src/test/meson.build
src/test/test-chase.c [moved from src/test/test-chase-symlinks.c with 96% similarity]
src/test/test-copy.c
src/test/test-fs-util.c
src/tmpfiles/offline-passwd.c
src/tmpfiles/tmpfiles.c
src/udev/udev-builtin-net_id.c
src/udev/udevadm-wait.c
src/volatile-root/volatile-root.c

diff --git a/TODO b/TODO
index fd7c348f9a1b35f3ac167696a3f0717a9b9fcd5d..5d2390610eb6cdde360188d54a192be193cf89af 100644 (file)
--- 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
similarity index 92%
rename from src/basic/chase-symlinks.c
rename to src/basic/chase.c
index 3eb43ffa6221a21ef794b906d0d54a13553443fd..3d423e4f880b0d631bb4749abe427b0ce56ecdf2 100644 (file)
@@ -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;
 
similarity index 52%
rename from src/basic/chase-symlinks.h
rename to src/basic/chase.h
index de7910a5e67ac311ee21af7346f30ec1ade487b1..c94cbde8fef533bd84b8aee8a7163d4b1283dfcf 100644 (file)
@@ -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);
index d64277b806b163c4bb79c7105126c1b1cfd9d74c..215e7951dcc6234174c6d78347a8caf389b001ff 100644 (file)
@@ -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)
index bd1b4d6c3901f50d6967622ee6361bac639cf620..de02255eef6493c1af47adec44b2980827477444 100644 (file)
@@ -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) {
index c75981528eff3726479962ad5da9bf726b5dabfd..340f9b48607bc66833a63d9e4b5897ac0d71c491 100644 (file)
@@ -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"
index 5f616c18934f4e4383d7dd4cbe061930a5ebc74d..ee9433714019bf65226ce766b4463ce985902be1 100644 (file)
@@ -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',
index 2257a1452f82f56fe5be02d1b60b684a14df9d29..3b7cf7a0bf4c0d5b6f36378c77f9b7b54d8570ba 100644 (file)
@@ -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;
         }
index 24e38a34e82f6141464008c24dd918289560beaa..ad22894a59e9349d26e72b7cbd324b4016e05bd0 100644 (file)
@@ -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;
 
index bf844e5b7fe05776d61b2706ea67e5f4b7ea1640..c8b23b10e471c4d2073376792fbd91c075f1e81a 100644 (file)
@@ -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;
                         }
index 40a819d47d344fc7f1eab9a7645bca029effba6b..ae0b25d1551024ae0415cf476e5b22d71bbf0432 100644 (file)
@@ -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;
 
index 42cefed48d73e29b8f23dd8328adc51a3868459a..150605e86d592522c361a5b96f08e48d63058f69 100644 (file)
@@ -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;
 
index 1f79a2735e9f543d4b7ee6205868abf790c1a17c..70b7eb16063f3c64461c1b7c0f416b60271ac260 100644 (file)
@@ -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);
index 0a47947d34853e174227eb01582d0534b7c687a7..551e98b4272dfacd0fc8a74f9b9ea0beb560f81c 100644 (file)
@@ -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);
index 617d0abde0268af310a8546e0bbf9c56290a032d..dc7ea8c5ca66d2bf193e881d256a1d5b92fb7f95 100644 (file)
@@ -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)
index ce97b013cf5d784c6d046ee19abb252a33cd3f79..cc0c3ad34ad839a929b656478eafb46e422d3b3e 100644 (file)
@@ -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;
index 896e2486532c747b097f7f295ca6172d8ceffdcc..afa474c88342b987ff6669cb5d56759dc7d3b525 100644 (file)
@@ -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);
 
index ca65bbf106cd98e9f6da9a3c26e333fca69ef408..c88ef93443c97c263873e732bba9a433506757fc 100644 (file)
@@ -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);
index f8ac4705e77a1d87dcd6d493b83a69a3e21f3ac7..bfdd2026c673c89e05d78b70e3db0cae26b0ba29 100644 (file)
@@ -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;
 
index 90c0f8442040b1572d7c701e0c6255133f0a884b..c75a2cb29f6651e5b3f7fc5ad449cb691a04b57b 100644 (file)
@@ -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;
index f8f5d6b1ec8b698cddfeb0df747156638cb7c73e..21d1bf6595b9e675d3f4bbadd7d73b99a3785d93 100644 (file)
@@ -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,
index 307a8f206120ea7b14be70f2c7fef90b4d42a13b..6b153a92faa7e005ea1c4b30e42d40aaf51037fd 100644 (file)
@@ -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;
 
index a9dffdf2b9e7e5a93794113373af8861afb0a04c..0418593d251523ee317492d68f92ffa9df97467f 100644 (file)
@@ -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;
index 909ffc8d8b822f7901ca9b7d32e7ae30fd91a200..60da536d4eb2a01fc0e675fb324ab0e94a4d435b 100644 (file)
@@ -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);
 
index db6e957fc9d51ee9a083a641629033a29e0197ed..eee2111abaadbc9c808a02ae0c457de232e8fd7d 100644 (file)
@@ -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) {
index 2658b2da60f16929b3bcaa1fa8321136eefee306..ff00c4f567dcb7378fbe36323d7e870d8c9ebea4 100644 (file)
@@ -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)
index 8f3e6a12651f4ab8e44e038e0199c3306dd7cc5b..3973de893187624af1f5d18597236ceb6a391e54 100644 (file)
@@ -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);
index 28cd5f05f1fc8dfd8615d76cd28dbfca92b7fc1a..69effacaa2c2dcaaa8b3ebb8ba89334c9c100781 100644 (file)
@@ -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);
index 59736143bc0d8cfc450f231af5af9d6627109406..69b40e68ea2401a25d76bddb2383e08cedfd0a80 100644 (file)
@@ -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");
 
index 8c65ee346984aa50189b40e313fb970d760df2cc..e86ec3e75b1c07ef0e2f8a68f7b99a4dfcbf6499 100644 (file)
@@ -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");
 
index 5cb1cd55263e4fee4cfa4077ae0852d6f547de29..5f5d84bb9718c1545d19f194ddc760e710e85415 100644 (file)
@@ -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;
index 2e3c3c3072990e41460883b08b77d274daf366e4..0a8653033d0689c2968a9f192f3d72733d9a8a23 100644 (file)
@@ -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)
index f190239cad70a2dc78489edb8765014149a50a74..ac9dc5116e8d72c3d4819e4f246b8d6b5f736307 100644 (file)
@@ -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? */
index f872b2e8f6b01f410dcb6787aee80ff18ba2b861..9fbacb2713eae3e831c623bf53795310a730035f 100644 (file)
@@ -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;
 
index 44c8384e1cd918e0b980153b571a35c64100fd27..43f2901016fd47d3575534e8f1b5a4cff8d032f8 100644 (file)
@@ -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;
 
index 664c873ca7b8d23bbcf8a25468235ada8437fe39..8a3211166e8a55e1632214c28e2a99a7e36370ee 100644 (file)
@@ -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;
index 6a638c35c55e1328c1468a492ab72d1f0961c598..d390a9295d7504e586dc93bad71434ec825deb06 100644 (file)
@@ -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);
 
index 9dddb0e289c7955466339463e340f63a9d5e88bf..0d8a8aa0f67b0f09aad2c6b06c74e9626a4bca7f 100644 (file)
@@ -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
index 1f5b11f5f4050ede0d6c67eb50b56d9c2c3c5894..fa018cb9123cc12474d96b57111612a2c713fe15 100644 (file)
@@ -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) {
index 2502e3a0eb3f37a06c0dcb28b0b599a2c727be63..2920a51dc298f29529c3f1ee1950e092bb2902ad 100644 (file)
@@ -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;
                                 }
index 375a3ca600414e572cc2b1d7b4e93ba2c860c217..d46e8380440921994eac61837f7c519a8529633a 100644 (file)
@@ -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) {
index d474bb41a0785c7604508747421a4cac3f5f2778..f6abe51de5f61f8511685cac9cb0dbd5b069607d 100644 (file)
@@ -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)
index 8060dcc251439e49d48a726171e58e284a6cef02..79f9ea9b0eb8ea7ae828d42e96e62b61afc42899 100644 (file)
@@ -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;
index e583261f456fc4e35900e97accf3bd36cc9aacc6..1eac51b81eab9c457236835fefbb577eb6b78cb8 100644 (file)
@@ -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);
index 200e4ad9b86e217cadee8566ac6967659b450a7a..65e555f716da141079626f85eae636376cf29cfc 100644 (file)
@@ -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;
index 2aa30bd9f0213a8485e43be685a18f27e5407704..8dc93c28229937f20496217e5520dea96ec222a0 100644 (file)
@@ -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) {
index 195311942250965ac4b95db835f1e58a95c82cf0..fe7f158c41e4d8cde42ff083679d17589389a19a 100644 (file)
@@ -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)
index bae4d9d023b0d5c058f4ddf24fa95d2cb55a743c..ebd5a754c5cefbd9ee1ac9cb695c4dd92b66f1b7 100644 (file)
@@ -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];
 
index 4553e90a505064bc03e6847d12599a8cc2346dca..539ab5e639db31e141a58ff23bfa539fcdadd07f 100644 (file)
@@ -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;
index 5c71d3d97fc2cf5184237208861fde780a983503..8cfcaf89358406a16ef48c4c26af52544948e479 100644 (file)
@@ -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;
 
index 6e87b184943adb459086b8016d82d3b165744d6d..b6b28a113d85dc95150a5d5c5b656ce30fc5721f 100644 (file)
@@ -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)
index 6c05d245f8c473d52114e08b3126ac15a9924ac9..c918de79cc9e9c3d37800ad69691b7426082193a 100644 (file)
@@ -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);
 
index 0c3d65a00dcbe9fd826bdf6db07fe6a9626a30bf..6789f4896782f2d9070bdad014a02d982af0f57e 100644 (file)
@@ -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);
 
index 4ad901e0809255a0259537154bf425d3ee3cfb18..6cb09dae50d657690db15a3c2d24e8eededbe870 100644 (file)
@@ -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)
index 70abcfa1317429f223e28f558d802f3d62dd3967..f9f694bd5493e0eb4a4768d7923da943ffb0b55d 100644 (file)
@@ -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",
index 8d815edea5ac83feb75fdfe1702c4a16ae3e0538..e93851790e09f310c5efcdafc352eac8a18da388 100644 (file)
@@ -263,7 +263,7 @@ tests += [
                 'base' : test_core_base,
         },
         {
-                'sources' : files('test-chase-symlinks.c'),
+                'sources' : files('test-chase.c'),
                 'type' : 'manual',
         },
         {
similarity index 96%
rename from src/test/test-chase-symlinks.c
rename to src/test/test-chase.c
index d94173f27be55d8eb47a9f3c585279c8ca211dd7..d65fbe1d744597da30bb221d9a0e413bbe84761b 100644 (file)
@@ -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 {
index d3f37ea9e39b7d6ab1e366985321b9a2a7c00977..4cd83dbeeaab5f5927e101e40d899b6c641770bc 100644 (file)
@@ -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));
         }
 
index 0f942f6dcbb4cb495b1023ace385479bbd9e0bff..d79d9603d3c8ae9355ad7d50cfaba7addab2a6ab 100644 (file)
@@ -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);
 }
index fe866f8ca1b503f544fd3a9a1dd614a61da50332..edf0dfb73d636f1842dba441a68d9dd0d9bea254 100644 (file)
@@ -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;
 
index 73beff063b80ce12b921d917dded1375cef15c54..c3741088c34aed46173bd31dc71ee79aeb1b1702 100644 (file)
@@ -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;
index a48d5dedf8066cdcb87613235ce491ce7b7e9020..5e2b69d6f74d001ebec3df092789e5d7ebd8e79f 100644 (file)
@@ -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"
index 544c94616d590a0d005e99bbbb804689415beaee..0ec7099eb0197e0b0cd65bdd571ff13bb69af0b8 100644 (file)
@@ -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"
index bf0b1decb421f05a7256473476c60e0f4c4b1ccf..27be7bdf56fdbaed4c12f21da4661a5a39ed93d4 100644 (file)
@@ -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");