summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-03-17 10:06:13 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2023-03-21 16:08:35 +0100
commit88f2ee86012ac8accf31e806f2f682fc78a85304 (patch)
tree6da9fdeb4c8a54d709bf0051715c1605c3a9ba61 /src
parent63bfd52f48a772c86ff84e3a1ba1fcd19e0008f8 (diff)
downloadsystemd-88f2ee86012ac8accf31e806f2f682fc78a85304.tar.gz
chase-symlinks: Return zero from access() and stat() helpers
We never check if r > 0 when using these helpers, so let's just return zero like we usually do.
Diffstat (limited to 'src')
-rw-r--r--src/basic/chase-symlinks.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/basic/chase-symlinks.c b/src/basic/chase-symlinks.c
index 16d36693b1..2eb1701e44 100644
--- a/src/basic/chase-symlinks.c
+++ b/src/basic/chase-symlinks.c
@@ -667,14 +667,10 @@ int chase_symlinks_and_stat(
assert(ret_stat);
if (empty_or_root(root) && !ret_path &&
- (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0) {
+ (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0)
/* Shortcut this call if none of the special features of this call are requested */
-
- if (fstatat(AT_FDCWD, path, ret_stat, FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0) < 0)
- return -errno;
-
- return 1;
- }
+ 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);
if (r < 0)
@@ -687,7 +683,7 @@ int chase_symlinks_and_stat(
if (ret_path)
*ret_path = TAKE_PTR(p);
- return 1;
+ return 0;
}
int chase_symlinks_and_access(
@@ -705,14 +701,10 @@ int chase_symlinks_and_access(
assert(!(chase_flags & (CHASE_NONEXISTENT|CHASE_STEP)));
if (empty_or_root(root) && !ret_path &&
- (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0) {
+ (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0)
/* Shortcut this call if none of the special features of this call are requested */
-
- if (faccessat(AT_FDCWD, path, access_mode, FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0) < 0)
- return -errno;
-
- return 1;
- }
+ 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);
if (r < 0)
@@ -726,7 +718,7 @@ int chase_symlinks_and_access(
if (ret_path)
*ret_path = TAKE_PTR(p);
- return 1;
+ return 0;
}
int chase_symlinks_and_fopen_unlocked(