]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
chase-symlinks: refuse more chase_symlink() flags in the open/stat flavours
authorLennart Poettering <lennart@poettering.net>
Mon, 22 Aug 2022 09:33:52 +0000 (11:33 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 22 Aug 2022 18:25:00 +0000 (19:25 +0100)
These flags make no sense when we try to access the final inode, hence
refuse.

src/basic/chase-symlinks.c

index a5d89e134974193957f92243e35dfa52cec88f01..ce50ff972619d883508ae9a971a389adcb3501d3 100644 (file)
@@ -417,7 +417,7 @@ int chase_symlinks_and_open(
         _cleanup_free_ char *p = NULL;
         int r;
 
-        if (chase_flags & CHASE_NONEXISTENT)
+        if (chase_flags & (CHASE_NONEXISTENT|CHASE_STEP))
                 return -EINVAL;
 
         if (empty_or_root(root) && !ret_path && (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE)) == 0) {
@@ -458,7 +458,7 @@ int chase_symlinks_and_opendir(
 
         if (!ret_dir)
                 return -EINVAL;
-        if (chase_flags & CHASE_NONEXISTENT)
+        if (chase_flags & (CHASE_NONEXISTENT|CHASE_STEP))
                 return -EINVAL;
 
         if (empty_or_root(root) && !ret_path && (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE)) == 0) {
@@ -502,7 +502,7 @@ int chase_symlinks_and_stat(
         assert(path);
         assert(ret_stat);
 
-        if (chase_flags & CHASE_NONEXISTENT)
+        if (chase_flags & (CHASE_NONEXISTENT|CHASE_STEP))
                 return -EINVAL;
 
         if (empty_or_root(root) && !ret_path && (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE)) == 0 && !ret_fd) {