{
ereport(LOG,
(errmsg("creating missing WAL directory \"%s\"", path)));
- if (mkdir(path, 0700) < 0)
+ if (mkdir(path, S_IRWXU) < 0)
ereport(FATAL,
(errmsg("could not create missing directory \"%s\": %m",
path)));
(errcode(ERRCODE_INVALID_NAME),
errmsg("relative path not allowed for COPY to file")));
- oumask = umask((mode_t) 022);
+ oumask = umask(S_IWGRP | S_IWOTH);
cstate->copy_file = AllocateFile(cstate->filename, PG_BINARY_W);
umask(oumask);
* Attempt to coerce target directory to safe permissions. If this fails,
* it doesn't exist or has the wrong owner.
*/
- if (chmod(location, 0700) != 0)
+ if (chmod(location, S_IRWXU) != 0)
{
if (errno == ENOENT)
ereport(ERROR,
* open the file to be read in
*/
text_to_cstring_buffer(filename, fnamebuf, sizeof(fnamebuf));
- fd = PathNameOpenFile(fnamebuf, O_RDONLY | PG_BINARY, 0666);
+ fd = PathNameOpenFile(fnamebuf, O_RDONLY | PG_BINARY, S_IRWXU);
if (fd < 0)
ereport(ERROR,
(errcode_for_file_access(),
* world-writable export files doesn't seem wise.
*/
text_to_cstring_buffer(filename, fnamebuf, sizeof(fnamebuf));
- oumask = umask((mode_t) 0022);
- fd = PathNameOpenFile(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC | PG_BINARY, 0666);
+ oumask = umask(S_IWGRP | S_IWOTH);
+ fd = PathNameOpenFile(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC | PG_BINARY,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
umask(oumask);
if (fd < 0)
ereport(ERROR,
/*
* for security, no dir or file created can be group or other accessible
*/
- umask((mode_t) 0077);
+ umask(S_IRWXG | S_IRWXO);
/*
* Fire up essential subsystems: memory management
progname, DEVNULL, strerror(errno));
ExitPostmaster(1);
}
- pmlog = open(pmlogname, O_CREAT | O_WRONLY | O_APPEND, 0600);
+ pmlog = open(pmlogname, O_CREAT | O_WRONLY | O_APPEND, S_IRUSR | S_IWUSR);
if (pmlog < 0)
{
write_stderr("%s: could not open log file \"%s/%s\": %s\n",
char *Log_directory = NULL;
char *Log_filename = NULL;
bool Log_truncate_on_rotation = false;
-int Log_file_mode = 0600;
+int Log_file_mode = S_IRUSR | S_IWUSR;
/*
* Globally visible state (used by elog.c)
/*
* Create log directory if not present; ignore errors
*/
- mkdir(Log_directory, 0700);
+ mkdir(Log_directory, S_IRWXU);
/*
* The initial logfile is created right in the postmaster, to verify that
* Note we do not let Log_file_mode disable IWUSR, since we certainly
* want to be able to write the files ourselves.
*/
- oumask = umask((mode_t) ((~(Log_file_mode | S_IWUSR)) & 0777));
+ oumask = umask((mode_t) ((~(Log_file_mode | S_IWUSR)) & (S_IRWXU | S_IRWXG | S_IRWXO)));
fh = fopen(filename, mode);
umask(oumask);
char fromfile[MAXPGPATH];
char tofile[MAXPGPATH];
- if (mkdir(todir, S_IRUSR | S_IWUSR | S_IXUSR) != 0)
+ if (mkdir(todir, S_IRWXU) != 0)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not create directory \"%s\": %m", todir)));
else
snprintf(gprofDirName, 32, "gprof/%d", (int) getpid());
- mkdir("gprof", 0777);
- mkdir(gprofDirName, 0777);
+ mkdir("gprof", S_IRWXU | S_IRWXG | S_IRWXO);
+ mkdir(gprofDirName, S_IRWXU | S_IRWXG | S_IRWXO);
chdir(gprofDirName);
}
#endif
else
strcpy(path, pg_data);
- if (mkdir_p(path, 0700) == 0)
+ if (mkdir_p(path, S_IRWXU) == 0)
return true;
fprintf(stderr, _("%s: could not create directory \"%s\": %s\n"),
snprintf(path, sizeof(path), "%s/postgresql.conf", pg_data);
writefile(path, conflines);
- chmod(path, 0600);
+ chmod(path, S_IRUSR | S_IWUSR);
free(conflines);
snprintf(path, sizeof(path), "%s/pg_hba.conf", pg_data);
writefile(path, conflines);
- chmod(path, 0600);
+ chmod(path, S_IRUSR | S_IWUSR);
free(conflines);
snprintf(path, sizeof(path), "%s/pg_ident.conf", pg_data);
writefile(path, conflines);
- chmod(path, 0600);
+ chmod(path, S_IRUSR | S_IWUSR);
free(conflines);
printf("\n");
- umask(077);
+ umask(S_IRWXG | S_IRWXO);
/*
* now we are starting to do real work, trap signals so we can clean up
pg_data);
fflush(stdout);
- if (chmod(pg_data, 0700) != 0)
+ if (chmod(pg_data, S_IRWXU) != 0)
{
fprintf(stderr, _("%s: could not change permissions of directory \"%s\": %s\n"),
progname, pg_data, strerror(errno));
xlog_dir);
fflush(stdout);
- if (mkdir_p(xlog_dir, 0700) != 0)
+ if (mkdir_p(xlog_dir, S_IRWXU) != 0)
{
fprintf(stderr, _("%s: could not create directory \"%s\": %s\n"),
progname, xlog_dir, strerror(errno));
xlog_dir);
fflush(stdout);
- if (chmod(xlog_dir, 0700) != 0)
+ if (chmod(xlog_dir, S_IRWXU) != 0)
{
fprintf(stderr, _("%s: could not change permissions of directory \"%s\": %s\n"),
progname, xlog_dir, strerror(errno));
*/
argv0 = argv[0];
- umask(077);
+ umask(S_IRWXG | S_IRWXO);
/* support --help and --version even if invoked as root */
if (argc > 1)