--- sec_acl-orig.cc 2006-07-18 17:52:13.421875000 +0200 +++ sec_acl.cc 2006-07-20 09:20:27.562500000 +0200 @@ -727,7 +727,7 @@ acltotext32 (__aclent32_t *aclbufp, int strcat (buf, ","); first = false; if (aclbufp[pos].a_type & ACL_DEFAULT) - strcat (buf, "default"); + strcat (buf, "default:"); /* use Sun and Linux compatible output format */ switch (aclbufp[pos].a_type & ~ACL_DEFAULT) { case USER_OBJ: @@ -785,11 +785,13 @@ permfromstr (char *perm) } extern "C" __aclent32_t * -aclfromtext32 (char *acltextp, int *) +aclfromtext32 (char *acltextp, int *aclcnt) { + /* parameter aclcnt returns the number of ACL entries found */ if (!acltextp) { set_errno (EINVAL); + *aclcnt = 0; return NULL; } char buf[strlen (acltextp) + 1]; @@ -802,25 +804,29 @@ aclfromtext32 (char *acltextp, int *) c; c = strtok_r (NULL, ",", &lasts)) { - if (!strncmp (c, "default", 7)) + if (!strncmp(c, "d:", 2) || !strncmp(c, "default:", 8)) { lacl[pos].a_type |= ACL_DEFAULT; - c += 7; + c += (c[2] == ':') ? 3 : 8; } - if (!strncmp (c, "user:", 5)) + if (!strncmp(c, "u:", 2) || !strncmp (c, "user:", 5)) { - if (c[5] == ':') - lacl[pos].a_type |= USER_OBJ; + if ((c[2] == ':') || (c[5] == ':')) + { + lacl[pos].a_type |= USER_OBJ; + c += (c[2] == ':') ? 3 : 6; + } else { lacl[pos].a_type |= USER; - c += 5; + c += (c[1] == ':') ? 2 : 5; if (isalpha (*c)) { struct passwd *pw = internal_getpwnam (c); if (!pw) { set_errno (EINVAL); + *aclcnt = 0; return NULL; } lacl[pos].a_id = pw->pw_uid; @@ -828,27 +834,32 @@ aclfromtext32 (char *acltextp, int *) } else if (isdigit (*c)) lacl[pos].a_id = strtol (c, &c, 10); - if (*c != ':') + if (*c++ != ':') { set_errno (EINVAL); + *aclcnt = 0; return NULL; } } } - else if (!strncmp (c, "group:", 6)) + else if (!strncmp (c, "g:", 2) || !strncmp (c, "group:", 6)) { - if (c[5] == ':') - lacl[pos].a_type |= GROUP_OBJ; + if ((c[2] == ':') || (c[6] == ':')) + { + lacl[pos].a_type |= GROUP_OBJ; + c += (c[2] == ':') ? 3 : 7; + } else { lacl[pos].a_type |= GROUP; - c += 5; + c += (c[1] == ':') ? 2 : 6; if (isalpha (*c)) { struct __group32 *gr = internal_getgrnam (c); if (!gr) { set_errno (EINVAL); + *aclcnt = 0; return NULL; } lacl[pos].a_id = gr->gr_gid; @@ -856,40 +867,51 @@ aclfromtext32 (char *acltextp, int *) } else if (isdigit (*c)) lacl[pos].a_id = strtol (c, &c, 10); - if (*c != ':') + if (*c++ != ':') { set_errno (EINVAL); + *aclcnt = 0; return NULL; } } } - else if (!strncmp (c, "mask:", 5)) + else if (!strncmp (c, "m:", 2) || !strncmp (c, "mask:", 5)) { - if (c[5] == ':') - lacl[pos].a_type |= CLASS_OBJ; + if ((c[2] == ':') || (c[5] == ':')) + { + lacl[pos].a_type |= CLASS_OBJ; + c += (c[2] == ':') ? 3 : 6; + } else { set_errno (EINVAL); + *aclcnt = 0; return NULL; } } - else if (!strncmp (c, "other:", 6)) + else if (!strncmp (c, "o:", 2) || !strncmp (c, "other:", 6)) { - if (c[5] == ':') - lacl[pos].a_type |= OTHER_OBJ; + if ((c[2] == ':') || (c[6] == ':')) + { + lacl[pos].a_type |= OTHER_OBJ; + c += (c[2] == ':') ? 3 : 7; + } else { set_errno (EINVAL); + *aclcnt = 0; return NULL; } } if ((lacl[pos].a_perm = permfromstr (c)) == 01000) { set_errno (EINVAL); + *aclcnt = 0; return NULL; } ++pos; } + *aclcnt = pos; /* set number of ACL entries */ __aclent32_t *aclp = (__aclent32_t *) malloc (pos * sizeof (__aclent32_t)); if (aclp) memcpy (aclp, lacl, pos * sizeof (__aclent32_t));