From: Marc G. Fournier Date: Thu, 4 Dec 1997 01:31:28 +0000 (+0000) Subject: Incorporate patch from Matt(maycock@intelliquest.com) for dumping ACLs X-Git-Tag: REL6_3~555 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a57e21c304a9f2cc719ea265efa3319828adbd8;p=postgresql Incorporate patch from Matt(maycock@intelliquest.com) for dumping ACLs Clean up formatting of code Integrate new functions into dumpTable This is not tested yet...have to recompile server due to patches from Todd...but this compiles cleanly as it stands now --- diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 85e87c7bd2..85f4418c05 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.55 1997/12/01 22:02:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.56 1997/12/04 01:31:27 scrappy Exp $ * * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * @@ -2138,6 +2138,117 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs, } } +/* + * These are some support functions to fix the acl problem of pg_dump + * + * Matthew C. Aycock 12/02/97 + */ +/* + * This will return a new string: "s,add" + */ +char *AddAcl(char *s, const char *add) +{ + char *t; + + if (s == (char *)NULL) + return (strdup(add)); + + t=(char *)calloc((strlen(s) + strlen(add)+1),sizeof(char)); + sprintf(t,"%s,%s",s,add); + + return(t); +} +/* + * This will take a string of 'arwR' and return a + * comma delimited string of SELECT,INSERT,UPDATE,DELETE,RULE + */ +char *GetPrivledges(char *s) +{ + char *acls=NULL; + + /*Grant All == arwR */ + /* INSERT == ar */ + /* UPDATE/DELETE == rw */ + /* SELECT == r */ + /* RULE == R */ + + if (strstr(s,"arwR")) + return(strdup("ALL")); + + if (strstr(s,"ar")) + acls=AddAcl(acls,"INSERT"); + + if (strstr(s,"rw")) + acls=AddAcl(acls,"UPDATE,DELETE"); + else + if (strchr(s,'r')) + acls=AddAcl(acls,"SELECT"); + + if (strchr(s,'R')) + acls=AddAcl(acls,"RULES"); + + return(acls); +} +/* This will parse the acl string of TableInfo + * into a two deminsional aray: + * user | Privledges + * So to reset the acls I need to grant these priviledges + * to user + */ +ACL *ParseACL(const char *acls,int *count) +{ + ACL *ParsedAcl=NULL; + int i, + len, + NumAcls=1, /*There is always public*/ + AclLen=0; + char *s=NULL, + *user=NULL, + *priv=NULL, + *tok; + + AclLen=strlen(acls); + + if (AclLen == 0) { + *count=0; + return (ACL *) NULL; + } + + for (i=0;i