summaryrefslogtreecommitdiff
blob: 3d97eea652015c4494865d9f0726cb5206d8f5bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From cd582e0230f502a8e9710b03ec6375699d2e484e Mon Sep 17 00:00:00 2001
From: "J. Bruce Fields" <bfields@snoopy.citi.umich.edu>
Date: Tue, 12 Dec 2006 17:37:22 -0500
Subject: [PATCH 11/17] POSIX->NFSv4: relax inheritance bit mapping

Accept wider range of inheritance bits by e.g. treating file inherit and
directory inherit as if both were always on if one is.
---
 libacl/acl_ptn4_acl_trans.c |   30 +++++++++---------------------
 1 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/libacl/acl_ptn4_acl_trans.c b/libacl/acl_ptn4_acl_trans.c
index 3c23f01..4dbd4c5 100644
--- a/libacl/acl_ptn4_acl_trans.c
+++ b/libacl/acl_ptn4_acl_trans.c
@@ -38,9 +38,10 @@
 #include <nfsidmap.h>
 #include "libacl_nfs4.h"
 
-/* flags used to simulate posix default ACLs */
-#define NFS4_INHERITANCE_FLAGS (NFS4_ACE_FILE_INHERIT_ACE \
-		| NFS4_ACE_DIRECTORY_INHERIT_ACE | NFS4_ACE_INHERIT_ONLY_ACE)
+
+#define FILE_OR_DIR_INHERIT (NFS4_ACE_FILE_INHERIT_ACE \
+		| NFS4_ACE_DIRECTORY_INHERIT_ACE)
+#define NFS4_INHERITANCE_FLAGS (FILE_OR_DIR_INHERIT | NFS4_ACE_INHERIT_ONLY_ACE)
 
 /* Plan:
  * 1: if setting default, remove all purely inherited aces, and replace
@@ -48,26 +49,22 @@
  * 2: if setting effective, remove all purely effective aces, and replace
  *    all dual-use aces by purely inherited ones
  */
-
-int purge_aces(struct nfs4_acl *nacl, acl_type_t type)
+static void purge_aces(struct nfs4_acl *nacl, acl_type_t type)
 {
 	struct nfs4_ace *p, *next;
 
 	for (p = nacl->ace_head.tqh_first; p != NULL; p = next) {
 		next = p->l_ace.tqe_next;
 
-		switch (p->flag & NFS4_INHERITANCE_FLAGS) {
-		case 0:
+		if (!(p->flag & FILE_OR_DIR_INHERIT)) {
 			/* purely effective */
 			if (type == ACL_TYPE_ACCESS)
 				acl_nfs4_remove_ace(nacl, p);
-			continue;
-		case NFS4_INHERITANCE_FLAGS:
+		} else if (p->flag & NFS4_ACE_INHERIT_ONLY_ACE) {
 			/* purely inherited */
 			if (type == ACL_TYPE_DEFAULT)
 				acl_nfs4_remove_ace(nacl, p);
-			break;
-		case NFS4_INHERITANCE_FLAGS & ~NFS4_ACE_INHERIT_ONLY_ACE:
+		} else {
 			/* both effective and inherited */
 			if (type == ACL_TYPE_DEFAULT) {
 				/* Change to purely effective */
@@ -76,14 +73,9 @@ int purge_aces(struct nfs4_acl *nacl, acl_type_t type)
 				/* Change to purely inherited */
 				p->flag |= NFS4_INHERITANCE_FLAGS;
 			}
-			break;
-		default:
-			errno = EINVAL;
-			return -1;
 		}
 
 	}
-	return 0;
 }
  
 int
@@ -114,9 +106,7 @@ acl_ptn4_acl_trans(acl_t pacl, struct nfs4_acl *acl, acl_type_t type, u32 is_dir
 		iflags |= NFS4_ACL_REQUEST_DEFAULT;
 	}
 
-	result = purge_aces(acl, type);
-	if (result)
-		return -1;
+	purge_aces(acl, type);
 
 	if (is_dir & NFS4_ACL_ISDIR)
 		iflags |= NFS4_ACL_ISDIR;
@@ -517,5 +507,3 @@ out:
 		acl_nfs4_free(acl);
 	return -1;
 }
-
-
-- 
1.7.8.1