mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Add a --role option to pg_dump, pg_dumpall, and pg_restore. This allows
performing dumps and restores in accordance with a security policy that forbids logging in directly as superuser, but instead specifies that you should log into an admin account and then SET ROLE to the superuser. In passing, clean up some ugly and mostly-broken code for quoting shell arguments in pg_dumpall. Benedek László, with some help from Tom Lane
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.159 2008/12/19 16:25:17 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.160 2009/01/05 16:54:36 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -462,9 +462,8 @@ NewRestoreOptions(void)
|
||||
|
||||
opts = (RestoreOptions *) calloc(1, sizeof(RestoreOptions));
|
||||
|
||||
/* set any fields that shouldn't default to zeroes */
|
||||
opts->format = archUnknown;
|
||||
opts->suppressDumpWarnings = false;
|
||||
opts->exit_on_error = false;
|
||||
|
||||
return opts;
|
||||
}
|
||||
@ -2146,6 +2145,10 @@ _doSetFixedOutputState(ArchiveHandle *AH)
|
||||
ahprintf(AH, "SET standard_conforming_strings = %s;\n",
|
||||
AH->public.std_strings ? "on" : "off");
|
||||
|
||||
/* Select the role to be used during restore */
|
||||
if (AH->ropt && AH->ropt->use_role)
|
||||
ahprintf(AH, "SET ROLE %s;\n", fmtId(AH->ropt->use_role));
|
||||
|
||||
/* Make sure function checking is disabled */
|
||||
ahprintf(AH, "SET check_function_bodies = false;\n");
|
||||
|
||||
|
Reference in New Issue
Block a user