PERFORCE change 146245 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Wed Jul 30 10:02:44 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=146245
Change 146245 by trasz at trasz_traszkan on 2008/07/30 10:02:29
Implement parsing ACLs in verbose form.
Affected files ...
.. //depot/projects/soc2008/trasz_nfs4acl/TODO#22 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support_nfs4.c#5 edit
Differences ...
==== //depot/projects/soc2008/trasz_nfs4acl/TODO#22 (text+ko) ====
@@ -1,13 +1,5 @@
Things to do, in no particular order:
-- Add the ability to parse ACLs in verbose form, e.g. instead of
-
- owner@:rwx:f:allow
-
- it would be
-
- owner@:read_data/write_data/execute:file_inherit:allow
-
- Update setfacl(1) manual page.
- Either add or extend existing manual pages for new API routines:
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support_nfs4.c#5 (text+ko) ====
@@ -26,6 +26,8 @@
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <assert.h>
#include <err.h>
#include <sys/acl.h>
@@ -126,6 +128,43 @@
}
static int
+parse_flags_verbose(const char *strp, uint32_t *var,
+ const struct flagnames_struct *flags, int *try_compact)
+{
+ int i, found, ever_found = 0;
+ char *str, *flag;
+
+ str = strdup(strp);
+ *try_compact = 0;
+ *var = 0;
+
+ while (str != NULL) {
+ flag = strsep(&str, "/:");
+
+ found = 0;
+ for (i = 0; flags[i].name != NULL; i++) {
+ if (strcmp(flags[i].name, flag) == 0) {
+ *var |= flags[i].flag;
+ found = 1;
+ ever_found = 1;
+ }
+ }
+
+ if (!found) {
+ if (ever_found)
+ warnx("Invalid flag: %s.", flag);
+ else
+ *try_compact = 1;
+ free(str);
+ return (-1);
+ }
+ }
+
+ free(str);
+ return (0);
+}
+
+static int
parse_flags_compact(const char *str, uint32_t *var,
const struct flagnames_struct *flags)
{
@@ -179,12 +218,24 @@
int
_nfs4_parse_flags(const char *str, uint32_t *var)
{
- return (parse_flags_compact(str, var, a_flags));
+ int error, try_compact;
+
+ error = parse_flags_verbose(str, var, a_flags, &try_compact);
+ if (error && try_compact)
+ error = parse_flags_compact(str, var, a_flags);
+
+ return (error);
}
int
_nfs4_parse_access_mask(const char *str, uint32_t *var)
{
- return (parse_flags_compact(str, var, a_access_masks));
+ int error, try_compact;
+
+ error = parse_flags_verbose(str, var, a_access_masks, &try_compact);
+ if (error && try_compact)
+ error = parse_flags_compact(str, var, a_access_masks);
+
+ return (error);
}
More information about the p4-projects
mailing list