mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Allow group access on PGDATA
Allow the cluster to be optionally init'd with read access for the group. This means a relatively non-privileged user can perform a backup of the cluster without requiring write privileges, which enhances security. The mode of PGDATA is used to determine whether group permissions are enabled for directory and file creates. This method was chosen as it's simple and works well for the various utilities that write into PGDATA. Changing the mode of PGDATA manually will not automatically change the mode of all the files contained therein. If the user would like to enable group access on an existing cluster then changing the mode of all the existing files will be required. Note that pg_upgrade will automatically change the mode of all migrated files if the new cluster is init'd with the -g option. Tests are included for the backend and all the utilities which operate on the PG data directory to ensure that the correct mode is set based on the data directory permissions. Author: David Steele <david@pgmasters.net> Reviewed-By: Michael Paquier, with discussion amongst many others. Discussion: https://postgr.es/m/ad346fe6-b23e-59f1-ecb7-0e08390ad629%40pgmasters.net
This commit is contained in:
@ -194,6 +194,7 @@ static void assign_application_name(const char *newval, void *extra);
|
||||
static bool check_cluster_name(char **newval, void **extra, GucSource source);
|
||||
static const char *show_unix_socket_permissions(void);
|
||||
static const char *show_log_file_mode(void);
|
||||
static const char *show_data_directory_mode(void);
|
||||
|
||||
/* Private functions in guc-file.l that need to be called from guc.c */
|
||||
static ConfigVariable *ProcessConfigFileInternal(GucContext context,
|
||||
@ -2044,6 +2045,21 @@ static struct config_int ConfigureNamesInt[] =
|
||||
NULL, NULL, show_log_file_mode
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
{"data_directory_mode", PGC_INTERNAL, PRESET_OPTIONS,
|
||||
gettext_noop("Mode of the data directory."),
|
||||
gettext_noop("The parameter value is a numeric mode specification "
|
||||
"in the form accepted by the chmod and umask system "
|
||||
"calls. (To use the customary octal format the number "
|
||||
"must start with a 0 (zero).)"),
|
||||
GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
|
||||
},
|
||||
&data_directory_mode,
|
||||
0700, 0000, 0777,
|
||||
NULL, NULL, show_data_directory_mode
|
||||
},
|
||||
|
||||
{
|
||||
{"work_mem", PGC_USERSET, RESOURCES_MEM,
|
||||
gettext_noop("Sets the maximum memory to be used for query workspaces."),
|
||||
@ -10744,4 +10760,13 @@ show_log_file_mode(void)
|
||||
return buf;
|
||||
}
|
||||
|
||||
static const char *
|
||||
show_data_directory_mode(void)
|
||||
{
|
||||
static char buf[12];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%04o", data_directory_mode);
|
||||
return buf;
|
||||
}
|
||||
|
||||
#include "guc-file.c"
|
||||
|
Reference in New Issue
Block a user