From nobody@FreeBSD.org  Tue Jan 18 14:54:05 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4E788106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Jan 2011 14:54:05 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 233858FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Jan 2011 14:54:05 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p0IEs4f3018921
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Jan 2011 14:54:04 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p0IEs4h2018920;
	Tue, 18 Jan 2011 14:54:04 GMT
	(envelope-from nobody)
Message-Id: <201101181454.p0IEs4h2018920@red.freebsd.org>
Date: Tue, 18 Jan 2011 14:54:04 GMT
From: Shawn Webb <lattera@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] [libc] Missing ZFS NFSv4 ACL read_set, modify_set, write_set, full_set
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         154113
>Category:       kern
>Synopsis:       [patch] [libc] Missing ZFS NFSv4 ACL read_set, modify_set, write_set, full_set
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    trasz
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 18 15:00:21 UTC 2011
>Closed-Date:    Sat Apr 09 07:53:54 UTC 2011
>Last-Modified:  Sat Apr 09 07:53:54 UTC 2011
>Originator:     Shawn Webb
>Release:        8.2-RC1
>Organization:
HotlinkHR
>Environment:
FreeBSD  8.2-RC1 FreeBSD 8.2-RC1 #0: Wed Dec 22 17:34:20 UTC 2010     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
The `setfacl` command is missing read_set, modify_set, write_set, and full_set ZFS NFSv4 ACL sets. The proposed patch implements them.
>How-To-Repeat:

>Fix:
Patch included and attached.

Patch attached with submission follows:

--- releng_8_2/src/lib/libc/posix1e/acl_support_nfs4.c	2010-12-21 10:09:25.000000000 -0700
+++ src/lib/libc/posix1e/acl_support_nfs4.c	2011-01-11 10:51:11.000000000 -0700
@@ -144,13 +144,38 @@
 
 	while (str != NULL) {
 		flag = strsep(&str, "/:");
-
 		found = 0;
-		for (i = 0; flags[i].name != NULL; i++) {
-			if (strcmp(flags[i].name, flag) == 0) {
+
+		if (flags == a_access_masks && strcmp("full_set", flag) == 0) {
+			for (i = 0; flags[i].name != NULL; i++)
 				*var |= flags[i].flag;
-				found = 1;
-				ever_found = 1;
+			found = 1;
+			ever_found = 1;
+		}
+		else if (flags == a_access_masks && strcmp("read_set", flag) == 0) {
+			*var |= (ACL_READ_DATA | ACL_READ_ATTRIBUTES | ACL_READ_NAMED_ATTRS | ACL_READ_ACL);
+			found = 1;
+			ever_found = 1;
+		}
+		else if (flags == a_access_masks && strcmp("write_set", flag) == 0) {
+			*var |= (ACL_WRITE_DATA | ACL_APPEND_DATA | ACL_WRITE_ATTRIBUTES | ACL_WRITE_NAMED_ATTRS);
+			found = 1;
+			ever_found = 1;
+		}
+		else if (flags == a_access_masks && strcmp("modify_set", flag) == 0) {
+			for (i = 0; flags[i].name != NULL; i++)
+				if (flags[i].flag != ACL_WRITE_ACL || flags[i].flag != ACL_WRITE_OWNER)
+					*var |= flags[i].flag;
+			found = 1;
+			ever_found = 1;
+		}
+		else {
+			for (i = 0; flags[i].name != NULL; i++) {
+				if (strcmp(flags[i].name, flag) == 0) {
+					*var |= flags[i].flag;
+					found = 1;
+					ever_found = 1;
+				}
 			}
 		}
 


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->trasz 
Responsible-Changed-By: trasz 
Responsible-Changed-When: Wed Mar 2 07:25:01 UTC 2011 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154113 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/154113: commit references a PR
Date: Sat,  9 Apr 2011 07:42:37 +0000 (UTC)

 Author: trasz
 Date: Sat Apr  9 07:42:25 2011
 New Revision: 220465
 URL: http://svn.freebsd.org/changeset/base/220465
 
 Log:
   Make it possible to use permission sets (full_set, modify_set, read_set
   and write_set) with setfacl(1).
   
   PR:		kern/154113
   Submitted by:	Shawn Webb <lattera at gmail dot com> (earlier version)
   MFC after:	1 month
 
 Modified:
   head/bin/setfacl/setfacl.1
   head/lib/libc/posix1e/acl_support_nfs4.c
   head/sys/sys/acl.h
 
 Modified: head/bin/setfacl/setfacl.1
 ==============================================================================
 --- head/bin/setfacl/setfacl.1	Sat Apr  9 06:01:37 2011	(r220464)
 +++ head/bin/setfacl/setfacl.1	Sat Apr  9 07:42:25 2011	(r220465)
 @@ -1,5 +1,6 @@
  .\"-
  .\" Copyright (c) 2001 Chris D. Faulhaber
 +.\" Copyright (c) 2011 Edward Tomasz Napierała
  .\" All rights reserved.
  .\"
  .\" Redistribution and use in source and binary forms, with or without
 @@ -25,7 +26,7 @@
  .\"
  .\" $FreeBSD$
  .\"
 -.Dd July 27, 2010
 +.Dd April 9, 2011
  .Dt SETFACL 1
  .Os
  .Sh NAME
 @@ -307,7 +308,7 @@ Permissions in long form are separated b
  .Ql /
  character; in short form, they are concatenated together.
  Valid permissions are:
 -.Bl -tag -width ".Dv short"
 +.Bl -tag -width ".Dv modify_set"
  .It Short
  Long
  .It r
 @@ -339,6 +340,20 @@ write_owner
  .It S
  synchronize
  .El
 +.Pp
 +In addition, the following permission sets may be used:
 +.Bl -tag -width ".Dv modify_set"
 +.It Set
 +Permissions
 +.It full_set
 +all permissions, as shown above
 +.It modify_set
 +all permissions except write_acl and write_owner
 +.It read_set
 +read_data, read_attributes, read_xattr and read_acl
 +.It write_set
 +write_data, append_data, write_attributes and write_xattr
 +.El
  .It Ar "ACL inheritance flags"
  Inheritance flags may be specified in either short or long form.
  Short and long forms may not be mixed.
 
 Modified: head/lib/libc/posix1e/acl_support_nfs4.c
 ==============================================================================
 --- head/lib/libc/posix1e/acl_support_nfs4.c	Sat Apr  9 06:01:37 2011	(r220464)
 +++ head/lib/libc/posix1e/acl_support_nfs4.c	Sat Apr  9 07:42:25 2011	(r220465)
 @@ -70,6 +70,10 @@ struct flagnames_struct a_access_masks[]
       { ACL_WRITE_ACL, "write_acl", 'C'},
       { ACL_WRITE_OWNER, "write_owner", 'o'},
       { ACL_SYNCHRONIZE, "synchronize", 's'},
 +     { ACL_FULL_SET, "full_set", '\0'},
 +     { ACL_MODIFY_SET, "modify_set", '\0'},
 +     { ACL_READ_SET, "read_set", '\0'},
 +     { ACL_WRITE_SET, "write_set", '\0'},
       { 0, 0, 0}};
  
  static const char *
 @@ -117,7 +121,7 @@ format_flags_compact(char *str, size_t s
  {
  	size_t i;
  
 -	for (i = 0; flags[i].name != NULL; i++) {
 +	for (i = 0; flags[i].letter != '\0'; i++) {
  		assert(i < size);
  		if ((flags[i].flag & var) == 0)
  			str[i] = '-';
 
 Modified: head/sys/sys/acl.h
 ==============================================================================
 --- head/sys/sys/acl.h	Sat Apr  9 06:01:37 2011	(r220464)
 +++ head/sys/sys/acl.h	Sat Apr  9 07:42:25 2011	(r220465)
 @@ -217,12 +217,23 @@ typedef void *acl_t;
  #define	ACL_WRITE_OWNER		0x00004000
  #define	ACL_SYNCHRONIZE		0x00008000
  
 -#define	ACL_NFS4_PERM_BITS	(ACL_READ_DATA | ACL_WRITE_DATA | \
 +#define	ACL_FULL_SET		(ACL_READ_DATA | ACL_WRITE_DATA | \
      ACL_APPEND_DATA | ACL_READ_NAMED_ATTRS | ACL_WRITE_NAMED_ATTRS | \
      ACL_EXECUTE | ACL_DELETE_CHILD | ACL_READ_ATTRIBUTES | \
      ACL_WRITE_ATTRIBUTES | ACL_DELETE | ACL_READ_ACL | ACL_WRITE_ACL | \
      ACL_WRITE_OWNER | ACL_SYNCHRONIZE)
  
 +#define	ACL_MODIFY_SET		(ACL_FULL_SET & \
 +    ~(ACL_WRITE_ACL | ACL_WRITE_OWNER))
 +
 +#define	ACL_READ_SET		(ACL_READ_DATA | ACL_READ_NAMED_ATTRS | \
 +    ACL_READ_ATTRIBUTES | ACL_READ_ACL)
 +
 +#define	ACL_WRITE_SET		(ACL_WRITE_DATA | ACL_APPEND_DATA | \
 +    ACL_WRITE_NAMED_ATTRS | ACL_WRITE_ATTRIBUTES)
 +
 +#define	ACL_NFS4_PERM_BITS	ACL_FULL_SET
 +
  /*
   * Possible entry_id values for acl_get_entry(3).
   */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: trasz 
State-Changed-When: Sat Apr 9 07:53:53 UTC 2011 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154113 
>Unformatted:
