# patroni.file_perm module

Helper object that helps with figuring out file and directory permissions based on permissions of PGDATA.

var logger:

  logger of this module.

var pg_perm:

  instance of the `__FilePermissions` object.

class patroni.file_perm.__FilePermissions

  Bases: `object`

  Helper class for managing permissions of directories and files under PGDATA.

  Execute `set_permissions_from_data_directory()` to figure out which permissions should be used for files and directories under PGDATA based on permissions of PGDATA root directory.

  _FilePermissions__PG_DIR_MODE_GROUP = 488
  _FilePermissions__PG_DIR_MODE_OWNER = 448
  _FilePermissions__PG_FILE_MODE_GROUP = 416
  _FilePermissions__PG_FILE_MODE_OWNER = 384
  _FilePermissions__PG_MODE_MASK_GROUP = 23
  _FilePermissions__PG_MODE_MASK_OWNER = 63
  _FilePermissions__set_group_permissions() → None

    Make directories/files accessible by the owner and readable by group.

  _FilePermissions__set_owner_permissions() → None

    Make directories/files accessible only by the owner.

  _FilePermissions__set_umask() → None

    Set umask value based on calculations.

    Note

    Should only be called once either `__set_owner_permissions()` or `__set_group_permissions()` has been executed.

  __init__() → None

    Create a `__FilePermissions` object and set default permissions.

  property dir_create_mode: int

    Directory permissions.

  property file_create_mode: int

    File permissions.

  set_permissions_from_data_directory(data_dir: str) → None

    Set new permissions based on provided data_dir.

    Parameters:

      data_dir – reference to PGDATA to calculate permissions from.