PERFORCE change 146217 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Tue Jul 29 17:45:03 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=146217
Change 146217 by trasz at trasz_traszkan on 2008/07/29 17:44:26
Add "-n" option to getfacl(1).
Affected files ...
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support.c#5 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support.h#7 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support_nfs4.c#4 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_to_text.c#6 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_to_text_nfs4.c#8 edit
Differences ...
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support.c#5 (text+ko) ====
@@ -302,7 +302,8 @@
* MAY HAVE SIDE-EFFECTS
*/
int
-_posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf)
+_posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf,
+ int flags)
{
struct group *g;
struct passwd *p;
@@ -310,7 +311,10 @@
switch(tag) {
case ACL_USER:
- p = getpwuid(id);
+ if (flags & ACL_TEXT_NUMERIC_IDS)
+ p = NULL;
+ else
+ p = getpwuid(id);
if (!p)
i = snprintf(buf, buf_len, "%d", id);
else
@@ -323,7 +327,10 @@
return (0);
case ACL_GROUP:
- g = getgrgid(id);
+ if (flags & ACL_TEXT_NUMERIC_IDS)
+ g = NULL;
+ else
+ g = getgrgid(id);
if (g == NULL)
i = snprintf(buf, buf_len, "%d", id);
else
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support.h#7 (text+ko) ====
@@ -53,7 +53,7 @@
int _posix1e_acl_sort(acl_t acl);
int _posix1e_acl(acl_t acl, acl_type_t type);
int _posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len,
- char *buf);
+ char *buf, int flags);
int _posix1e_acl_perm_to_string(acl_perm_t perm, ssize_t buf_len,
char *buf);
int _posix1e_acl_string_to_perm(char *string, acl_perm_t *perm);
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_support_nfs4.c#4 (text+ko) ====
@@ -99,10 +99,9 @@
off--;
/* ... then remove the last slash. */
assert(str[off] == '/');
- str[off] = '\0';
- } else {
- str[0] = '\0';
- }
+ }
+
+ str[off] = '\0';
return (0);
}
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_to_text.c#6 (text+ko) ====
@@ -54,7 +54,7 @@
char *_nfs4_acl_to_text_np(const acl_t acl, ssize_t *len_p, int flags);
static char *
-_posix1e_acl_to_text(acl_t acl, ssize_t *len_p)
+_posix1e_acl_to_text(acl_t acl, ssize_t *len_p, int flags)
{
struct acl *acl_int;
char *buf, *tmpbuf;
@@ -108,7 +108,7 @@
goto error_label;
error = _posix1e_acl_id_to_name(ae_tag, ae_id,
- UT_NAMESIZE+1, name_buf);
+ UT_NAMESIZE+1, name_buf, flags);
if (error)
goto error_label;
@@ -168,7 +168,7 @@
goto error_label;
error = _posix1e_acl_id_to_name(ae_tag, ae_id,
- UT_NAMESIZE+1, name_buf);
+ UT_NAMESIZE+1, name_buf, flags);
if (error)
goto error_label;
@@ -244,7 +244,7 @@
{
switch (_acl_brand(acl)) {
case ACL_BRAND_POSIX:
- return (_posix1e_acl_to_text(acl, len_p));
+ return (_posix1e_acl_to_text(acl, len_p, flags));
case ACL_BRAND_NFS4:
return (_nfs4_acl_to_text_np(acl, len_p, flags));
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_to_text_nfs4.c#8 (text+ko) ====
@@ -42,7 +42,7 @@
#define MAX_ENTRY_LENGTH 512
static int
-format_who(char *str, size_t size, const acl_entry_t entry)
+format_who(char *str, size_t size, const acl_entry_t entry, int numeric)
{
int error;
acl_tag_t tag;
@@ -62,7 +62,10 @@
id = (id_t *)acl_get_qualifier(entry);
assert(id);
/* XXX: Thread-unsafe. */
- pwd = getpwuid(*id);
+ if (!numeric)
+ pwd = getpwuid(*id);
+ else
+ pwd = NULL;
if (pwd == NULL)
snprintf(str, size, "user:%d", (unsigned int)*id);
else
@@ -77,7 +80,10 @@
id = (id_t *)acl_get_qualifier(entry);
assert(id);
/* XXX: Thread-unsafe. */
- grp = getgrgid(*id);
+ if (!numeric)
+ grp = getgrgid(*id);
+ else
+ grp = NULL;
if (grp == NULL)
snprintf(str, size, "group:%d", (unsigned int)*id);
else
@@ -136,12 +142,9 @@
size_t off = 0, padding_length, maximum_who_field_length = 18;
acl_permset_t permset;
acl_flagset_t flagset;
- int error, len, verbose = 0;
+ int error, len;
char buf[MAX_ENTRY_LENGTH + 1];
- if (flags & ACL_TEXT_VERBOSE)
- verbose = 1;
-
assert(_entry_brand(entry) == ACL_BRAND_NFS4);
error = acl_get_flagset_np(entry, &flagset);
@@ -152,7 +155,8 @@
if (error)
return (error);
- error = format_who(buf, sizeof(buf), entry);
+ error = format_who(buf, sizeof(buf), entry,
+ flags & ACL_TEXT_NUMERIC_IDS);
if (error)
return (error);
len = strlen(buf);
@@ -163,12 +167,14 @@
}
off += snprintf(str + off, size - off, "%s:", buf);
- error = _nfs4_format_access_mask(buf, sizeof(buf), *permset, verbose);
+ error = _nfs4_format_access_mask(buf, sizeof(buf), *permset,
+ flags & ACL_TEXT_VERBOSE);
if (error)
return (error);
off += snprintf(str + off, size - off, "%s:", buf);
- error = _nfs4_format_flags(buf, sizeof(buf), *flagset, verbose);
+ error = _nfs4_format_flags(buf, sizeof(buf), *flagset,
+ flags & ACL_TEXT_VERBOSE);
if (error)
return (error);
off += snprintf(str + off, size - off, "%s:", buf);
More information about the p4-projects
mailing list