]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkdir: chase_symlinks_and_stat() does not return 0
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 25 Aug 2022 22:50:32 +0000 (07:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 19 Sep 2022 13:54:05 +0000 (22:54 +0900)
This reverts commits e22916e61d1fdb7b46918b605ebf783d9017f9d8 and
1e146d738232acbe7f72903e9c5e4d1166ea67f5.

src/basic/mkdir.c

index cd966cba9420662f2db007aab7d48326d5d0aa3d..c8ff342d0f7e45156f796bde8cc8d03ebe301f49 100644 (file)
@@ -19,7 +19,8 @@
 int mkdir_safe_internal(
                 const char *path,
                 mode_t mode,
-                uid_t uid, gid_t gid,
+                uid_t uid,
+                gid_t gid,
                 MkdirFlags flags,
                 mkdirat_func_t _mkdirat) {
 
@@ -42,13 +43,16 @@ int mkdir_safe_internal(
         if ((flags & MKDIR_FOLLOW_SYMLINK) && S_ISLNK(st.st_mode)) {
                 _cleanup_free_ char *p = NULL;
 
-                r = chase_symlinks_and_stat(path, NULL, 0, &p, &st, NULL);
+                r = chase_symlinks(path, NULL, CHASE_NONEXISTENT, &p, NULL);
                 if (r < 0)
                         return r;
                 if (r == 0)
                         return mkdir_safe_internal(p, mode, uid, gid,
                                                    flags & ~MKDIR_FOLLOW_SYMLINK,
                                                    _mkdirat);
+
+                if (lstat(p, &st) < 0)
+                        return -errno;
         }
 
         if (flags & MKDIR_IGNORE_EXISTING)