acl problem in NetBSD/m68k

Поиск
Список
Период
Сортировка
От Tatsuo Ishii
Тема acl problem in NetBSD/m68k
Дата
Msg-id 199906290301.MAA24508@ext16.sra.co.jp
обсуждение исходный текст
Ответы Re: [HACKERS] acl problem in NetBSD/m68k  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
grant/revoke does not work in NetBSD/m68k. This is due to the wrong
assumption that sizeof(AclItem) is equal to 8 in all platforms. I am
going to fix this by replacing all occurrence of sizeof(AclItem) to
ACLITEM_SIZE (newly defined as 8 in catalog/pg_type.h). See included
patches. If there's no objection, I will commit them. Comments?
---
Tatsuo Ishii

--------------------------- cut here ----------------------------------
*** pgsql/src/backend/utils/adt/acl.c~    Wed May 26 01:11:49 1999
--- pgsql/src/backend/utils/adt/acl.c    Tue Jun 29 09:18:18 1999
***************
*** 235,241 ****     if (!s)         elog(ERROR, "aclitemin: null string"); 
!     aip = (AclItem *) palloc(sizeof(AclItem));     if (!aip)         elog(ERROR, "aclitemin: palloc failed");     s =
aclparse(s,aip, &modechg);
 
--- 235,241 ----     if (!s)         elog(ERROR, "aclitemin: null string"); 
!     aip = (AclItem *) palloc(ACLITEM_SIZE);     if (!aip)         elog(ERROR, "aclitemin: palloc failed");     s =
aclparse(s,aip, &modechg);
 
***************
*** 445,460 ****         {                        /* end */             memmove((char *) new_aip,
(char*) old_aip,
 
!                     num * sizeof(AclItem));         }         else         {                        /* middle */
      memmove((char *) new_aip,                     (char *) old_aip,
 
!                     dst * sizeof(AclItem));             memmove((char *) (new_aip + dst + 1),
(char*) (old_aip + dst),
 
!                     (num - dst) * sizeof(AclItem));         }         new_aip[dst].ai_id = mod_aip->ai_id;
new_aip[dst].ai_idtype= mod_aip->ai_idtype;
 
--- 445,460 ----         {                        /* end */             memmove((char *) new_aip,
(char*) old_aip,
 
!                     num * ACLITEM_SIZE);         }         else         {                        /* middle */
   memmove((char *) new_aip,                     (char *) old_aip,
 
!                     dst * ACLITEM_SIZE);             memmove((char *) (new_aip + dst + 1),                     (char
*)(old_aip + dst),
 
!                     (num - dst) * ACLITEM_SIZE);         }         new_aip[dst].ai_id = mod_aip->ai_id;
new_aip[dst].ai_idtype= mod_aip->ai_idtype;
 
***************
*** 493,499 ****             }             ARR_DIMS(new_acl)[0] = num - 1;             /* Adjust also the array size
becauseit is used for memmove */
 
!             ARR_SIZE(new_acl) -= sizeof(AclItem);             break;         }     }
--- 493,499 ----             }             ARR_DIMS(new_acl)[0] = num - 1;             /* Adjust also the array size
becauseit is used for memmove */
 
!             ARR_SIZE(new_acl) -= ACLITEM_SIZE;             break;         }     }
***************
*** 556,571 ****         {                        /* end */             memmove((char *) new_aip,
(char*) old_aip,
 
!                     new_num * sizeof(AclItem));         }         else         {                        /* middle */
          memmove((char *) new_aip,                     (char *) old_aip,
 
!                     dst * sizeof(AclItem));             memmove((char *) (new_aip + dst),                     (char
*)(old_aip + dst + 1),
 
!                     (new_num - dst) * sizeof(AclItem));         }     }     return new_acl;
--- 556,571 ----         {                        /* end */             memmove((char *) new_aip,
(char*) old_aip,
 
!                     new_num * ACLITEM_SIZE);         }         else         {                        /* middle */
       memmove((char *) new_aip,                     (char *) old_aip,
 
!                     dst * ACLITEM_SIZE);             memmove((char *) (new_aip + dst),                     (char *)
(old_aip+ dst + 1),
 
!                     (new_num - dst) * ACLITEM_SIZE);         }     }     return new_acl;
***************
*** 682,688 ****     ChangeACLStmt *n = makeNode(ChangeACLStmt);     char        str[MAX_PARSE_BUFFER]; 
!     n->aclitem = (AclItem *) palloc(sizeof(AclItem));      /* the grantee string is "G <group_name>", "U
<user_name>",or "ALL" */     if (grantee[0] == 'G')        /* group permissions */
 
--- 682,688 ----     ChangeACLStmt *n = makeNode(ChangeACLStmt);     char        str[MAX_PARSE_BUFFER]; 
!     n->aclitem = (AclItem *) palloc(ACLITEM_SIZE);      /* the grantee string is "G <group_name>", "U  <user_name>",
or"ALL" */     if (grantee[0] == 'G')        /* group permissions */
 
*** pgsql/src/include/catalog/pg_type.h~    Wed May 26 01:13:48 1999
--- pgsql/src/include/catalog/pg_type.h    Tue Jun 29 09:13:46 1999
***************
*** 341,348 **** DATA(insert OID = 1025 (  _tinterval PGUID -1  -1 f b t \054 0 704 array_in array_out array_in
array_outi _null_ )); DATA(insert OID = 1026 (  _filename  PGUID -1  -1 f b t \054 0 605 array_in array_out array_in
array_outi _null_ )); DATA(insert OID = 1027 (  _polygon     PGUID -1  -1 f b t \054 0 604 array_in array_out array_in
array_outd _null_ ));
 
- /* Note: the size of an aclitem needs to match sizeof(AclItem) in acl.h */ DATA(insert OID = 1033 (  aclitem
PGUID8   -1 f b t \054 0 0 aclitemin aclitemout aclitemin aclitemout i _null_ )); DESCR("access control list");
DATA(insertOID = 1034 (  _aclitem     PGUID -1 -1 f b t \054 0 1033 array_in array_out array_in array_out i _null_ ));
DATA(insertOID = 1040 (  _macaddr     PGUID -1 -1 f b t \054 0  829 array_in array_out array_in array_out i _null_ ));
 
--- 341,348 ---- DATA(insert OID = 1025 (  _tinterval PGUID -1  -1 f b t \054 0 704 array_in array_out array_in
array_outi _null_ )); DATA(insert OID = 1026 (  _filename  PGUID -1  -1 f b t \054 0 605 array_in array_out array_in
array_outi _null_ )); DATA(insert OID = 1027 (  _polygon     PGUID -1  -1 f b t \054 0 604 array_in array_out array_in
array_outd _null_ )); DATA(insert OID = 1033 (  aclitem     PGUID 8   -1 f b t \054 0 0 aclitemin aclitemout aclitemin
aclitemouti _null_ ));
 
+ #define ACLITEM_SIZE 8 DESCR("access control list"); DATA(insert OID = 1034 (  _aclitem     PGUID -1 -1 f b t \054 0
1033array_in array_out array_in array_out i _null_ )); DATA(insert OID = 1040 (  _macaddr     PGUID -1 -1 f b t \054 0
829array_in array_out array_in array_out i _null_ ));
 
*** pgsql/src/include/utils/acl.h~    Sun Feb 14 08:22:14 1999
--- pgsql/src/include/utils/acl.h    Tue Jun 29 09:17:40 1999
***************
*** 24,29 ****
--- 24,30 ----  #include <nodes/parsenodes.h> #include <utils/array.h>
+ #include <catalog/pg_type.h>  /*  * AclId        system identifier for the user, group, etc.
***************
*** 79,84 ****
--- 80,92 ---- /* Note: if the size of AclItem changes,    change the aclitem typlen in pg_type.h */ 
+ /* There used to be a wrong assumption that sizeof(AclItem) was
+    always same in all platforms.
+    Of course this is not true for certain platform (for example
+    NetBSD/m68k). For now we use ACLITEM_SIZE defined in catalog/pg_type.h
+    instead of sizeof(AclItem) -- 1999/6/29 Tatsuo
+    */
+  /*  * The value of the first dimension-array element.    Since these arrays  * always have a lower-bound of 0, this
isthe same as the number of
 
***************
*** 94,100 **** #define ACL_NUM(ACL)            ARR_DIM0(ACL) #define ACL_DAT(ACL)            ((AclItem *)
ARR_DATA_PTR(ACL))#define ACL_N_SIZE(N) \
 
!         ((unsigned) (ARR_OVERHEAD(1) + ((N) * sizeof(AclItem)))) #define ACL_SIZE(ACL)            ARR_SIZE(ACL)  /*
--- 102,108 ---- #define ACL_NUM(ACL)            ARR_DIM0(ACL) #define ACL_DAT(ACL)            ((AclItem *)
ARR_DATA_PTR(ACL))#define ACL_N_SIZE(N) \
 
!         ((unsigned) (ARR_OVERHEAD(1) + ((N) * ACLITEM_SIZE))) #define ACL_SIZE(ACL)            ARR_SIZE(ACL)  /*


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: 6.5.1 status
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] acl problem in NetBSD/m68k