1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-03 01:17:45 +03:00

mkdir: chase_symlinks_and_stat() does not return 0

This reverts commits e22916e61d and
1e146d7382.
This commit is contained in:
Yu Watanabe 2022-08-26 07:50:32 +09:00
parent 4b544b5ffd
commit f1d93b84bc

View 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)