From owner-p4-projects@FreeBSD.ORG Wed Jul 2 11:09:46 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 541BE1065673; Wed, 2 Jul 2008 11:09:46 +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 16713106564A for ; Wed, 2 Jul 2008 11:09:46 +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 04CAA8FC20 for ; Wed, 2 Jul 2008 11:09:46 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m62B9jfv014395 for ; Wed, 2 Jul 2008 11:09:45 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m62B9jHc014393 for perforce@freebsd.org; Wed, 2 Jul 2008 11:09:45 GMT (envelope-from trasz@freebsd.org) Date: Wed, 2 Jul 2008 11:09:45 GMT Message-Id: <200807021109.m62B9jHc014393@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 144480 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: Wed, 02 Jul 2008 11:09:46 -0000 http://perforce.freebsd.org/chv.cgi?CH=144480 Change 144480 by trasz@trasz_traszkan on 2008/07/02 11:09:31 Add support for the new ACLs to ls(1). Affected files ... .. //depot/projects/soc2008/trasz_nfs4acl/bin/ls/print.c#2 edit Differences ... ==== //depot/projects/soc2008/trasz_nfs4acl/bin/ls/print.c#2 (text+ko) ==== @@ -616,9 +616,8 @@ aclmode(char *buf, const FTSENT *p, int *haveacls) { char name[MAXPATHLEN + 1]; - int entries, ret; + int type = ACL_TYPE_ACCESS, ret; acl_t facl; - acl_entry_t ae; /* * Add a + after the standard rwxrwxrwx mode if the file has an @@ -638,29 +637,34 @@ *haveacls = 1; return; } - if ((ret = pathconf(name, _PC_ACL_EXTENDED)) <= 0) { - if (ret < 0 && errno != EINVAL) - warn("%s", name); - else - *haveacls = 0; + + *haveacls = 0; + + ret = pathconf(name, _PC_ACL_EXTENDED); + if (ret > 0) { + type = ACL_TYPE_ACCESS; + *haveacls = 1; + } else if (ret < 0 && errno != EINVAL) { + warn("%s", name); + return; + } + + ret = pathconf(name, _PC_EXTENDED_SECURITY_NP); + if (ret > 0) { + type = ACL_TYPE_NFS4; + *haveacls = 1; + } else if (ret < 0 && errno != EINVAL) { + warn("%s", name); return; } - *haveacls = 1; - if ((facl = acl_get_file(name, ACL_TYPE_ACCESS)) != NULL) { - if (acl_get_entry(facl, ACL_FIRST_ENTRY, &ae) == 1) { - entries = 1; - while (acl_get_entry(facl, ACL_NEXT_ENTRY, &ae) == 1) - if (++entries > 3) - break; - /* - * POSIX.1e requires that ACLs of type ACL_TYPE_ACCESS - * must have at least three entries (owner, group, - * and other). So anything with more than 3 ACLs looks - * interesting to us. - */ - if (entries > 3) - buf[10] = '+'; - } + + if (*haveacls == 0) + return; + + if ((facl = acl_get_file(name, type)) != NULL) { + if (!acl_is_trivial_np(facl)) + buf[10] = '+'; + acl_free(facl); } else warn("%s", name);