dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
594167
From 77cde7d38bf8cd3438a867a6330c314f4580e43b Mon Sep 17 00:00:00 2001
594167
From: Yu Watanabe <watanabe.yu+github@gmail.com>
594167
Date: Wed, 2 Feb 2022 14:20:48 +0900
594167
Subject: [PATCH] mkdir: allow to create directory whose path contains symlink
594167
594167
Fixes a regression caused by 3008a6f21c1c42efe852d69798a2fdd63fe657ec.
594167
594167
Before the commit, when `mkdir_parents_internal()` is called from `mkdir_p()`,
594167
it uses `_mkdir()` as `flag` is zero. But after the commit, `mkdir_safe_internal()`
594167
is always used. Hence, if the path contains a symlink, it fails with -ENOTDIR.
594167
594167
To fix the issue, this makes `mkdir_p()` calls `mkdir_parents_internal()` with
594167
MKDIR_FOLLOW_SYMLINK flag.
594167
594167
Fixes #22334.
594167
594167
(cherry picked from commit 5117059ee9f84ed2fd37801ec0b90473db475422)
594167
594167
Related: #2017035
594167
---
594167
 src/basic/mkdir.c | 2 +-
594167
 1 file changed, 1 insertion(+), 1 deletion(-)
594167
594167
diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c
594167
index 6e2b94d024..88782ab0d4 100644
594167
--- a/src/basic/mkdir.c
594167
+++ b/src/basic/mkdir.c
594167
@@ -162,7 +162,7 @@ int mkdir_p_internal(const char *prefix, const char *path, mode_t mode, uid_t ui
594167
 
594167
         assert(_mkdirat != mkdirat);
594167
 
594167
-        r = mkdir_parents_internal(prefix, path, mode, uid, gid, flags, _mkdirat);
594167
+        r = mkdir_parents_internal(prefix, path, mode, uid, gid, flags | MKDIR_FOLLOW_SYMLINK, _mkdirat);
594167
         if (r < 0)
594167
                 return r;
594167