From owner-svn-src-all@FreeBSD.ORG Sat Jan 30 15:50:01 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 986BC1065672; Sat, 30 Jan 2010 15:50:01 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 85AFF8FC12; Sat, 30 Jan 2010 15:50:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0UFo1F0036803; Sat, 30 Jan 2010 15:50:01 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0UFo1Uh036797; Sat, 30 Jan 2010 15:50:01 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201001301550.o0UFo1Uh036797@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sat, 30 Jan 2010 15:50:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203198 - stable/8/bin/setfacl X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jan 2010 15:50:01 -0000 Author: trasz Date: Sat Jan 30 15:50:01 2010 New Revision: 203198 URL: http://svn.freebsd.org/changeset/base/203198 Log: MFC r201016: Improve ACL branding mismatch detection and reporting in some rare cases, such as "setfacl -m ''". Modified: stable/8/bin/setfacl/merge.c stable/8/bin/setfacl/remove.c stable/8/bin/setfacl/setfacl.h stable/8/bin/setfacl/util.c Directory Properties: stable/8/bin/setfacl/ (props changed) Modified: stable/8/bin/setfacl/merge.c ============================================================================== --- stable/8/bin/setfacl/merge.c Sat Jan 30 15:42:06 2010 (r203197) +++ stable/8/bin/setfacl/merge.c Sat Jan 30 15:50:01 2010 (r203198) @@ -100,11 +100,10 @@ merge_acl(acl_t acl, acl_t *prev_acl, co acl_get_brand_np(acl, &acl_brand); acl_get_brand_np(*prev_acl, &prev_acl_brand); - if (acl_brand != prev_acl_brand) { + if (branding_mismatch(acl_brand, prev_acl_brand)) { warnx("%s: branding mismatch; existing ACL is %s, " "entry to be merged is %s", filename, - prev_acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e", - acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e"); + brand_name(prev_acl_brand), brand_name(acl_brand)); return (-1); } @@ -252,9 +251,10 @@ add_acl(acl_t acl, uint entry_number, ac return (-1); } - if (acl_brand != ACL_BRAND_NFS4) { + if (branding_mismatch(acl_brand, ACL_BRAND_NFS4)) { warnx("%s: branding mismatch; existing ACL is NFSv4, " - "entry to be added is POSIX.1e", filename); + "entry to be added is %s", filename, + brand_name(acl_brand)); return (-1); } Modified: stable/8/bin/setfacl/remove.c ============================================================================== --- stable/8/bin/setfacl/remove.c Sat Jan 30 15:42:06 2010 (r203197) +++ stable/8/bin/setfacl/remove.c Sat Jan 30 15:50:01 2010 (r203198) @@ -53,11 +53,10 @@ remove_acl(acl_t acl, acl_t *prev_acl, c acl_get_brand_np(acl, &acl_brand); acl_get_brand_np(*prev_acl, &prev_acl_brand); - if (acl_brand != prev_acl_brand) { + if (branding_mismatch(acl_brand, prev_acl_brand)) { warnx("%s: branding mismatch; existing ACL is %s, " "entry to be removed is %s", filename, - prev_acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e", - acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e"); + brand_name(prev_acl_brand), brand_name(acl_brand)); return (-1); } Modified: stable/8/bin/setfacl/setfacl.h ============================================================================== --- stable/8/bin/setfacl/setfacl.h Sat Jan 30 15:42:06 2010 (r203197) +++ stable/8/bin/setfacl/setfacl.h Sat Jan 30 15:50:01 2010 (r203198) @@ -71,6 +71,8 @@ void remove_ext(acl_t *prev_acl, const int set_acl_mask(acl_t *prev_acl, const char *filename); /* util.c */ void *zmalloc(size_t size); +const char *brand_name(int brand); +int branding_mismatch(int brand1, int brand2); uint have_mask; uint need_mask; Modified: stable/8/bin/setfacl/util.c ============================================================================== --- stable/8/bin/setfacl/util.c Sat Jan 30 15:42:06 2010 (r203197) +++ stable/8/bin/setfacl/util.c Sat Jan 30 15:50:01 2010 (r203198) @@ -43,3 +43,26 @@ zmalloc(size_t size) err(1, "calloc() failed"); return (ptr); } + +const char * +brand_name(int brand) +{ + switch (brand) { + case ACL_BRAND_NFS4: + return "NFSv4"; + case ACL_BRAND_POSIX: + return "POSIX.1e"; + default: + return "unknown"; + } +} + +int +branding_mismatch(int brand1, int brand2) +{ + if (brand1 == ACL_BRAND_UNKNOWN || brand2 == ACL_BRAND_UNKNOWN) + return (0); + if (brand1 != brand2) + return (1); + return (1); +}