2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 09:57:41 +00:00

In iolog_openat() enable the write bit on pre-existing files if needed.

This prevents problems caused by the change to strip the write bit
from the timing file when it is finished.
This commit is contained in:
Todd C. Miller 2020-05-19 13:14:31 -06:00
parent 7febc39137
commit c63ba01e0e

View File

@ -393,6 +393,17 @@ iolog_openat(int dfd, const char *path, int flags)
omask = umask(ACCESSPERMS & ~(iolog_filemode|iolog_dirmode));
}
fd = openat(dfd, path, flags, iolog_filemode);
if (fd == -1 && errno == EACCES) {
/* Enable write bit if it is missing. */
struct stat sb;
if (fstatat(dfd, path, &sb, 0) == 0) {
mode_t write_bits = iolog_filemode & (S_IWUSR|S_IWGRP|S_IWOTH);
if ((sb.st_mode & write_bits) != write_bits) {
if (fchmodat(dfd, path, iolog_filemode, 0) == 0)
fd = openat(dfd, path, flags, iolog_filemode);
}
}
}
if (fd == -1 && errno == EACCES) {
/* Try again as the I/O log owner (for NFS). */
if (io_swapids(false)) {