PERFORCE change 144832 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Mon Jul 7 17:15:36 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=144832
Change 144832 by trasz at trasz_traszkan on 2008/07/07 17:15:10
Add support for printing out ACLs in verbose form. Useful, if you're
not sure if 'R' is read_attribute or read_xattr, for example.
Affected files ...
.. //depot/projects/soc2008/trasz_nfs4acl/TODO#7 edit
.. //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.c#6 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/Symbol.map#5 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_to_text.c#3 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_to_text_nfs4.c#3 edit
.. //depot/projects/soc2008/trasz_nfs4acl/sys/sys/acl.h#9 edit
Differences ...
==== //depot/projects/soc2008/trasz_nfs4acl/TODO#7 (text+ko) ====
@@ -4,7 +4,7 @@
- Add the ability to add ACE at a given position in ACL to setfacl(1),
-- Add the ability to parse and print ACLs in verbose form, e.g. instead of
+- Add the ability to parse ACLs in verbose form, e.g. instead of
owner@:rwx:f:allow
==== //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.c#6 (text+ko) ====
@@ -54,7 +54,7 @@
usage(void)
{
- fprintf(stderr, "getfacl [-dhq] [file ...]\n");
+ fprintf(stderr, "getfacl [-dhqv] [file ...]\n");
}
static char *
@@ -175,7 +175,7 @@
}
static int
-print_acl(char *path, acl_type_t type, int hflag, int qflag)
+print_acl(char *path, acl_type_t type, int hflag, int qflag, int vflag)
{
struct stat sb;
acl_t acl;
@@ -222,7 +222,7 @@
}
}
- acl_text = acl_to_text(acl, 0);
+ acl_text = acl_to_text_np(acl, 0, vflag);
if (!acl_text) {
warn("%s", path);
return(-1);
@@ -237,7 +237,7 @@
}
static int
-print_acl_from_stdin(acl_type_t type, int hflag, int qflag)
+print_acl_from_stdin(acl_type_t type, int hflag, int qflag, int vflag)
{
char *p, pathname[PATH_MAX];
int carried_error = 0;
@@ -245,7 +245,7 @@
while (fgets(pathname, (int)sizeof(pathname), stdin)) {
if ((p = strchr(pathname, '\n')) != NULL)
*p = '\0';
- if (print_acl(pathname, type, hflag, qflag) == -1) {
+ if (print_acl(pathname, type, hflag, qflag, vflag) == -1) {
carried_error = -1;
}
}
@@ -259,11 +259,12 @@
acl_type_t type = ACL_TYPE_ACCESS;
int carried_error = 0;
int ch, error, i;
- int hflag, qflag;
+ int hflag, qflag, vflag;
hflag = 0;
qflag = 0;
- while ((ch = getopt(argc, argv, "dhq")) != -1)
+ vflag = 0;
+ while ((ch = getopt(argc, argv, "dhqv")) != -1)
switch(ch) {
case 'd':
type = ACL_TYPE_DEFAULT;
@@ -274,6 +275,9 @@
case 'q':
qflag = 1;
break;
+ case 'v':
+ vflag = 1;
+ break;
default:
usage();
return(-1);
@@ -282,17 +286,17 @@
argv += optind;
if (argc == 0) {
- error = print_acl_from_stdin(type, hflag, qflag);
+ error = print_acl_from_stdin(type, hflag, qflag, vflag);
return(error ? 1 : 0);
}
for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-")) {
- error = print_acl_from_stdin(type, hflag, qflag);
+ error = print_acl_from_stdin(type, hflag, qflag, vflag);
if (error == -1)
carried_error = -1;
} else {
- error = print_acl(argv[i], type, hflag, qflag);
+ error = print_acl(argv[i], type, hflag, qflag, vflag);
if (error == -1)
carried_error = -1;
}
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/Symbol.map#5 (text) ====
@@ -48,6 +48,7 @@
acl_set_qualifier;
acl_set_tag_type;
acl_to_text;
+ acl_to_text_np;
acl_valid;
acl_valid_file_np;
acl_valid_link_np;
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_to_text.c#3 (text+ko) ====
@@ -51,7 +51,7 @@
* a non-POSIX.1e semantics ACL.
*/
-char *_nfs4_acl_to_text(const acl_t acl, ssize_t *len_p);
+char *_nfs4_acl_to_text_np(const acl_t acl, ssize_t *len_p, int verbose);
static char *
_posix1e_acl_to_text(acl_t acl, ssize_t *len_p)
@@ -240,11 +240,17 @@
}
char *
-acl_to_text(acl_t acl, ssize_t *len_p)
+acl_to_text_np(acl_t acl, ssize_t *len_p, int verbose)
{
if (_acl_is_nfs4(acl))
- return (_nfs4_acl_to_text(acl, len_p));
+ return (_nfs4_acl_to_text_np(acl, len_p, verbose));
return (_posix1e_acl_to_text(acl, len_p));
}
+char *
+acl_to_text(acl_t acl, ssize_t *len_p)
+{
+ return (acl_to_text_np(acl, len_p, 0));
+}
+
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_to_text_nfs4.c#3 (text+ko) ====
@@ -132,7 +132,7 @@
}
static int
-format_entry_compact(char *str, size_t size, const acl_entry_t entry)
+format_entry(char *str, size_t size, const acl_entry_t entry, int verbose)
{
size_t off = 0, maximum_who_field_length = 18;
acl_permset_t permset;
@@ -152,9 +152,9 @@
off += add_padding(str, size - off, maximum_who_field_length - off);
off += snprintf(str + off, size - off, ":");
- off += _nfs4_format_access_mask(str + off, size - off, *permset, 0);
+ off += _nfs4_format_access_mask(str + off, size - off, *permset, verbose);
off += snprintf(str + off, size - off, ":");
- off += _nfs4_format_flags(str + off, size - off, *flagset, 0);
+ off += _nfs4_format_flags(str + off, size - off, *flagset, verbose);
off += snprintf(str + off, size - off, ":");
off += format_extended(str + off, size - off, entry);
@@ -165,7 +165,7 @@
}
char *
-_nfs4_acl_to_text(const acl_t aclp, ssize_t *len_p)
+_nfs4_acl_to_text_np(const acl_t aclp, ssize_t *len_p, int verbose)
{
int off = 0, size, entry_id = ACL_FIRST_ENTRY;
char *str;
@@ -184,7 +184,7 @@
assert(off < size);
- off += format_entry_compact(str + off, size - off, entry);
+ off += format_entry(str + off, size - off, entry, verbose);
off += snprintf(str + off, size - off, "\n");
}
==== //depot/projects/soc2008/trasz_nfs4acl/sys/sys/acl.h#9 (text+ko) ====
@@ -344,6 +344,7 @@
int acl_set_tag_type(acl_entry_t _entry_d, acl_tag_t _tag_type);
ssize_t acl_size(acl_t _acl);
char *acl_to_text(acl_t _acl, ssize_t *_len_p);
+char *acl_to_text_np(acl_t _acl, ssize_t *_len_p, int _verbose);
int acl_valid(acl_t _acl);
int acl_valid_fd_np(int _fd, acl_type_t _type, acl_t _acl);
int acl_valid_file_np(const char *_path_p, acl_type_t _type, acl_t _acl);
More information about the p4-projects
mailing list