Re-add pg_dump fix.
This commit is contained in:
parent
e83621aa13
commit
bf7b72109f
@ -21,7 +21,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.69 1998/04/07 22:00:37 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.70 1998/04/07 22:36:38 momjian Exp $
|
||||||
*
|
*
|
||||||
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
||||||
*
|
*
|
||||||
@ -79,6 +79,7 @@
|
|||||||
#include "pg_dump.h"
|
#include "pg_dump.h"
|
||||||
|
|
||||||
static void dumpSequence(FILE *fout, TableInfo tbinfo);
|
static void dumpSequence(FILE *fout, TableInfo tbinfo);
|
||||||
|
static void dumpACL(FILE *fout, TableInfo tbinfo);
|
||||||
static void
|
static void
|
||||||
dumpTriggers(FILE *fout, const char *tablename,
|
dumpTriggers(FILE *fout, const char *tablename,
|
||||||
TableInfo *tblinfo, int numTables);
|
TableInfo *tblinfo, int numTables);
|
||||||
@ -2291,21 +2292,22 @@ GetPrivledges(char *s)
|
|||||||
{
|
{
|
||||||
char *acls = NULL;
|
char *acls = NULL;
|
||||||
|
|
||||||
/* Grant All == arwR */
|
/* Grant All == arwR */
|
||||||
/* INSERT == ar */
|
/* INSERT == a */
|
||||||
/* UPDATE/DELETE == rw */
|
/* UPDATE/DELETE == w */
|
||||||
/* SELECT == r */
|
/* SELECT == r */
|
||||||
/* RULE == R */
|
/* RULE == R */
|
||||||
|
|
||||||
if (strstr(s, "arwR"))
|
if (strstr(s, "arwR"))
|
||||||
return (strdup("ALL"));
|
return (strdup("ALL"));
|
||||||
|
|
||||||
if (strstr(s, "ar"))
|
if (strchr(s, 'a'))
|
||||||
acls = AddAcl(acls, "INSERT");
|
acls = AddAcl(acls, "INSERT");
|
||||||
|
|
||||||
if (strstr(s, "rw"))
|
if (strchr(s, 'w'))
|
||||||
acls = AddAcl(acls, "UPDATE,DELETE");
|
acls = AddAcl(acls, "UPDATE,DELETE");
|
||||||
else if (strchr(s, 'r'))
|
|
||||||
|
if (strchr(s, 'r'))
|
||||||
acls = AddAcl(acls, "SELECT");
|
acls = AddAcl(acls, "SELECT");
|
||||||
|
|
||||||
if (strchr(s, 'R'))
|
if (strchr(s, 'R'))
|
||||||
@ -2378,6 +2380,44 @@ ParseACL(const char *acls, int *count)
|
|||||||
*count = NumAcls;
|
*count = NumAcls;
|
||||||
return (ParsedAcl);
|
return (ParsedAcl);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* dumpACL:
|
||||||
|
* Write out grant/revoke information
|
||||||
|
* Called for sequences and tables
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
dumpACL(FILE *fout, TableInfo tbinfo)
|
||||||
|
{
|
||||||
|
int k, l;
|
||||||
|
ACL *ACLlist;
|
||||||
|
|
||||||
|
ACLlist = ParseACL(tbinfo.relacl, &l);
|
||||||
|
if (ACLlist == (ACL *) NULL)
|
||||||
|
if (l == 0)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Could not parse ACL list for %s...Exiting!\n",
|
||||||
|
tbinfo.relname);
|
||||||
|
exit_nicely(g_conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Revoke Default permissions for PUBLIC */
|
||||||
|
fprintf(fout,
|
||||||
|
"REVOKE ALL on %s from PUBLIC;\n",
|
||||||
|
tbinfo.relname);
|
||||||
|
|
||||||
|
for (k = 0; k < l; k++)
|
||||||
|
{
|
||||||
|
if (ACLlist[k].privledges != (char *) NULL)
|
||||||
|
fprintf(fout,
|
||||||
|
"GRANT %s on %s to %s;\n",
|
||||||
|
ACLlist[k].privledges, tbinfo.relname,
|
||||||
|
ACLlist[k].user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dumpTables:
|
* dumpTables:
|
||||||
@ -2392,13 +2432,11 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
|
|||||||
{
|
{
|
||||||
int i,
|
int i,
|
||||||
j,
|
j,
|
||||||
k,
|
k;
|
||||||
l;
|
|
||||||
char q[MAXQUERYLEN];
|
char q[MAXQUERYLEN];
|
||||||
char **parentRels; /* list of names of parent relations */
|
char **parentRels; /* list of names of parent relations */
|
||||||
int numParents;
|
int numParents;
|
||||||
int actual_atts; /* number of attrs in this CREATE statment */
|
int actual_atts; /* number of attrs in this CREATE statment */
|
||||||
ACL *ACLlist;
|
|
||||||
|
|
||||||
/* First - dump SEQUENCEs */
|
/* First - dump SEQUENCEs */
|
||||||
for (i = 0; i < numTables; i++)
|
for (i = 0; i < numTables; i++)
|
||||||
@ -2409,6 +2447,8 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
|
|||||||
{
|
{
|
||||||
fprintf(fout, "\\connect - %s\n", tblinfo[i].usename);
|
fprintf(fout, "\\connect - %s\n", tblinfo[i].usename);
|
||||||
dumpSequence(fout, tblinfo[i]);
|
dumpSequence(fout, tblinfo[i]);
|
||||||
|
if (acls)
|
||||||
|
dumpACL(fout, tblinfo[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2505,36 +2545,9 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
|
|||||||
}
|
}
|
||||||
strcat(q, ";\n");
|
strcat(q, ";\n");
|
||||||
fputs(q, fout);
|
fputs(q, fout);
|
||||||
|
|
||||||
if (acls)
|
if (acls)
|
||||||
{
|
dumpACL(fout, tblinfo[i]);
|
||||||
ACLlist = ParseACL(tblinfo[i].relacl, &l);
|
|
||||||
if (ACLlist == (ACL *) NULL)
|
|
||||||
{
|
|
||||||
if (l == 0)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Could not parse ACL list for %s...Exiting!\n",
|
|
||||||
tblinfo[i].relname);
|
|
||||||
exit_nicely(g_conn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Revoke Default permissions for PUBLIC */
|
|
||||||
fprintf(fout,
|
|
||||||
"REVOKE ALL on %s from PUBLIC;\n",
|
|
||||||
tblinfo[i].relname);
|
|
||||||
|
|
||||||
for (k = 0; k < l; k++)
|
|
||||||
{
|
|
||||||
if (ACLlist[k].privledges != (char *) NULL)
|
|
||||||
fprintf(fout,
|
|
||||||
"GRANT %s on %s to %s;\n",
|
|
||||||
ACLlist[k].privledges, tblinfo[i].relname,
|
|
||||||
ACLlist[k].user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user