2222 *
2323 *
2424 * IDENTIFICATION
25- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.300 2002/09/22 20:57:20 petere Exp $
25+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.301 2002/09/24 23:14:25 tgl Exp $
2626 *
2727 *-------------------------------------------------------------------------
2828 */
@@ -4839,16 +4839,18 @@ GetPrivileges(Archive *AH, const char *s, const char *type)
48394839}
48404840
48414841
4842- /*
4842+ /*----------
48434843 * Write out grant/revoke information
48444844 *
4845- * 'type' must be TABLE, FUNCTION, LANGUAGE, or SCHEMA. 'name' is the
4846- * formatted name of the object. Must be quoted etc. already.
4845+ * 'type' must be TABLE, FUNCTION, LANGUAGE, or SCHEMA.
4846+ * 'name' is the formatted name of the object. Must be quoted etc. already.
4847+ * 'tag' is the tag for the archive entry (typ. unquoted name of object).
48474848 * 'nspname' is the namespace the object is in (NULL if none).
48484849 * 'usename' is the owner, NULL if there is no owner (for languages).
48494850 * 'acls' is the string read out of the fooacl system catalog field;
48504851 * it will be parsed here.
48514852 * 'objoid' is the OID of the object for purposes of ordering.
4853+ *----------
48524854 */
48534855static void
48544856dumpACL (Archive * fout ,const char * type ,const char * name ,
@@ -4867,6 +4869,14 @@ dumpACL(Archive *fout, const char *type, const char *name,
48674869
48684870sql = createPQExpBuffer ();
48694871
4872+ /*
4873+ * Always start with REVOKE ALL FROM PUBLIC, so that we don't have to
4874+ * wire-in knowledge about the default public privileges for different
4875+ * kinds of objects.
4876+ */
4877+ appendPQExpBuffer (sql ,"REVOKE ALL ON %s %s FROM PUBLIC;\n" ,
4878+ type ,name );
4879+
48704880/* Make a working copy of acls so we can use strtok */
48714881aclbuf = strdup (acls );
48724882
@@ -4938,18 +4948,21 @@ dumpACL(Archive *fout, const char *type, const char *name,
49384948else
49394949{
49404950/* No privileges. Issue explicit REVOKE for safety. */
4941- appendPQExpBuffer (sql ,"REVOKE ALL ON %s %s FROM " ,
4942- type ,name );
49434951if (eqpos == tok )
49444952{
4945- /* Empty left-hand side means "PUBLIC" */
4946- appendPQExpBuffer (sql ,"PUBLIC;\n" );
4953+ /* Empty left-hand side means "PUBLIC"; already did it */
49474954}
49484955else if (strncmp (tok ,"group " ,strlen ("group " ))== 0 )
4949- appendPQExpBuffer (sql ,"GROUP %s;\n" ,
4956+ {
4957+ appendPQExpBuffer (sql ,"REVOKE ALL ON %s %s FROM GROUP %s;\n" ,
4958+ type ,name ,
49504959fmtId (tok + strlen ("group " )));
4960+ }
49514961else
4952- appendPQExpBuffer (sql ,"%s;\n" ,fmtId (tok ));
4962+ {
4963+ appendPQExpBuffer (sql ,"REVOKE ALL ON %s %s FROM %s;\n" ,
4964+ type ,name ,fmtId (tok ));
4965+ }
49534966}
49544967free (priv );
49554968}
@@ -4960,9 +4973,8 @@ dumpACL(Archive *fout, const char *type, const char *name,
49604973 */
49614974if (!found_owner_privs && usename )
49624975{
4963- appendPQExpBuffer (sql ,"REVOKE ALL ON %s %s FROM " ,
4964- type ,name );
4965- appendPQExpBuffer (sql ,"%s;\n" ,fmtId (usename ));
4976+ appendPQExpBuffer (sql ,"REVOKE ALL ON %s %s FROM %s;\n" ,
4977+ type ,name ,fmtId (usename ));
49664978}
49674979
49684980ArchiveEntry (fout ,objoid ,tag ,nspname ,usename ?usename :"" ,