summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/basic/chase-symlinks.c15
-rw-r--r--src/basic/chase-symlinks.h4
-rw-r--r--src/basic/stat-util.c2
-rw-r--r--src/boot/bootctl-install.c2
-rw-r--r--src/boot/bootctl-status.c2
-rw-r--r--src/core/dbus-manager.c2
-rw-r--r--src/coredump/coredumpctl.c2
-rw-r--r--src/nspawn/nspawn-mount.c2
-rw-r--r--src/partition/repart.c2
-rw-r--r--src/shared/bootspec.c2
-rw-r--r--src/systemctl/systemctl-switch-root.c4
11 files changed, 16 insertions, 23 deletions
diff --git a/src/basic/chase-symlinks.c b/src/basic/chase-symlinks.c
index bf90ba23cc..1b434950e6 100644
--- a/src/basic/chase-symlinks.c
+++ b/src/basic/chase-symlinks.c
@@ -631,21 +631,19 @@ int chase_symlinks_and_stat(
const char *root,
ChaseSymlinksFlags chase_flags,
char **ret_path,
- struct stat *ret_stat,
- int *ret_fd) {
+ struct stat *ret_stat) {
_cleanup_close_ int path_fd = -EBADF;
_cleanup_free_ char *p = NULL;
int r;
assert(path);
- assert(ret_stat);
if (chase_flags & (CHASE_NONEXISTENT|CHASE_STEP))
return -EINVAL;
if (empty_or_root(root) && !ret_path &&
- (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0 && !ret_fd) {
+ (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)
@@ -664,8 +662,6 @@ int chase_symlinks_and_stat(
if (ret_path)
*ret_path = TAKE_PTR(p);
- if (ret_fd)
- *ret_fd = TAKE_FD(path_fd);
return 1;
}
@@ -675,8 +671,7 @@ int chase_symlinks_and_access(
const char *root,
ChaseSymlinksFlags chase_flags,
int access_mode,
- char **ret_path,
- int *ret_fd) {
+ char **ret_path) {
_cleanup_close_ int path_fd = -EBADF;
_cleanup_free_ char *p = NULL;
@@ -688,7 +683,7 @@ int chase_symlinks_and_access(
return -EINVAL;
if (empty_or_root(root) && !ret_path &&
- (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0 && !ret_fd) {
+ (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)
@@ -708,8 +703,6 @@ int chase_symlinks_and_access(
if (ret_path)
*ret_path = TAKE_PTR(p);
- if (ret_fd)
- *ret_fd = TAKE_FD(path_fd);
return 1;
}
diff --git a/src/basic/chase-symlinks.h b/src/basic/chase-symlinks.h
index 19acf9e4b5..26e8cfceca 100644
--- a/src/basic/chase-symlinks.h
+++ b/src/basic/chase-symlinks.h
@@ -33,8 +33,8 @@ int chase_symlinks(const char *path_with_prefix, const char *root, ChaseSymlinks
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 *ret_fd);
-int chase_symlinks_and_access(const char *path, const char *root, ChaseSymlinksFlags chase_flags, int access_mode, char **ret_path, int *ret_fd);
+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);
diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c
index 700e28f2c2..88b8346a0f 100644
--- a/src/basic/stat-util.c
+++ b/src/basic/stat-util.c
@@ -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, NULL);
+ r = chase_symlinks_and_stat(fn, root, CHASE_PREFIX_ROOT, NULL, &st);
if (r < 0)
return r;
diff --git a/src/boot/bootctl-install.c b/src/boot/bootctl-install.c
index 624b88abe3..1b86c7773e 100644
--- a/src/boot/bootctl-install.c
+++ b/src/boot/bootctl-install.c
@@ -663,7 +663,7 @@ static int install_variables(
return 0;
}
- r = chase_symlinks_and_access(path, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL, NULL);
+ r = chase_symlinks_and_access(path, esp_path, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL);
if (r == -ENOENT)
return 0;
if (r < 0)
diff --git a/src/boot/bootctl-status.c b/src/boot/bootctl-status.c
index e25cd963ae..ce97b013cf 100644
--- a/src/boot/bootctl-status.c
+++ b/src/boot/bootctl-status.c
@@ -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, NULL);
+ r = chase_symlinks_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
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 242a662bca..2198e73f24 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -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, NULL);
+ r = chase_symlinks_and_access(init, root, CHASE_PREFIX_ROOT, X_OK, NULL);
if (r == -EACCES)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
"Init binary %s is not executable.", init);
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c
index 4c312d0fbb..909ffc8d8b 100644
--- a/src/coredump/coredumpctl.c
+++ b/src/coredump/coredumpctl.c
@@ -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, NULL);
+ r = chase_symlinks_and_access(filename, arg_root, CHASE_PREFIX_ROOT, F_OK, &resolved);
if (r < 0)
return log_error_errno(r, "Cannot access \"%s%s\": %m", strempty(arg_root), filename);
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c
index ea54b23e08..f190239cad 100644
--- a/src/nspawn/nspawn-mount.c
+++ b/src/nspawn/nspawn-mount.c
@@ -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, NULL);
+ r = chase_symlinks_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;
diff --git a/src/partition/repart.c b/src/partition/repart.c
index e8f3cb7fe7..2b1fbbdae2 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -4021,7 +4021,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, NULL);
+ r = chase_symlinks_and_stat(path, arg_root, CHASE_PREFIX_ROOT, NULL, st);
if (r == -ENOENT)
return 0;
if (r < 0)
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
index 49fb34b4d6..9dddb0e289 100644
--- a/src/shared/bootspec.c
+++ b/src/shared/bootspec.c
@@ -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, NULL);
+ int status = chase_symlinks_and_access(p, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, F_OK, NULL);
/* Note that this shows two '/' between the root and the file. This is intentional to highlight (in
* the absence of color support) to the user that the boot loader is only interested in the second
diff --git a/src/systemctl/systemctl-switch-root.c b/src/systemctl/systemctl-switch-root.c
index 7fa8b26f59..5c71d3d97f 100644
--- a/src/systemctl/systemctl-switch-root.c
+++ b/src/systemctl/systemctl-switch-root.c
@@ -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, NULL);
+ r = chase_symlinks_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, NULL);
+ r = chase_symlinks_and_stat(b, root, CHASE_PREFIX_ROOT, NULL, &stb);
if (r < 0)
return r;