Commit 5cf1964f authored by Marc G. Fournier's avatar Marc G. Fournier

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.
parent 751ebd20
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.5 1998/02/11 19:09:42 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.6 1998/02/24 03:31:45 scrappy Exp $
* *
* NOTES * NOTES
* See acl.h. * See acl.h.
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "utils/tqual.h" #include "utils/tqual.h"
#include "fmgr.h" #include "fmgr.h"
static int32 aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode); static int32 aclcheck(char *relname, Acl *acl, AclId id, AclIdType idtype, AclMode mode);
/* /*
* Enable use of user relations in place of real system catalogs. * Enable use of user relations in place of real system catalogs.
...@@ -150,7 +150,7 @@ ChangeAcl(char *relname, ...@@ -150,7 +150,7 @@ ChangeAcl(char *relname,
elog(DEBUG, "ChangeAcl: using default ACL"); elog(DEBUG, "ChangeAcl: using default ACL");
#endif #endif
/* old_acl = acldefault(((Form_pg_class) GETSTRUCT(htp))->relowner); */ /* old_acl = acldefault(((Form_pg_class) GETSTRUCT(htp))->relowner); */
old_acl = acldefault(); old_acl = acldefault(relname);
free_old_acl = 1; free_old_acl = 1;
} }
...@@ -281,7 +281,7 @@ in_group(AclId uid, AclId gid) ...@@ -281,7 +281,7 @@ in_group(AclId uid, AclId gid)
* any one of the requirements of 'mode'. Returns 0 otherwise. * any one of the requirements of 'mode'. Returns 0 otherwise.
*/ */
static int32 static int32
aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode) aclcheck(char *relname, Acl *acl, AclId id, AclIdType idtype, AclMode mode)
{ {
unsigned i; unsigned i;
AclItem *aip, AclItem *aip,
...@@ -292,7 +292,7 @@ aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode) ...@@ -292,7 +292,7 @@ aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode)
/* if no acl is found, use world default */ /* if no acl is found, use world default */
if (!acl) if (!acl)
{ {
acl = acldefault(); acl = acldefault(relname);
} }
num = ACL_NUM(acl); num = ACL_NUM(acl);
...@@ -475,7 +475,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode) ...@@ -475,7 +475,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
Anum_pg_class_relowner, Anum_pg_class_relowner,
RelationGetTupleDescriptor(relation), RelationGetTupleDescriptor(relation),
(bool *) NULL); (bool *) NULL);
acl = aclownerdefault(ownerId); acl = aclownerdefault(relname, ownerId);
} }
#else #else
{ /* This is why the syscache is great... */ { /* This is why the syscache is great... */
...@@ -511,7 +511,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode) ...@@ -511,7 +511,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
heap_close(relation); heap_close(relation);
} }
#endif #endif
result = aclcheck(acl, id, (AclIdType) ACL_IDTYPE_UID, mode); result = aclcheck(relname, acl, id, (AclIdType) ACL_IDTYPE_UID, mode);
if (acl) if (acl)
pfree(acl); pfree(acl);
return (result); return (result);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.24 1998/02/11 19:12:03 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.25 1998/02/24 03:31:47 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <utils/memutils.h> #include <utils/memutils.h>
#include "utils/acl.h" #include "utils/acl.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#include "catalog/catalog.h"
#include "catalog/pg_user.h" #include "catalog/pg_user.h"
#include "miscadmin.h" #include "miscadmin.h"
...@@ -342,7 +343,7 @@ aclitemgt(AclItem *a1, AclItem *a2) ...@@ -342,7 +343,7 @@ aclitemgt(AclItem *a1, AclItem *a2)
} }
Acl * Acl *
aclownerdefault(AclId ownerid) aclownerdefault(char *relname, AclId ownerid)
{ {
Acl *acl; Acl *acl;
AclItem *aip; AclItem *aip;
...@@ -351,7 +352,7 @@ aclownerdefault(AclId ownerid) ...@@ -351,7 +352,7 @@ aclownerdefault(AclId ownerid)
aip = ACL_DAT(acl); aip = ACL_DAT(acl);
aip[0].ai_idtype = ACL_IDTYPE_WORLD; aip[0].ai_idtype = ACL_IDTYPE_WORLD;
aip[0].ai_id = ACL_ID_WORLD; aip[0].ai_id = ACL_ID_WORLD;
aip[0].ai_mode = ACL_WORLD_DEFAULT; aip[0].ai_mode = IsSystemRelationName(relname) ? ACL_RD : ACL_WORLD_DEFAULT;
aip[1].ai_idtype = ACL_IDTYPE_UID; aip[1].ai_idtype = ACL_IDTYPE_UID;
aip[1].ai_id = ownerid; aip[1].ai_id = ownerid;
aip[1].ai_mode = ACL_OWNER_DEFAULT; aip[1].ai_mode = ACL_OWNER_DEFAULT;
...@@ -359,7 +360,7 @@ aclownerdefault(AclId ownerid) ...@@ -359,7 +360,7 @@ aclownerdefault(AclId ownerid)
} }
Acl * Acl *
acldefault(void) acldefault(char *relname)
{ {
Acl *acl; Acl *acl;
AclItem *aip; AclItem *aip;
...@@ -368,7 +369,7 @@ acldefault(void) ...@@ -368,7 +369,7 @@ acldefault(void)
aip = ACL_DAT(acl); aip = ACL_DAT(acl);
aip[0].ai_idtype = ACL_IDTYPE_WORLD; aip[0].ai_idtype = ACL_IDTYPE_WORLD;
aip[0].ai_id = ACL_ID_WORLD; aip[0].ai_id = ACL_ID_WORLD;
aip[0].ai_mode = ACL_WORLD_DEFAULT; aip[0].ai_mode = IsSystemRelationName(relname) ? ACL_RD : ACL_WORLD_DEFAULT;
return (acl); return (acl);
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: acl.h,v 1.14 1998/02/23 18:43:13 scrappy Exp $ * $Id: acl.h,v 1.15 1998/02/24 03:31:50 scrappy Exp $
* *
* NOTES * NOTES
* For backward-compatability purposes we have to allow there * For backward-compatability purposes we have to allow there
...@@ -135,8 +135,8 @@ extern char *aclcheck_error_strings[]; ...@@ -135,8 +135,8 @@ extern char *aclcheck_error_strings[];
/* /*
* routines used internally (parser, etc.) * routines used internally (parser, etc.)
*/ */
extern Acl *aclownerdefault(AclId ownerid); extern Acl *aclownerdefault(char *relname, AclId ownerid);
extern Acl *acldefault(void); extern Acl *acldefault(char *relname);
extern Acl *aclinsert3(Acl *old_acl, AclItem *mod_aip, unsigned modechg); extern Acl *aclinsert3(Acl *old_acl, AclItem *mod_aip, unsigned modechg);
extern char *aclmakepriv(char *old_privlist, char new_priv); extern char *aclmakepriv(char *old_privlist, char new_priv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment