Create new files with the umask specified in sudoers.

This commit is contained in:
Todd C. Miller
2019-09-11 16:26:56 -06:00
parent d94798e5d0
commit ab9a2ecac2

View File

@@ -682,6 +682,7 @@ sudo_edit_copy_tfiles(struct command_details *command_details,
ssize_t nwritten, nread;
struct timespec ts;
struct stat sb;
mode_t oldmask;
debug_decl(sudo_edit_copy_tfiles, SUDO_DEBUG_EDIT)
/* Copy contents of temp files to real ones. */
@@ -725,8 +726,10 @@ sudo_edit_copy_tfiles(struct command_details *command_details,
}
switch_user(command_details->euid, command_details->egid,
command_details->ngroups, command_details->groups);
oldmask = umask(command_details->umask);
ofd = sudo_edit_open(tf[i].ofile, O_WRONLY|O_TRUNC|O_CREAT,
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, command_details);
umask(oldmask);
switch_user(ROOT_UID, user_details.egid,
user_details.ngroups, user_details.groups);
if (ofd == -1) {