2
0

file_perm.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*-------------------------------------------------------------------------
  2. *
  3. * File and directory permission definitions
  4. *
  5. *
  6. * Portions Copyright (c) 1996-2022, 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. #include <sys/stat.h>
  16. /*
  17. * Mode mask for data directory permissions that only allows the owner to
  18. * read/write directories and files.
  19. *
  20. * This is the default.
  21. */
  22. #define PG_MODE_MASK_OWNER (S_IRWXG | S_IRWXO)
  23. /*
  24. * Mode mask for data directory permissions that also allows group read/execute.
  25. */
  26. #define PG_MODE_MASK_GROUP (S_IWGRP | S_IRWXO)
  27. /* Default mode for creating directories */
  28. #define PG_DIR_MODE_OWNER S_IRWXU
  29. /* Mode for creating directories that allows group read/execute */
  30. #define PG_DIR_MODE_GROUP (S_IRWXU | S_IRGRP | S_IXGRP)
  31. /* Default mode for creating files */
  32. #define PG_FILE_MODE_OWNER (S_IRUSR | S_IWUSR)
  33. /* Mode for creating files that allows group read */
  34. #define PG_FILE_MODE_GROUP (S_IRUSR | S_IWUSR | S_IRGRP)
  35. /* Modes for creating directories and files in the data directory */
  36. extern PGDLLIMPORT int pg_dir_create_mode;
  37. extern PGDLLIMPORT int pg_file_create_mode;
  38. /* Mode mask to pass to umask() */
  39. extern PGDLLIMPORT int pg_mode_mask;
  40. /* Set permissions and mask based on the provided mode */
  41. extern void SetDataDirectoryCreatePerm(int dataDirMode);
  42. /* Set permissions and mask based on the mode of the data directory */
  43. extern bool GetDataDirectoryCreatePerm(const char *dataDir);
  44. #endif /* FILE_PERM_H */