}
if (ok) {
if (S_ISDIR(sb.st_mode)) {
- if ((sb.st_mode & ALLPERMS) != iolog_dirmode)
- ignore_result(chmod(path, iolog_dirmode));
if (sb.st_uid != iolog_uid || sb.st_gid != iolog_gid)
ignore_result(chown(path, iolog_uid, iolog_gid));
+ if ((sb.st_mode & ALLPERMS) != iolog_dirmode)
+ ignore_result(chmod(path, iolog_dirmode));
} else {
sudo_warnx(U_("%s exists but is not a directory (0%o)"),
path, (unsigned int) sb.st_mode);
ok = false;
} else {
ignore_result(chown(path, iolog_uid, iolog_gid));
+ ignore_result(chmod(path, iolog_dirmode));
}
}
if (uid_changed) {
}
sudo_lock_file(fd, SUDO_LOCK);
ignore_result(fchown(fd, iolog_uid, iolog_gid));
+ ignore_result(fchmod(fd, iolog_filemode));
/*
* If there is no seq file in iolog_dir and a fallback dir was
}
if (fd2 != -1) {
ignore_result(fchown(fd2, iolog_uid, gid));
+ ignore_result(fchmod(fd2, iolog_filemode));
nread = read(fd2, buf, sizeof(buf) - 1);
if (nread > 0) {
if (buf[nread - 1] == '\n')
}
if (fd != -1) {
ignore_result(fchown(fd, iolog_uid, iolog_gid));
+ ignore_result(fchmod(fd, iolog_filemode));
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
#ifdef HAVE_ZLIB_H
if (docompress)
debug_return_bool(false);
}
ignore_result(fchown(fd, iolog_uid, iolog_gid));
+ ignore_result(fchmod(fd, iolog_filemode));
fprintf(fp, "%lld:%s:%s:%s:%s:%d:%d\n%s\n%s", (long long)now->tv_sec,
details->user ? details->user : "unknown", details->runas_pw->pw_name,
if (mkdir(path, mode) == 0) {
if (uid != (uid_t)-1 && gid != (gid_t)-1)
ignore_result(chown(path, uid, gid));
+ ignore_result(chmod(path, mode));
} else {
if (errno != EEXIST) {
if (!quiet)
sudo_warn(U_("unable to stat %s"), path);
goto bad;
}
- if (!S_ISDIR(sb.st_mode)) {
+ 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 (!quiet)
sudo_warnx(U_("%s exists but is not a directory (0%o)"),
path, (unsigned int) sb.st_mode);