summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_dumpall.c
diff options
context:
space:
mode:
authorMagnus Hagander2010-12-29 10:05:03 +0000
committerMagnus Hagander2010-12-29 10:05:03 +0000
commit9b8aff8c192e2f313f90395d114c58a9ef84f97f (patch)
treea4a4f7a5c25d4bbdd85599471a206433de704f1d /src/bin/pg_dump/pg_dumpall.c
parentf2ba1e994c4d17dc3d4b8d48d3933c96d09127e1 (diff)
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.
Diffstat (limited to 'src/bin/pg_dump/pg_dumpall.c')
-rw-r--r--src/bin/pg_dump/pg_dumpall.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index bf91d726ce8..beeba1cb528 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -653,16 +653,26 @@ dumpRoles(PGconn *conn)
i_rolconnlimit,
i_rolpassword,
i_rolvaliduntil,
+ i_rolreplication,
i_rolcomment;
int i;
/* note: rolconfig is dumped later */
- if (server_version >= 80200)
+ if (server_version >= 90100)
printfPQExpBuffer(buf,
"SELECT rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, rolcatupdate, "
"rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, "
+ "rolvaliduntil, rolreplication, "
+ "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment "
+ "FROM pg_authid "
+ "ORDER BY 1");
+ else if (server_version >= 80200)
+ printfPQExpBuffer(buf,
+ "SELECT rolname, rolsuper, rolinherit, "
+ "rolcreaterole, rolcreatedb, rolcatupdate, "
+ "rolcanlogin, rolconnlimit, rolpassword, "
+ "rolvaliduntil, false as rolreplication, "
"pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment "
"FROM pg_authid "
"ORDER BY 1");
@@ -671,7 +681,8 @@ dumpRoles(PGconn *conn)
"SELECT rolname, rolsuper, rolinherit, "
"rolcreaterole, rolcreatedb, rolcatupdate, "
"rolcanlogin, rolconnlimit, rolpassword, "
- "rolvaliduntil, null as rolcomment "
+ "rolvaliduntil, false as rolreplication, "
+ "null as rolcomment "
"FROM pg_authid "
"ORDER BY 1");
else
@@ -686,6 +697,7 @@ dumpRoles(PGconn *conn)
"-1 as rolconnlimit, "
"passwd as rolpassword, "
"valuntil as rolvaliduntil, "
+ "false as rolreplication, "
"null as rolcomment "
"FROM pg_shadow "
"UNION ALL "
@@ -699,6 +711,7 @@ dumpRoles(PGconn *conn)
"-1 as rolconnlimit, "
"null::text as rolpassword, "
"null::abstime as rolvaliduntil, "
+ "false as rolreplication, "
"null as rolcomment "
"FROM pg_group "
"WHERE NOT EXISTS (SELECT 1 FROM pg_shadow "
@@ -717,6 +730,7 @@ dumpRoles(PGconn *conn)
i_rolconnlimit = PQfnumber(res, "rolconnlimit");
i_rolpassword = PQfnumber(res, "rolpassword");
i_rolvaliduntil = PQfnumber(res, "rolvaliduntil");
+ i_rolreplication = PQfnumber(res, "rolreplication");
i_rolcomment = PQfnumber(res, "rolcomment");
if (PQntuples(res) > 0)
@@ -765,6 +779,11 @@ dumpRoles(PGconn *conn)
else
appendPQExpBuffer(buf, " NOLOGIN");
+ if (strcmp(PQgetvalue(res, i, i_rolreplication), "t") == 0)
+ appendPQExpBuffer(buf, " REPLICATION");
+ else
+ appendPQExpBuffer(buf, " NOREPLICATION");
+
if (strcmp(PQgetvalue(res, i, i_rolconnlimit), "-1") != 0)
appendPQExpBuffer(buf, " CONNECTION LIMIT %s",
PQgetvalue(res, i, i_rolconnlimit));