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