rpms/acl/devel acl-2.2.39-nfsv4.patch,NONE,1.1 acl.spec,1.35,1.36

Steve Dickson (steved) fedora-extras-commits at redhat.com
Tue Aug 28 19:24:18 UTC 2007


Author: steved

Update of /cvs/pkgs/rpms/acl/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv16694

Modified Files:
	acl.spec 
Added Files:
	acl-2.2.39-nfsv4.patch 
Log Message:
Added NFS v4 ACL support


acl-2.2.39-nfsv4.patch:

--- NEW FILE acl-2.2.39-nfsv4.patch ---
--- /dev/null	2007-08-22 11:21:03.626521839 -0400
+++ acl-2.2.39/libacl/acl_nfs4_get_who.c	2007-08-22 12:02:13.000000000 -0400
@@ -0,0 +1,103 @@
+/*
+ *  NFSv4 ACL Code
+ *  Read the who value from the ace and return its type and optionally
+ *  its value.
+ *
+ *  Ace is a reference to the ace to extract the who value from.
+ *  Type is a reference where the value of the whotype will be stored.
+ *  Who is a double reference that should either be passed as NULL
+ *  (and thus no who string will be returned) or as a pointer to a
+ *  char* where the who string will be allocated. This string must be
+ *  freed by the caller.
+ *
+ *  Copyright (c) 2002, 2003 The Regents of the University of Michigan.
+ *  All rights reserved.
+ *
+ *  Nathaniel Gallaher <ngallahe at umich.edu>
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *  3. Neither the name of the University nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ *  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "libacl_nfs4.h"
+
+int acl_nfs4_get_who(struct nfs4_ace* ace, int* type, char** who)
+{
+	int itype;
+	char* iwho = NULL;
+	int wholen;
+
+	if(ace == NULL || ace->who == NULL)
+		goto inval_failed;
+
+	itype = acl_nfs4_get_whotype(ace->who);
+
+	if(type != NULL) {
+		*type = itype;
+	}
+
+
+	if(who == NULL)
+		return 0;
+
+	switch(itype)
+	{
+		case NFS4_ACL_WHO_NAMED:
+			iwho = ace->who;
+			break;
+		case NFS4_ACL_WHO_OWNER:
+			iwho = NFS4_ACL_WHO_OWNER_STRING;
+			break;
+		case NFS4_ACL_WHO_GROUP:
+			iwho = NFS4_ACL_WHO_GROUP_STRING;
+			break;
+		case NFS4_ACL_WHO_EVERYONE:
+			iwho = NFS4_ACL_WHO_EVERYONE_STRING;
+			break;
+		default:
+			goto inval_failed;
+	}
+
+	wholen = strlen(iwho);
+	if(wholen < 0)
+		goto inval_failed;
+
+	(*who) = (char *) malloc(sizeof(char) * (wholen + 1));
+	if((*who) == NULL) {
+		errno = ENOMEM;
+		goto failed;
+	}
+
+	strcpy((*who), iwho);
+
+	return 0;
+
+inval_failed:
+	errno = EINVAL;
+
+failed:
+	return -1;
+}
+
--- /dev/null	2007-08-22 11:21:03.626521839 -0400
+++ acl-2.2.39/libacl/acl_nfs4_add_ace.c	2007-08-22 12:02:13.000000000 -0400
@@ -0,0 +1,83 @@
+/*
+ *  NFSv4 ACL Code
+ *  Add an ace to the acl
+ *
+ *  Copyright (c) 2002, 2003 The Regents of the University of Michigan.
+ *  All rights reserved.
+ *
+ *  Marius Aamodt Eriksen <marius at umich.edu>
+ *  J. Bruce Fields <bfields at umich.edu>
+ *  Nathaniel Gallaher <ngallahe at umich.edu>
+ *  Jeff Sedlak <jsedlak at umich.edu>
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *  3. Neither the name of the University nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ *  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "libacl_nfs4.h"
+
+int
+acl_nfs4_add_ace(struct nfs4_acl *acl, u32 type, u32 flag, u32 access_mask,
+		int whotype, char* who)
+{
+	struct nfs4_ace *ace;
+	int result;
+
+	if(acl == NULL)
+	{
+		errno = EINVAL;
+		return -1;
+	}
+
+	if ((ace = malloc(sizeof(*ace))) == NULL)
+	{
+		errno = ENOMEM;
+		return -1;
+	}
+
+	ace->type = type;
+	ace->flag = flag;
+
+	if( type == NFS4_ACE_ACCESS_DENIED_ACE_TYPE )
+		access_mask = access_mask & ~(NFS4_ACE_MASK_IGNORE);
+
+
+	/* Castrate delete_child if we aren't a directory */
+	if (!acl->is_directory)
+		access_mask &= ~NFS4_ACE_DELETE_CHILD;
+
+
+	ace->access_mask = access_mask & NFS4_ACE_MASK_ALL;
+
+	result = acl_nfs4_set_who(ace, whotype, who);
+	if(result < 0)
+		return -1;
+
+	TAILQ_INSERT_TAIL(&acl->ace_head, ace, l_ace);
+	acl->naces++;
+
+	return 0;
+}
+
--- /dev/null	2007-08-22 11:21:03.626521839 -0400
+++ acl-2.2.39/libacl/acl_nfs4_get_whotype.c	2007-08-22 12:02:13.000000000 -0400
@@ -0,0 +1,60 @@
+/*
+ *  NFSv4 ACL Code
+ *  Get the whotype of the who string passed
+ *
[...2879 lines suppressed...]
+
+/* Recommended Attributes */
+#define FATTR4_WORD0_ACL                (1UL << 12)
+#define FATTR4_WORD0_ACLSUPPORT         (1UL << 13)
+#define FATTR4_WORD0_ARCHIVE            (1UL << 14)
+#define FATTR4_WORD0_CANSETTIME         (1UL << 15)
+#define FATTR4_WORD0_CASE_INSENSITIVE   (1UL << 16)
+#define FATTR4_WORD0_CASE_PRESERVING    (1UL << 17)
+#define FATTR4_WORD0_CHOWN_RESTRICTED   (1UL << 18)
+#define FATTR4_WORD0_FILEHANDLE         (1UL << 19)
+#define FATTR4_WORD0_FILEID             (1UL << 20)
+#define FATTR4_WORD0_FILES_AVAIL        (1UL << 21)
+#define FATTR4_WORD0_FILES_FREE         (1UL << 22)
+#define FATTR4_WORD0_FILES_TOTAL        (1UL << 23)
+#define FATTR4_WORD0_FS_LOCATIONS       (1UL << 24)
+#define FATTR4_WORD0_HIDDEN             (1UL << 25)
+#define FATTR4_WORD0_HOMOGENEOUS        (1UL << 26)
+#define FATTR4_WORD0_MAXFILESIZE        (1UL << 27)
+#define FATTR4_WORD0_MAXLINK            (1UL << 28)
+#define FATTR4_WORD0_MAXNAME            (1UL << 29)
+#define FATTR4_WORD0_MAXREAD            (1UL << 30)
+#define FATTR4_WORD0_MAXWRITE           (1UL << 31)
+#define FATTR4_WORD1_MIMETYPE           (1UL << 0)
+#define FATTR4_WORD1_MODE               (1UL << 1)
+#define FATTR4_WORD1_NO_TRUNC           (1UL << 2)
+#define FATTR4_WORD1_NUMLINKS           (1UL << 3)
+#define FATTR4_WORD1_OWNER              (1UL << 4)
+#define FATTR4_WORD1_OWNER_GROUP        (1UL << 5)
+#define FATTR4_WORD1_QUOTA_HARD         (1UL << 6)
+#define FATTR4_WORD1_QUOTA_SOFT         (1UL << 7)
+#define FATTR4_WORD1_QUOTA_USED         (1UL << 8)
+#define FATTR4_WORD1_RAWDEV             (1UL << 9)
+#define FATTR4_WORD1_SPACE_AVAIL        (1UL << 10)
+#define FATTR4_WORD1_SPACE_FREE         (1UL << 11)
+#define FATTR4_WORD1_SPACE_TOTAL        (1UL << 12)
+#define FATTR4_WORD1_SPACE_USED         (1UL << 13)
+#define FATTR4_WORD1_SYSTEM             (1UL << 14)
+#define FATTR4_WORD1_TIME_ACCESS        (1UL << 15)
+#define FATTR4_WORD1_TIME_ACCESS_SET    (1UL << 16)
+#define FATTR4_WORD1_TIME_BACKUP        (1UL << 17)
+#define FATTR4_WORD1_TIME_CREATE        (1UL << 18)
+#define FATTR4_WORD1_TIME_DELTA         (1UL << 19)
+#define FATTR4_WORD1_TIME_METADATA      (1UL << 20)
+#define FATTR4_WORD1_TIME_MODIFY        (1UL << 21)
+#define FATTR4_WORD1_TIME_MODIFY_SET    (1UL << 22)
+#define FATTR4_WORD1_MOUNTED_ON_FILEID  (1UL << 23)
+
+#define NFSPROC4_NULL 0
+#define NFSPROC4_COMPOUND 1
+#define NFS4_MINOR_VERSION 0
+#define NFS4_DEBUG 1
+
+#ifdef __KERNEL__
+
+/* Index of predefined Linux client operations */
+
+enum {
+	NFSPROC4_CLNT_NULL = 0,		/* Unused */
+	NFSPROC4_CLNT_READ,
+	NFSPROC4_CLNT_WRITE,
+	NFSPROC4_CLNT_COMMIT,
+	NFSPROC4_CLNT_OPEN,
+	NFSPROC4_CLNT_OPEN_CONFIRM,
+	NFSPROC4_CLNT_OPEN_RECLAIM,
+	NFSPROC4_CLNT_OPEN_DOWNGRADE,
+	NFSPROC4_CLNT_CLOSE,
+	NFSPROC4_CLNT_SETATTR,
+	NFSPROC4_CLNT_FSINFO,
+	NFSPROC4_CLNT_RENEW,
+	NFSPROC4_CLNT_SETCLIENTID,
+	NFSPROC4_CLNT_SETCLIENTID_CONFIRM,
+	NFSPROC4_CLNT_LOCK,
+	NFSPROC4_CLNT_LOCKT,
+	NFSPROC4_CLNT_LOCKU,
+	NFSPROC4_CLNT_ACCESS,
+	NFSPROC4_CLNT_GETATTR,
+	NFSPROC4_CLNT_LOOKUP,
+	NFSPROC4_CLNT_LOOKUP_ROOT,
+	NFSPROC4_CLNT_REMOVE,
+	NFSPROC4_CLNT_RENAME,
+	NFSPROC4_CLNT_LINK,
+	NFSPROC4_CLNT_CREATE,
+	NFSPROC4_CLNT_PATHCONF,
+	NFSPROC4_CLNT_STATFS,
+	NFSPROC4_CLNT_READLINK,
+	NFSPROC4_CLNT_READDIR,
+	NFSPROC4_CLNT_SERVER_CAPS,
+	NFSPROC4_CLNT_DELEGRETURN,
+	NFSPROC4_CLNT_GETACL,
+	NFSPROC4_CLNT_SETACL,
+};
+
+#endif
+#endif
+
+/*
+ * Local variables:
+ *  c-basic-offset: 8
+ * End:
+ */
--- /dev/null	2007-08-22 11:21:03.626521839 -0400
+++ acl-2.2.39/include/libacl_nfs4.h	2007-08-22 12:02:13.000000000 -0400
@@ -0,0 +1,97 @@
+#include <sys/types.h>
+#include <pwd.h>
+#include <grp.h>
+#include <sys/acl.h>
+#include <stdlib.h>
+#include <sys/queue.h>
+#include <nfs4.h>
+#include <sys/errno.h>
+#include <string.h>
+
+/* mode bit translations: */
+#define NFS4_READ_MODE NFS4_ACE_READ_DATA
+#define NFS4_WRITE_MODE (NFS4_ACE_WRITE_DATA | NFS4_ACE_APPEND_DATA)
+#define NFS4_EXECUTE_MODE NFS4_ACE_EXECUTE
+#define NFS4_ANYONE_MODE (NFS4_ACE_READ_ATTRIBUTES | NFS4_ACE_READ_ACL | \
+		NFS4_ACE_SYNCHRONIZE)
+#define NFS4_OWNER_MODE (NFS4_ACE_WRITE_ATTRIBUTES | NFS4_ACE_WRITE_ACL)
+
+#define NFS4_ACE_MASK_IGNORE (NFS4_ACE_DELETE | NFS4_ACE_WRITE_OWNER \
+		| NFS4_ACE_READ_NAMED_ATTRS | NFS4_ACE_WRITE_NAMED_ATTRS)
+/* XXX not sure about the following.  Note that e.g. DELETE_CHILD is wrong in
+ * general (should only be ignored on files). */
+#define MASK_EQUAL(mask1, mask2) \
+	(((mask1) & NFS4_ACE_MASK_ALL & ~NFS4_ACE_MASK_IGNORE & \
+	  					~NFS4_ACE_DELETE_CHILD) \
+	 == ((mask2) & NFS4_ACE_MASK_ALL & ~NFS4_ACE_MASK_IGNORE & \
+		 				~NFS4_ACE_DELETE_CHILD))
+
+/* Maximum length of the ace->who attribute */
+#define NFS4_ACL_WHO_LENGTH_MAX		2048
+#define NFS4_ACL_WHO_BUFFER_LEN_GUESS	255
+
+/* NFS4 acl xattr name */
+#define ACL_NFS4_XATTR "system.nfs4_acl"
+
+/* Macro for finding empty tailqs */
+#define TAILQ_IS_EMPTY(head) (head.tqh_first == NULL)
+
+/* Flags to pass certain properties around */
+#define NFS4_ACL_NOFLAGS			0x00
+#define NFS4_ACL_ISFILE				0x00
+#define NFS4_ACL_ISDIR				0x01
+#define NFS4_ACL_OWNER				0x02
+#define NFS4_ACL_REQUEST_DEFAULT	0x04
+#define NFS4_ACL_RAW				0x01
+
+#define NFS4_XDR_MOD				4
+
+typedef u_int32_t u32;
+
+enum {	ACL_NFS4_NOT_USED = 0,
+		ACL_NFS4_USED
+};
+
+struct ace_container {
+	struct nfs4_ace *ace;
+	TAILQ_ENTRY(ace_container) l_ace;
+};
+
+TAILQ_HEAD(ace_container_list_head, ace_container);
+
+/**** Public functions ****/
+
+/** Manipulation functions **/
+extern int				acl_nfs4_add_ace(struct nfs4_acl *, u32, u32, u32, int, char*);
+extern int				acl_nfs4_add_pair(struct nfs4_acl *, int, u32, int, char*);
+extern void				acl_nfs4_free(struct nfs4_acl *);
+extern struct nfs4_acl *acl_nfs4_new(u32);
+extern int				acl_nfs4_set_who(struct nfs4_ace*, int, char*);
+extern struct nfs4_acl *acl_nfs4_copy_acl(struct nfs4_acl *);
+extern struct nfs4_acl *acl_nfs4_xattr_load(char *, int, u32);
+extern int				acl_nfs4_xattr_pack(struct nfs4_acl *, char**);
+extern int				acl_nfs4_xattr_size(struct nfs4_acl *);
+extern void				acl_nfs4_remove_ace(struct nfs4_acl * acl, struct nfs4_ace * ace);
+
+/** Conversion functions **/
+
+/* nfs4 -> posix */
+extern acl_t		acl_n4tp_acl_trans(struct nfs4_acl *, acl_type_t);
+
+/* posix -> nfs4 */
+extern int				acl_ptn4_get_mask(u32* mask, acl_permset_t perms,
+								int iflags);
+extern int acl_ptn4_acl_trans(acl_t, struct nfs4_acl *, acl_type_t, u32, char*);
+
+
+/** Access Functions **/
+extern inline int	acl_nfs4_get_whotype(char*);
+extern int			acl_nfs4_get_who(struct nfs4_ace*, int*, char**);
+
+/**** Private(?) functions ****/
+acl_t		__posix_acl_from_nfs4_xattr(char*, int, acl_type_t, u32);
+
+/* These will change */
+char * nfs4_get_who_from_uid(uid_t);
+char * nfs4_get_who_from_gid(gid_t);
+/* End change */


Index: acl.spec
===================================================================
RCS file: /cvs/pkgs/rpms/acl/devel/acl.spec,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- acl.spec	26 Jul 2007 13:55:14 -0000	1.35
+++ acl.spec	28 Aug 2007 19:23:46 -0000	1.36
@@ -1,7 +1,7 @@
 Summary: Access control list utilities
 Name: acl
 Version: 2.2.39
-Release: 4.1%{?dist}
+Release: 5%{?dist}
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: libattr-devel >= 2.4.1
 Source: ftp://oss.sgi.com/projects/xfs/cmd_tars/acl_%{version}-1.tar.gz
@@ -11,6 +11,7 @@
 Patch3: acl-2.2.39-walk.patch
 Patch4: acl-2.2.39-params.patch
 Patch5: acl-2.2.39-man.patch
+Patch6: acl-2.2.39-nfsv4.patch
 BuildRequires: autoconf, libtool >= 1.5, gettext
 License: GPL
 Group: System Environment/Base
@@ -51,6 +52,7 @@
 %patch3 -p1 -b .walk
 %patch4 -p1 -b .params
 %patch5 -p1 -b .man
+%patch6 -p1 -b .nfsv4
 autoconf
 
 %build
@@ -106,6 +108,9 @@
 /%{_lib}/libacl.so.*
 
 %changelog
+* Mon Aug 27 2007 Steve Dickson <steved at redhat.com>  2.2.39-5
+- Added NFS v4 ACL support
+
 * Thu Jul 26 2007 Jiri Moskovcak <jmoskovc at redhat.com> 2.2.39-4.1
 - Updated man page for getfacl
 




More information about the fedora-extras-commits mailing list