4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-18 20:39:33 +08:00

aclsort: Honor calclass argument and allow recalculating ACL mask.

* sec_acl.cc (__aclcalcmask): New function to recalculate ACL masks.
        (aclsort32): Honor calclass argument.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2015-12-24 00:48:20 +01:00
parent 7a1ac642f6
commit ed3c07215c
2 changed files with 26 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2015-12-24 Corinna Vinschen <corinna@vinschen.de>
* sec_acl.cc (__aclcalcmask): New function to recalculate ACL masks.
(aclsort32): Honor calclass argument.
2015-12-24 Corinna Vinschen <corinna@vinschen.de>
* sec_acl.cc (aclfromtext32): Return missing aclcnt parameter.

View File

@ -1295,6 +1295,24 @@ aclcheck32 (aclent_t *aclbufp, int nentries, int *which)
return 0;
}
void
__aclcalcmask (aclent_t *aclbufp, int nentries)
{
acl_perm_t mask = 0;
int mask_idx = -1;
for (int idx = 0; idx < nentries; ++idx)
{
if (aclbufp[idx].a_type == CLASS_OBJ)
mask_idx = idx;
else if (aclbufp[idx].a_type
& (USER | GROUP_OBJ | GROUP))
mask |= aclbufp[idx].a_perm;
}
if (mask_idx != -1)
aclbufp[mask_idx].a_perm = mask;
}
static int
acecmp (const void *a1, const void *a2)
{
@ -1307,7 +1325,7 @@ acecmp (const void *a1, const void *a2)
}
extern "C" int
aclsort32 (int nentries, int, aclent_t *aclbufp)
aclsort32 (int nentries, int calclass, aclent_t *aclbufp)
{
if (aclcheck32 (aclbufp, nentries, NULL))
{
@ -1320,6 +1338,8 @@ aclsort32 (int nentries, int, aclent_t *aclbufp)
return -1;
}
qsort ((void *) aclbufp, nentries, sizeof (aclent_t), acecmp);
if (calclass)
__aclcalcmask (aclbufp, nentries);
return 0;
}