From owner-p4-projects@FreeBSD.ORG Sat Aug 9 18:04:56 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3B57F10656C8; Sat, 9 Aug 2008 18:04:56 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F365F106567F for ; Sat, 9 Aug 2008 18:04:55 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id DDF018FC13 for ; Sat, 9 Aug 2008 18:04:55 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m79I4tGC027906 for ; Sat, 9 Aug 2008 18:04:55 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m79I4t03027903 for perforce@freebsd.org; Sat, 9 Aug 2008 18:04:55 GMT (envelope-from trasz@freebsd.org) Date: Sat, 9 Aug 2008 18:04:55 GMT Message-Id: <200808091804.m79I4t03027903@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Cc: Subject: PERFORCE change 147003 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Aug 2008 18:04:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=147003 Change 147003 by trasz@trasz_traszkan on 2008/08/09 18:04:38 Add ACL_TEXT_APPEND_ID. This is mostly useful for tar(1). Affected files ... .. //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.1#6 edit .. //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.c#10 edit .. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_to_text_nfs4.c#9 edit .. //depot/projects/soc2008/trasz_nfs4acl/sys/sys/acl.h#17 edit Differences ... ==== //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.1#6 (text+ko) ==== @@ -38,7 +38,7 @@ .Nd get ACL information .Sh SYNOPSIS .Nm -.Op Fl dhnqv +.Op Fl dhinqv .Op Ar .Sh DESCRIPTION The @@ -65,9 +65,13 @@ .It Fl h If the target of the operation is a symbolic link, return the ACL from the symbolic link itself rather than following the link. +.It Fl i +For NFS4 ACLs, append numerical ID at the end of each entry containing +user or group name. .It Fl n Display user and group IDs numerically rather than converting to a user or group name. +For POSIX.1e ACLs, this option does nothing. .It Fl q Do not write commented information about file name and ownership. This is ==== //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.c#10 (text+ko) ==== @@ -175,7 +175,8 @@ } static int -print_acl(char *path, acl_type_t type, int hflag, int nflag, int qflag, int vflag) +print_acl(char *path, acl_type_t type, int hflag, int iflag, int nflag, + int qflag, int vflag) { struct stat sb; acl_t acl; @@ -222,12 +223,15 @@ } } - if (vflag) - flags |= ACL_TEXT_VERBOSE; + if (iflag) + flags |= ACL_TEXT_APPEND_ID; if (nflag) flags |= ACL_TEXT_NUMERIC_IDS; + if (vflag) + flags |= ACL_TEXT_VERBOSE; + acl_text = acl_to_text_np(acl, 0, flags); if (!acl_text) { warn("%s: acl_to_text_np() failed", path); @@ -243,7 +247,8 @@ } static int -print_acl_from_stdin(acl_type_t type, int hflag, int nflag, int qflag, int vflag) +print_acl_from_stdin(acl_type_t type, int hflag, int iflag, int nflag, + int qflag, int vflag) { char *p, pathname[PATH_MAX]; int carried_error = 0; @@ -251,7 +256,8 @@ while (fgets(pathname, (int)sizeof(pathname), stdin)) { if ((p = strchr(pathname, '\n')) != NULL) *p = '\0'; - if (print_acl(pathname, type, hflag, nflag, qflag, vflag) == -1) { + if (print_acl(pathname, type, hflag, iflag, nflag, + qflag, vflag) == -1) { carried_error = -1; } } @@ -265,13 +271,14 @@ acl_type_t type = ACL_TYPE_ACCESS; int carried_error = 0; int ch, error, i; - int hflag, qflag, nflag, vflag; + int hflag, iflag, qflag, nflag, vflag; hflag = 0; + iflag = 0; qflag = 0; nflag = 0; vflag = 0; - while ((ch = getopt(argc, argv, "dhnqv")) != -1) + while ((ch = getopt(argc, argv, "dhinqv")) != -1) switch(ch) { case 'd': type = ACL_TYPE_DEFAULT; @@ -279,6 +286,9 @@ case 'h': hflag = 1; break; + case 'i': + iflag = 1; + break; case 'n': nflag = 1; break; @@ -296,19 +306,20 @@ argv += optind; if (argc == 0) { - error = print_acl_from_stdin(type, hflag, nflag, qflag, vflag); + error = print_acl_from_stdin(type, hflag, iflag, nflag, + qflag, vflag); return(error ? 1 : 0); } for (i = 0; i < argc; i++) { if (!strcmp(argv[i], "-")) { - error = print_acl_from_stdin(type, hflag, nflag, qflag, - vflag); + error = print_acl_from_stdin(type, hflag, iflag, nflag, + qflag, vflag); if (error == -1) carried_error = -1; } else { - error = print_acl(argv[i], type, hflag, nflag, qflag, - vflag); + error = print_acl(argv[i], type, hflag, iflag, nflag, + qflag, vflag); if (error == -1) carried_error = -1; } ==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_to_text_nfs4.c#9 (text+ko) ==== @@ -137,6 +137,32 @@ } static int +format_additional_id(char *str, size_t size, const acl_entry_t entry) +{ + int error; + acl_tag_t tag; + id_t *id; + + error = acl_get_tag_type(entry, &tag); + assert(!error); + + switch (tag) { + case ACL_USER_OBJ: + case ACL_GROUP_OBJ: + case ACL_EVERYONE: + str[0] = '\0'; + break; + + default: + id = (id_t *)acl_get_qualifier(entry); + assert(id); + snprintf(str, size, ":%d", (unsigned int)*id); + } + + return (0); +} + +static int format_entry(char *str, size_t size, const acl_entry_t entry, int flags) { size_t off = 0, padding_length, maximum_who_field_length = 18; @@ -182,7 +208,16 @@ error = format_extended(buf, sizeof(buf), entry); if (error) return (error); - off += snprintf(str + off, size - off, "%s\n", buf); + off += snprintf(str + off, size - off, "%s", buf); + + if (flags & ACL_TEXT_APPEND_ID) { + error = format_additional_id(buf, sizeof(buf), entry); + if (error) + return (error); + off += snprintf(str + off, size - off, "%s", buf); + } + + off += snprintf(str + off, size - off, "\n"); /* Make sure we didn't truncate anything. */ assert (off < size); ==== //depot/projects/soc2008/trasz_nfs4acl/sys/sys/acl.h#17 (text+ko) ==== @@ -231,6 +231,7 @@ */ #define ACL_TEXT_VERBOSE 0x01 #define ACL_TEXT_NUMERIC_IDS 0x02 +#define ACL_TEXT_APPEND_ID 0x04 #ifdef _KERNEL