mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Move permissions check from do_pg_start_backup to pg_start_backup
And the same for do_pg_stop_backup. The code in do_pg_* is not allowed to access the catalogs. For manual base backups, the permissions check can be handled in the calling function, and for streaming base backups only users with the required permissions can get past the authentication step in the first place. Reported by Antonin Houska, diagnosed by Andres Freund
This commit is contained in:
@ -56,6 +56,11 @@ pg_start_backup(PG_FUNCTION_ARGS)
|
||||
|
||||
backupidstr = text_to_cstring(backupid);
|
||||
|
||||
if (!superuser() && !has_rolreplication(GetUserId()))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("must be superuser or replication role to run a backup")));
|
||||
|
||||
startpoint = do_pg_start_backup(backupidstr, fast, NULL, NULL);
|
||||
|
||||
snprintf(startxlogstr, sizeof(startxlogstr), "%X/%X",
|
||||
@ -82,6 +87,11 @@ pg_stop_backup(PG_FUNCTION_ARGS)
|
||||
XLogRecPtr stoppoint;
|
||||
char stopxlogstr[MAXFNAMELEN];
|
||||
|
||||
if (!superuser() && !has_rolreplication(GetUserId()))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
(errmsg("must be superuser or replication role to run a backup"))));
|
||||
|
||||
stoppoint = do_pg_stop_backup(NULL, true, NULL);
|
||||
|
||||
snprintf(stopxlogstr, sizeof(stopxlogstr), "%X/%X",
|
||||
|
Reference in New Issue
Block a user