7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.33 1999/02/13 23:18:58 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.34 1999/03/21 06:31:59 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -34,11 +34,12 @@ static char *aclparse(char *s, AclItem *aip, unsigned *modechg);
34
34
/*
35
35
* getid
36
36
* Consumes the first alphanumeric string (identifier) found in string
37
- * 's', ignoring any leading white space.
37
+ * 's', ignoring any leading white space. If it finds a double quote
38
+ * it returns the word inside the quotes.
38
39
*
39
40
* RETURNS:
40
41
* the string position in 's' that points to the next non-space character
41
- * in 's'. Also:
42
+ * in 's', after any quotes . Also:
42
43
* - loads the identifier into 'name'. (If no identifier is found, 'name'
43
44
* contains an empty string).
44
45
*/
@@ -47,13 +48,27 @@ getid(char *s, char *n)
47
48
{
48
49
unsigned len ;
49
50
char * id ;
51
+ int in_quotes = 0 ;
50
52
51
53
Assert (s && n );
52
54
53
55
while (isspace (* s ))
54
56
++ s ;
55
- for (id = s , len = 0 ; isalnum (* s ) || * s == '_' ; ++ len , ++ s )
56
- ;
57
+
58
+ if (* s == '"' )
59
+ {
60
+ in_quotes = 1 ;
61
+ s ++ ;
62
+ }
63
+
64
+ for (id = s , len = 0 ; isalnum (* s ) || * s == '_' || in_quotes ; ++ len , ++ s )
65
+ {
66
+ if (in_quotes && * s == '"' )
67
+ {
68
+ len -- ;
69
+ in_quotes = 0 ;
70
+ }
71
+ }
57
72
if (len > sizeof (NameData ))
58
73
elog (ERROR , "getid: identifier cannot be >%d characters" ,
59
74
sizeof (NameData ));
@@ -91,12 +106,16 @@ aclparse(char *s, AclItem *aip, unsigned *modechg)
91
106
92
107
Assert (s && aip && modechg );
93
108
109
+ #ifdef ACLDEBUG_TRACE
110
+ printf ("aclparse: input = '%s'\n" , s );
111
+ #endif ACLDEBUG_TRACE
94
112
aip -> ai_idtype = ACL_IDTYPE_UID ;
95
113
s = getid (s , name );
96
114
if (* s != ACL_MODECHG_ADD_CHR &&
97
115
* s != ACL_MODECHG_DEL_CHR &&
98
116
* s != ACL_MODECHG_EQL_CHR )
99
- { /* we just read a keyword, not a name */
117
+ {
118
+ /* we just read a keyword, not a name */
100
119
if (!strcmp (name , ACL_IDTYPE_GID_KEYWORD ))
101
120
aip -> ai_idtype = ACL_IDTYPE_GID ;
102
121
else if (strcmp (name , ACL_IDTYPE_UID_KEYWORD ))
@@ -668,15 +687,15 @@ makeAclStmt(char *privileges, List *rel_list, char *grantee,
668
687
/* the grantee string is "G <group_name>", "U <user_name>", or "ALL" */
669
688
if (grantee [0 ] == 'G' ) /* group permissions */
670
689
{
671
- sprintf (str , "%s %s %c%s" ,
690
+ sprintf (str , "%s %c%s%c %c%s" ,
672
691
ACL_IDTYPE_GID_KEYWORD ,
673
- grantee + 2 , grant_or_revoke , privileges );
692
+ '"' , grantee + 2 , '"' , grant_or_revoke , privileges );
674
693
}
675
694
else if (grantee [0 ] == 'U' ) /* user permission */
676
695
{
677
- sprintf (str , "%s %s %c%s" ,
696
+ sprintf (str , "%s %c%s%c %c%s" ,
678
697
ACL_IDTYPE_UID_KEYWORD ,
679
- grantee + 2 , grant_or_revoke , privileges );
698
+ '"' , grantee + 2 , '"' , grant_or_revoke , privileges );
680
699
}
681
700
else
682
701
/* all permission */
0 commit comments