Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit beb1851

Browse files
committed
This patch fixes the bug that made it impossible to grant permissions to
a user such as "www-data". Oliver
1 parent b01a272 commit beb1851

File tree

1 file changed

+29
-10
lines changed
  • src/backend/utils/adt

1 file changed

+29
-10
lines changed

src/backend/utils/adt/acl.c

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* 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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -34,11 +34,12 @@ static char *aclparse(char *s, AclItem *aip, unsigned *modechg);
3434
/*
3535
* getid
3636
* 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.
3839
*
3940
* RETURNS:
4041
* the string position in 's' that points to the next non-space character
41-
* in 's'. Also:
42+
* in 's', after any quotes. Also:
4243
* - loads the identifier into 'name'. (If no identifier is found, 'name'
4344
* contains an empty string).
4445
*/
@@ -47,13 +48,27 @@ getid(char *s, char *n)
4748
{
4849
unsigned len;
4950
char *id;
51+
int in_quotes = 0;
5052

5153
Assert(s && n);
5254

5355
while (isspace(*s))
5456
++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+
}
5772
if (len > sizeof(NameData))
5873
elog(ERROR, "getid: identifier cannot be >%d characters",
5974
sizeof(NameData));
@@ -91,12 +106,16 @@ aclparse(char *s, AclItem *aip, unsigned *modechg)
91106

92107
Assert(s && aip && modechg);
93108

109+
#ifdef ACLDEBUG_TRACE
110+
printf("aclparse: input = '%s'\n", s);
111+
#endif ACLDEBUG_TRACE
94112
aip->ai_idtype = ACL_IDTYPE_UID;
95113
s = getid(s, name);
96114
if (*s != ACL_MODECHG_ADD_CHR &&
97115
*s != ACL_MODECHG_DEL_CHR &&
98116
*s != ACL_MODECHG_EQL_CHR)
99-
{ /* we just read a keyword, not a name */
117+
{
118+
/* we just read a keyword, not a name */
100119
if (!strcmp(name, ACL_IDTYPE_GID_KEYWORD))
101120
aip->ai_idtype = ACL_IDTYPE_GID;
102121
else if (strcmp(name, ACL_IDTYPE_UID_KEYWORD))
@@ -668,15 +687,15 @@ makeAclStmt(char *privileges, List *rel_list, char *grantee,
668687
/* the grantee string is "G <group_name>", "U <user_name>", or "ALL" */
669688
if (grantee[0] == 'G') /* group permissions */
670689
{
671-
sprintf(str, "%s %s%c%s",
690+
sprintf(str, "%s %c%s%c%c%s",
672691
ACL_IDTYPE_GID_KEYWORD,
673-
grantee + 2, grant_or_revoke, privileges);
692+
'"', grantee + 2, '"', grant_or_revoke, privileges);
674693
}
675694
else if (grantee[0] == 'U') /* user permission */
676695
{
677-
sprintf(str, "%s %s%c%s",
696+
sprintf(str, "%s %c%s%c%c%s",
678697
ACL_IDTYPE_UID_KEYWORD,
679-
grantee + 2, grant_or_revoke, privileges);
698+
'"', grantee + 2, '"', grant_or_revoke, privileges);
680699
}
681700
else
682701
/* all permission */

0 commit comments

Comments
 (0)