mirror of
https://github.com/postgres/postgres.git
synced 2026-03-13 22:28:01 -04:00
Commitc37b3d08cdropped its added GetDataDirectoryCreatePerm call into the wrong place in pg_resetwal.c, namely after the chdir to DataDir. That broke invocations using a relative path, as reported by Tushar Ahuja. We could have left it where it was and changed the argument to be ".", but that'd result in a rather confusing error message in event of a failure, so re-ordering seems like a better solution. Similarly reorder operations in pg_rewind.c. The issue there is that it doesn't seem like a good idea to do any actual operations before the not-root check (on Unix) or the restricted token acquisition (on Windows). I don't know that this is an actual bug, but I'm definitely not convinced that it isn't, either. Assorted other code review forc37b3d08candda9b580d8: fix some misspelled or otherwise badly worded comments, put the #include for <sys/stat.h> where it actually belongs, etc. Discussion: https://postgr.es/m/aeb9c3a7-3c3f-a57f-1a18-c8d4fcdc2a1f@enterprisedb.com
56 lines
1.6 KiB
C
56 lines
1.6 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* File and directory permission definitions
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/common/file_perm.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef FILE_PERM_H
|
|
#define FILE_PERM_H
|
|
|
|
#include <sys/stat.h>
|
|
|
|
/*
|
|
* Mode mask for data directory permissions that only allows the owner to
|
|
* read/write directories and files.
|
|
*
|
|
* This is the default.
|
|
*/
|
|
#define PG_MODE_MASK_OWNER (S_IRWXG | S_IRWXO)
|
|
|
|
/*
|
|
* Mode mask for data directory permissions that also allows group read/execute.
|
|
*/
|
|
#define PG_MODE_MASK_GROUP (S_IWGRP | S_IRWXO)
|
|
|
|
/* Default mode for creating directories */
|
|
#define PG_DIR_MODE_OWNER S_IRWXU
|
|
|
|
/* Mode for creating directories that allows group read/execute */
|
|
#define PG_DIR_MODE_GROUP (S_IRWXU | S_IRGRP | S_IXGRP)
|
|
|
|
/* Default mode for creating files */
|
|
#define PG_FILE_MODE_OWNER (S_IRUSR | S_IWUSR)
|
|
|
|
/* Mode for creating files that allows group read */
|
|
#define PG_FILE_MODE_GROUP (S_IRUSR | S_IWUSR | S_IRGRP)
|
|
|
|
/* Modes for creating directories and files in the data directory */
|
|
extern int pg_dir_create_mode;
|
|
extern int pg_file_create_mode;
|
|
|
|
/* Mode mask to pass to umask() */
|
|
extern int pg_mode_mask;
|
|
|
|
/* Set permissions and mask based on the provided mode */
|
|
extern void SetDataDirectoryCreatePerm(int dataDirMode);
|
|
|
|
/* Set permissions and mask based on the mode of the data directory */
|
|
extern bool GetDataDirectoryCreatePerm(const char *dataDir);
|
|
|
|
#endif /* FILE_PERM_H */
|