mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Add REPLICATION privilege for ROLEs
This privilege is required to do Streaming Replication, instead of superuser, making it possible to set up a SR slave that doesn't have write permissions on the master. Superuser privileges do NOT override this check, so in order to use the default superuser account for replication it must be explicitly granted the REPLICATION permissions. This is backwards incompatible change, in the interest of higher default security.
This commit is contained in:
@@ -8301,10 +8301,10 @@ pg_start_backup(PG_FUNCTION_ARGS)
|
||||
struct stat stat_buf;
|
||||
FILE *fp;
|
||||
|
||||
if (!superuser())
|
||||
if (!superuser() && !is_authenticated_user_replication_role())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("must be superuser to run a backup")));
|
||||
errmsg("must be superuser or replication role to run a backup")));
|
||||
|
||||
if (RecoveryInProgress())
|
||||
ereport(ERROR,
|
||||
@@ -8493,10 +8493,10 @@ pg_stop_backup(PG_FUNCTION_ARGS)
|
||||
int waits = 0;
|
||||
bool reported_waiting = false;
|
||||
|
||||
if (!superuser())
|
||||
if (!superuser() && !is_authenticated_user_replication_role())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
(errmsg("must be superuser to run a backup"))));
|
||||
(errmsg("must be superuser or replication role to run a backup"))));
|
||||
|
||||
if (RecoveryInProgress())
|
||||
ereport(ERROR,
|
||||
|
||||
Reference in New Issue
Block a user