PERFORCE change 146802 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Wed Aug 6 21:25:49 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=146802
Change 146802 by trasz at trasz_traszkan on 2008/08/06 21:25:34
Make error messages produced by acl_from_text more understandable.
Also, fix an error, where passing unknown user name or group name
woulnd't result in error being returned.
Affected files ...
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_from_text_nfs4.c#5 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support_nfs4.c#6 edit
Differences ...
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_from_text_nfs4.c#5 (text+ko) ====
@@ -65,7 +65,7 @@
if (strcmp(str, "group") == 0 || strcmp(str, "g") == 0)
return (acl_set_tag_type(entry, ACL_GROUP));
- warnx("Malformed \"tag\" field.");
+ warnx("malformed ACL: invalid \"tag\" field");
return (-1);
}
@@ -83,7 +83,7 @@
qualifier_length = strlen(str);
if (qualifier_length == 0) {
- warnx("Empty qualifier.");
+ warnx("malformed ACL: empty \"qualifier\" field");
return (-1);
}
@@ -92,7 +92,8 @@
id = strtod(str, &end);
if (end - str != qualifier_length) {
- warnx("Trailing characters after numerical id.");
+ warnx("malformed ACL: trailing characters "
+ "after numerical id");
return (-1);
}
@@ -109,8 +110,8 @@
/* XXX: Thread-unsafe. */
pwd = getpwnam(str);
if (pwd == NULL) {
- warnx("Unknown user: %s", str);
- return (0);
+ warnx("malformed ACL: unknown user \"%s\"", str);
+ return (-1);
}
return (acl_set_qualifier(entry, &(pwd->pw_uid)));
@@ -119,8 +120,8 @@
/* XXX: Thread-unsafe. */
grp = getgrnam(str);
if (grp == NULL) {
- warnx("Unknown group: %s", str);
- return (0);
+ warnx("malformed ACL: unknown group \"%s\"", str);
+ return (-1);
}
return (acl_set_qualifier(entry, &(grp->gr_gid)));
@@ -132,10 +133,8 @@
int error, perm;
error = _nfs4_parse_access_mask(str, &perm);
- if (error) {
- warnx("Malformed \"access mask\" field.");
+ if (error)
return (error);
- }
error = acl_set_permset(entry, &perm);
@@ -148,10 +147,8 @@
int error, flags;
error = _nfs4_parse_flags(str, &flags);
- if (error) {
- warnx("Malformed \"flags\" field.");
+ if (error)
return (error);
- }
error = acl_set_flagset_np(entry, &flags);
@@ -173,7 +170,7 @@
if (strcmp(str, "alarm") == 0)
return (acl_set_extended_np(entry, ACL_EXTENDED_ALARM));
- warnx("Malformed \"extended\" field.");
+ warnx("malformed ACL: invalid \"type\" field");
return (-1);
}
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support_nfs4.c#6 (text+ko) ====
@@ -129,7 +129,8 @@
static int
parse_flags_verbose(const char *strp, uint32_t *var,
- const struct flagnames_struct *flags, int *try_compact)
+ const struct flagnames_struct *flags, const char *flags_name,
+ int *try_compact)
{
int i, found, ever_found = 0;
char *str, *flag;
@@ -152,7 +153,8 @@
if (!found) {
if (ever_found)
- warnx("Invalid flag: %s.", flag);
+ warnx("malformed ACL: \"%s\" field contains "
+ "invalid flag \"%s\"", flags_name, flag);
else
*try_compact = 1;
free(str);
@@ -166,7 +168,7 @@
static int
parse_flags_compact(const char *str, uint32_t *var,
- const struct flagnames_struct *flags)
+ const struct flagnames_struct *flags, const char *flags_name)
{
int i, j, found;
@@ -191,7 +193,8 @@
}
if (!found) {
- warnx("Invalid flag: %c.", str[i]);
+ warnx("malformed ACL: \"%s\" field contains "
+ "invalid flag \"%c\"", flags_name, str[i]);
return (-1);
}
}
@@ -220,9 +223,9 @@
{
int error, try_compact;
- error = parse_flags_verbose(str, var, a_flags, &try_compact);
+ error = parse_flags_verbose(str, var, a_flags, "flags", &try_compact);
if (error && try_compact)
- error = parse_flags_compact(str, var, a_flags);
+ error = parse_flags_compact(str, var, a_flags, "flags");
return (error);
}
@@ -232,9 +235,11 @@
{
int error, try_compact;
- error = parse_flags_verbose(str, var, a_access_masks, &try_compact);
+ error = parse_flags_verbose(str, var, a_access_masks,
+ "access permissions", &try_compact);
if (error && try_compact)
- error = parse_flags_compact(str, var, a_access_masks);
+ error = parse_flags_compact(str, var,
+ a_access_masks, "access permissions");
return (error);
}
More information about the p4-projects
mailing list