Skip to content

Commit 5cf1964

Browse files
committed
From: Jan Wieck <jwieck@debis.com>
So if the relname is given to acldefault() in utils/adt/acl.c, it can do a IsSystemRelationName() on it and return ACL_RD instead of ACL_WORLD_DEFAULT.
1 parent 751ebd2 commit 5cf1964

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/backend/catalog/aclchk.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.5 1998/02/11 19:09:42 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.6 1998/02/24 03:31:45 scrappy Exp $
1111
*
1212
* NOTES
1313
* See acl.h.
@@ -39,7 +39,7 @@
3939
#include "utils/tqual.h"
4040
#include "fmgr.h"
4141

42-
static int32 aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode);
42+
static int32 aclcheck(char *relname, Acl *acl, AclId id, AclIdType idtype, AclMode mode);
4343

4444
/*
4545
* Enable use of user relations in place of real system catalogs.
@@ -150,7 +150,7 @@ ChangeAcl(char *relname,
150150
elog(DEBUG, "ChangeAcl: using default ACL");
151151
#endif
152152
/* old_acl = acldefault(((Form_pg_class) GETSTRUCT(htp))->relowner); */
153-
old_acl = acldefault();
153+
old_acl = acldefault(relname);
154154
free_old_acl = 1;
155155
}
156156

@@ -281,7 +281,7 @@ in_group(AclId uid, AclId gid)
281281
* any one of the requirements of 'mode'. Returns 0 otherwise.
282282
*/
283283
static int32
284-
aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode)
284+
aclcheck(char *relname, Acl *acl, AclId id, AclIdType idtype, AclMode mode)
285285
{
286286
unsigned i;
287287
AclItem *aip,
@@ -292,7 +292,7 @@ aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode)
292292
/* if no acl is found, use world default */
293293
if (!acl)
294294
{
295-
acl = acldefault();
295+
acl = acldefault(relname);
296296
}
297297

298298
num = ACL_NUM(acl);
@@ -475,7 +475,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
475475
Anum_pg_class_relowner,
476476
RelationGetTupleDescriptor(relation),
477477
(bool *) NULL);
478-
acl = aclownerdefault(ownerId);
478+
acl = aclownerdefault(relname, ownerId);
479479
}
480480
#else
481481
{ /* This is why the syscache is great... */
@@ -511,7 +511,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
511511
heap_close(relation);
512512
}
513513
#endif
514-
result = aclcheck(acl, id, (AclIdType) ACL_IDTYPE_UID, mode);
514+
result = aclcheck(relname, acl, id, (AclIdType) ACL_IDTYPE_UID, mode);
515515
if (acl)
516516
pfree(acl);
517517
return (result);

src/backend/utils/adt/acl.c

Lines changed: 6 additions & 5 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.24 1998/02/11 19:12:03 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.25 1998/02/24 03:31:47 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -18,6 +18,7 @@
1818
#include <utils/memutils.h>
1919
#include "utils/acl.h"
2020
#include "utils/syscache.h"
21+
#include "catalog/catalog.h"
2122
#include "catalog/pg_user.h"
2223
#include "miscadmin.h"
2324

@@ -342,7 +343,7 @@ aclitemgt(AclItem *a1, AclItem *a2)
342343
}
343344

344345
Acl *
345-
aclownerdefault(AclId ownerid)
346+
aclownerdefault(char *relname, AclId ownerid)
346347
{
347348
Acl *acl;
348349
AclItem *aip;
@@ -351,15 +352,15 @@ aclownerdefault(AclId ownerid)
351352
aip = ACL_DAT(acl);
352353
aip[0].ai_idtype = ACL_IDTYPE_WORLD;
353354
aip[0].ai_id = ACL_ID_WORLD;
354-
aip[0].ai_mode = ACL_WORLD_DEFAULT;
355+
aip[0].ai_mode = IsSystemRelationName(relname) ? ACL_RD : ACL_WORLD_DEFAULT;
355356
aip[1].ai_idtype = ACL_IDTYPE_UID;
356357
aip[1].ai_id = ownerid;
357358
aip[1].ai_mode = ACL_OWNER_DEFAULT;
358359
return (acl);
359360
}
360361

361362
Acl *
362-
acldefault(void)
363+
acldefault(char *relname)
363364
{
364365
Acl *acl;
365366
AclItem *aip;
@@ -368,7 +369,7 @@ acldefault(void)
368369
aip = ACL_DAT(acl);
369370
aip[0].ai_idtype = ACL_IDTYPE_WORLD;
370371
aip[0].ai_id = ACL_ID_WORLD;
371-
aip[0].ai_mode = ACL_WORLD_DEFAULT;
372+
aip[0].ai_mode = IsSystemRelationName(relname) ? ACL_RD : ACL_WORLD_DEFAULT;
372373
return (acl);
373374
}
374375

src/include/utils/acl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: acl.h,v 1.14 1998/02/23 18:43:13 scrappy Exp $
9+
* $Id: acl.h,v 1.15 1998/02/24 03:31:50 scrappy Exp $
1010
*
1111
* NOTES
1212
* For backward-compatability purposes we have to allow there
@@ -135,8 +135,8 @@ extern char *aclcheck_error_strings[];
135135
/*
136136
* routines used internally (parser, etc.)
137137
*/
138-
extern Acl *aclownerdefault(AclId ownerid);
139-
extern Acl *acldefault(void);
138+
extern Acl *aclownerdefault(char *relname, AclId ownerid);
139+
extern Acl *acldefault(char *relname);
140140
extern Acl *aclinsert3(Acl *old_acl, AclItem *mod_aip, unsigned modechg);
141141

142142
extern char *aclmakepriv(char *old_privlist, char new_priv);

0 commit comments

Comments
 (0)