char *name;
int type;
} acl_flags[] = {
+ {ACL_ENTRY_INHERITED, "inherited", ACL_TYPE_FILE | ACL_TYPE_DIR},
{ACL_FLAG_DEFER_INHERIT, "defer_inherit", ACL_TYPE_ACL},
{ACL_ENTRY_FILE_INHERIT, "file_inherit", ACL_TYPE_DIR},
{ACL_ENTRY_DIRECTORY_INHERIT, "directory_inherit", ACL_TYPE_DIR},
va_start(ap, fmt);
ret = vsnprintf(*buf + *offset, *size - *offset, fmt, ap);
va_end(ap);
- if (ret < *size)
+ if (ret < (*size - *offset))
{
*offset += ret;
return ret;
}
}
- *buf = realloc(*buf, (*size *= 2));
+ *buf = reallocf(*buf, (*size *= 2));
} while (*buf);
- //warn("realloc failure");
+ //warn("reallocf failure");
return 0;
}
errout: ; //warn("Unable to translate qualifier on ACL\n");
}
}
- return "";
+ return strdup("");
}
acl_t
need_tag = 0;
}
/* name */
- if ((field = strtok_r(NULL, ":", &last_field)) != NULL && need_tag)
+ if (*last_field == ':') // empty username field
+ last_field++;
+ else if ((field = strtok_r(NULL, ":", &last_field)) != NULL && need_tag)
{
switch(ug_tag)
{
need_tag = 0;
}
/* uid */
- if ((field = strtok_r(NULL, ":", &last_field)) != NULL && need_tag)
+ if (*last_field == ':') // empty uid field
+ last_field++;
+ else if ((field = strtok_r(NULL, ":", &last_field)) != NULL && need_tag)
{
uid_t id;
error = 0;
}
}
- if((field = strtok_r(NULL, ":", &last_field)) == NULL)
- {
- error = EINVAL;
- goto exit;
- }
-
- for (sub = strtok_r(field, ",", &last_sub); sub;
- sub = strtok_r(NULL, ",", &last_sub))
- {
- for (i = 0; acl_perms[i].name != NULL; i++)
+ if((field = strtok_r(NULL, ":", &last_field)) != NULL) {
+ for (sub = strtok_r(field, ",", &last_sub); sub;
+ sub = strtok_r(NULL, ",", &last_sub))
{
- if (acl_perms[i].type & (ACL_TYPE_FILE | ACL_TYPE_DIR)
- && !strcmp(acl_perms[i].name, sub))
+ for (i = 0; acl_perms[i].name != NULL; i++)
{
- acl_add_perm(perms, acl_perms[i].perm);
- break;
+ if (acl_perms[i].type & (ACL_TYPE_FILE | ACL_TYPE_DIR)
+ && !strcmp(acl_perms[i].name, sub))
+ {
+ acl_add_perm(perms, acl_perms[i].perm);
+ break;
+ }
+ }
+ if (acl_perms[i].name == NULL)
+ {
+ /* couldn't find perm */
+ error = EINVAL;
+ goto exit;
}
- }
- if (acl_perms[i].name == NULL)
- {
- /* couldn't find perm */
- error = EINVAL;
- goto exit;
}
}
acl_set_tag_type(acl_entry, tag);
char *str, uu_str[256];
int i, first;
int isgid;
-
size_t bufsize = 1024;
- char *buf = malloc(bufsize);
+ char *buf;
+
+ if (!_ACL_VALID_ACL(acl)) {
+ errno = EINVAL;
+ return NULL;
+ }
+ buf = malloc(bufsize);
if (len_p == NULL)
len_p = alloca(sizeof(ssize_t));
*len_p = 0;
- if(!raosnprintf(&buf, &bufsize, len_p, "!#acl %d", 1))
+ if (!raosnprintf(&buf, &bufsize, len_p, "!#acl %d", 1))
return NULL;
if (acl_get_flagset_np(acl, &flags) == 0)
}
}
buf[(*len_p)++] = '\n';
- buf[(*len_p)++] = 0;
+ buf[(*len_p)] = 0;
return buf;
}