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

mkdir: use chase_symlinks_and_stat() where appropriate

This commit is contained in:
Lennart Poettering 2021-11-12 14:49:49 +01:00
parent c7e715096f
commit 1e146d7382

View File

@ -42,16 +42,13 @@ int mkdir_safe_internal(
if ((flags & MKDIR_FOLLOW_SYMLINK) && S_ISLNK(st.st_mode)) { if ((flags & MKDIR_FOLLOW_SYMLINK) && S_ISLNK(st.st_mode)) {
_cleanup_free_ char *p = NULL; _cleanup_free_ char *p = NULL;
r = chase_symlinks(path, NULL, CHASE_NONEXISTENT, &p, NULL); r = chase_symlinks_and_stat(path, NULL, CHASE_NONEXISTENT, &p, &st, NULL);
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) if (r == 0)
return mkdir_safe_internal(p, mode, uid, gid, return mkdir_safe_internal(p, mode, uid, gid,
flags & ~MKDIR_FOLLOW_SYMLINK, flags & ~MKDIR_FOLLOW_SYMLINK,
_mkdir); _mkdir);
if (lstat(p, &st) < 0)
return -errno;
} }
if (!S_ISDIR(st.st_mode)) if (!S_ISDIR(st.st_mode))