]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
chase: mask away CHASE_MUST_BE_REGULAR in chase_openat()
authorLennart Poettering <lennart@poettering.net>
Fri, 5 Sep 2025 12:12:37 +0000 (14:12 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Sep 2025 07:36:44 +0000 (09:36 +0200)
We pin the parent directory of the specified directory via CHASE_PARENT,
but if we do that we really should mask off CHASE_MUST_BE_REGULAR,
because a parent dir of course is a dir, nothing else. The
CHASE_MUST_BE_REGULAR after all should apply to the file created in that
dir, not to the parent.

src/basic/chase.c

index ddef19448741dc2e2eac9a9a849608e08116cc6b..af9bc7b823bfa07bfb8ae37bc9619003f1c3fc86 100644 (file)
@@ -796,7 +796,7 @@ int chase_and_open(
                                     /* xopen_flags = */ 0,
                                     MODE_INVALID);
 
-        r = chase(path, root, CHASE_PARENT|chase_flags, &p, &path_fd);
+        r = chase(path, root, (CHASE_PARENT|chase_flags)&~CHASE_MUST_BE_REGULAR, &p, &path_fd);
         if (r < 0)
                 return r;
         assert(path_fd >= 0);
@@ -1001,7 +1001,7 @@ int chase_and_openat(
                                     /* xopen_flags = */ 0,
                                     MODE_INVALID);
 
-        r = chaseat(dir_fd, path, chase_flags|CHASE_PARENT, &p, &path_fd);
+        r = chaseat(dir_fd, path, (chase_flags|CHASE_PARENT)&~CHASE_MUST_BE_REGULAR, &p, &path_fd);
         if (r < 0)
                 return r;