From 2caddff3f995e3b68c251f99bbdac3053db22666 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 21 Mar 2017 14:55:19 -0600 Subject: [PATCH] Don't set owner/mode on directories that already exist, only on newly-created ones. --- plugins/sudoers/mkdir_parents.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/plugins/sudoers/mkdir_parents.c b/plugins/sudoers/mkdir_parents.c index d49f93e24..87db53f15 100644 --- a/plugins/sudoers/mkdir_parents.c +++ b/plugins/sudoers/mkdir_parents.c @@ -66,14 +66,7 @@ sudo_mkdir_parents(char *path, uid_t uid, gid_t gid, mode_t mode, bool quiet) sudo_warn(U_("unable to stat %s"), path); goto bad; } - if (S_ISDIR(sb.st_mode)) { - if (uid != (uid_t)-1 && gid != (gid_t)-1) { - if (sb.st_uid != uid || sb.st_gid != uid) - ignore_result(chown(path, uid, uid)); - } - if ((sb.st_mode & ALLPERMS) != mode) - ignore_result(chmod(path, mode)); - } else { + if (!S_ISDIR(sb.st_mode)) { if (!quiet) sudo_warnx(U_("%s exists but is not a directory (0%o)"), path, (unsigned int) sb.st_mode); -- 2.40.0