| 1 | /*------------------------------------------------------------------------- |
| 2 | * |
| 3 | * File and directory permission definitions |
| 4 | * |
| 5 | * |
| 6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
| 7 | * Portions Copyright (c) 1994, Regents of the University of California |
| 8 | * |
| 9 | * src/include/common/file_perm.h |
| 10 | * |
| 11 | *------------------------------------------------------------------------- |
| 12 | */ |
| 13 | #ifndef FILE_PERM_H |
| 14 | #define FILE_PERM_H |
| 15 | |
| 16 | #include <sys/stat.h> |
| 17 | |
| 18 | /* |
| 19 | * Mode mask for data directory permissions that only allows the owner to |
| 20 | * read/write directories and files. |
| 21 | * |
| 22 | * This is the default. |
| 23 | */ |
| 24 | #define PG_MODE_MASK_OWNER (S_IRWXG | S_IRWXO) |
| 25 | |
| 26 | /* |
| 27 | * Mode mask for data directory permissions that also allows group read/execute. |
| 28 | */ |
| 29 | #define PG_MODE_MASK_GROUP (S_IWGRP | S_IRWXO) |
| 30 | |
| 31 | /* Default mode for creating directories */ |
| 32 | #define PG_DIR_MODE_OWNER S_IRWXU |
| 33 | |
| 34 | /* Mode for creating directories that allows group read/execute */ |
| 35 | #define PG_DIR_MODE_GROUP (S_IRWXU | S_IRGRP | S_IXGRP) |
| 36 | |
| 37 | /* Default mode for creating files */ |
| 38 | #define PG_FILE_MODE_OWNER (S_IRUSR | S_IWUSR) |
| 39 | |
| 40 | /* Mode for creating files that allows group read */ |
| 41 | #define PG_FILE_MODE_GROUP (S_IRUSR | S_IWUSR | S_IRGRP) |
| 42 | |
| 43 | /* Modes for creating directories and files in the data directory */ |
| 44 | extern int pg_dir_create_mode; |
| 45 | extern int pg_file_create_mode; |
| 46 | |
| 47 | /* Mode mask to pass to umask() */ |
| 48 | extern int pg_mode_mask; |
| 49 | |
| 50 | /* Set permissions and mask based on the provided mode */ |
| 51 | extern void SetDataDirectoryCreatePerm(int dataDirMode); |
| 52 | |
| 53 | /* Set permissions and mask based on the mode of the data directory */ |
| 54 | extern bool GetDataDirectoryCreatePerm(const char *dataDir); |
| 55 | |
| 56 | #endif /* FILE_PERM_H */ |
| 57 | |