ok = false;
} else {
ignore_result(chown(path, iolog_uid, iolog_gid));
- ignore_result(chmod(path, iolog_dirmode));
}
}
if (uid_changed) {
char buf[32], *ep;
int i, len, fd = -1;
unsigned long id = 0;
+ mode_t omask;
ssize_t nread;
bool ret = false;
char pathbuf[PATH_MAX];
static const char b36char[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
debug_decl(io_nextid, SUDOERS_DEBUG_UTIL)
+ /* umask must not be more restrictive than the file modes. */
+ omask = umask(ACCESSPERMS & ~(iolog_filemode|iolog_dirmode));
+
/*
* Create I/O log directory if it doesn't already exist.
*/
}
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, iolog_gid));
- ignore_result(fchmod(fd2, iolog_filemode));
nread = read(fd2, buf, sizeof(buf) - 1);
if (nread > 0) {
if (buf[nread - 1] == '\n')
ret = true;
done:
+ umask(omask);
if (fd != -1)
close(fd);
debug_return_bool(ret);
}
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,
char * const *cur;
const char *cp, *plugin_path = NULL;
size_t len;
+ mode_t omask;
int i, ret = -1;
debug_decl(sudoers_io_open, SUDOERS_DEBUG_PLUGIN)
continue;
}
}
+
+ /* umask must not be more restrictive than the file modes. */
+ omask = umask(ACCESSPERMS & ~(iolog_filemode|iolog_dirmode));
+
if (!sudoers_debug_register(plugin_path, &debug_files)) {
ret = -1;
goto done;
ret = true;
done:
+ umask(omask);
free(tofree);
if (iolog_details.runas_pw)
sudo_pw_delref(iolog_details.runas_pw);
mode_t parent_mode, bool quiet)
{
bool ret;
+ mode_t omask;
debug_decl(ts_mkdirs, SUDOERS_DEBUG_AUTH)
+ /* umask must not be more restrictive than the file modes. */
+ omask = umask(ACCESSPERMS & ~(mode|parent_mode));
ret = sudo_mkdir_parents(path, owner, group, parent_mode, quiet);
if (ret) {
/* Create final path component. */
ignore_result(chown(path, owner, group));
}
}
+ umask(omask);
debug_return_bool(ret);
}