Line 0
Link Here
|
|
|
1 |
--- star/acl_unix.c.orig 2014-03-31 17:44:46 UTC |
2 |
+++ star/acl_unix.c |
3 |
@@ -1,8 +1,8 @@ |
4 |
-/* @(#)acl_unix.c 1.49 14/03/31 Copyright 2001-2014 J. Schilling */ |
5 |
+/* @(#)acl_unix.c 1.51 16/09/03 Copyright 2001-2014 J. Schilling */ |
6 |
#include <schily/mconfig.h> |
7 |
#ifndef lint |
8 |
static UConst char sccsid[] = |
9 |
- "@(#)acl_unix.c 1.49 14/03/31 Copyright 2001-2014 J. Schilling"; |
10 |
+ "@(#)acl_unix.c 1.51 16/09/03 Copyright 2001-2014 J. Schilling"; |
11 |
#endif |
12 |
/* |
13 |
* ACL get and set routines for unix like operating systems. |
14 |
@@ -11,7 +11,7 @@ static UConst char sccsid[] = |
15 |
* |
16 |
* There are currently two basic flavors of ACLs: |
17 |
* |
18 |
- * Flavor 1: UFS/POSIX draft |
19 |
+ * Flavor 1: UFS/POSIX.1e draft (withrawn in 1997) |
20 |
* |
21 |
* The Solaric UFS ACLs that have been developed between 1990 and 1994. |
22 |
* These ACLs have been made available as extensions to NFSv2 and NFSv3. |
23 |
@@ -27,7 +27,7 @@ static UConst char sccsid[] = |
24 |
* As True64 does not like ACL "mask" entries and this version of the |
25 |
* ACL code does not generate "mask" entries on True64, ACL support for |
26 |
* True64 is currently broken. You cannot read back archives created |
27 |
- * on true64. |
28 |
+ * on True64. |
29 |
* |
30 |
* Flavor 2: NFSv4 |
31 |
* |
32 |
@@ -196,6 +196,9 @@ EXPORT void |
33 |
opt_acl() |
34 |
{ |
35 |
printf(" acl-POSIX.1e-draft"); |
36 |
+#ifdef HAVE_NFSV4_ACL |
37 |
+ printf(" acl-NFSv4"); |
38 |
+#endif |
39 |
} |
40 |
|
41 |
/* |
42 |
@@ -217,6 +220,15 @@ get_acls(info) |
43 |
if (is_symlink(info)) |
44 |
return (TRUE); |
45 |
|
46 |
+#ifdef HAVE_FREEBSD_NFSV4_ACL |
47 |
+ if (acl_to_info(info->f_sname, ACL_TYPE_NFS4, &acl_ace_text)) { |
48 |
+ if (*acl_ace_text.ps_path != '\0') { |
49 |
+ info->f_xflags |= XF_ACL_ACE; |
50 |
+ info->f_acl_ace = acl_ace_text.ps_path; |
51 |
+ } |
52 |
+ return (TRUE); |
53 |
+ } |
54 |
+#endif |
55 |
if (!acl_to_info(info->f_sname, ACL_TYPE_ACCESS, &acl_access_text)) |
56 |
return (FALSE); |
57 |
if (*acl_access_text.ps_path != '\0') { |
58 |
@@ -263,6 +275,13 @@ acl_to_info(name, type, acltext) |
59 |
if (err == ENOSYS) |
60 |
return (TRUE); |
61 |
#endif |
62 |
+#ifdef HAVE_FREEBSD_NFSV4_ACL |
63 |
+ /* |
64 |
+ * If ACL type is not NFS4 we continue with POSIX.1e ACLs |
65 |
+ */ |
66 |
+ if (type == ACL_TYPE_NFS4 && err == EINVAL) |
67 |
+ return (FALSE); |
68 |
+#endif |
69 |
if (!errhidden(E_GETACL, name)) { |
70 |
if (!errwarnonly(E_GETACL, name)) |
71 |
xstats.s_getaclerrs++; |
72 |
@@ -273,7 +292,12 @@ acl_to_info(name, type, acltext) |
73 |
return (FALSE); |
74 |
} |
75 |
seterrno(0); |
76 |
- text = acl_to_text(acl, NULL); |
77 |
+#ifdef HAVE_FREEBSD_NFSV4_ACL |
78 |
+ if (type == ACL_TYPE_NFS4) |
79 |
+ text = acl_to_text_np(acl, NULL, ACL_TEXT_APPEND_ID); |
80 |
+ else |
81 |
+#endif |
82 |
+ text = acl_to_text(acl, NULL); |
83 |
acl_free(acl); |
84 |
if (text == NULL) { |
85 |
if (geterrno() == 0) |
86 |
@@ -313,6 +337,22 @@ acl_to_info(name, type, acltext) |
87 |
; |
88 |
} |
89 |
|
90 |
+#ifdef HAVE_FREEBSD_NFSV4_ACL |
91 |
+ /* remove space fields */ |
92 |
+ if (type == ACL_TYPE_NFS4) { |
93 |
+ c = text; |
94 |
+ while ((c = strchr(c, ' ')) != NULL) { |
95 |
+ char *d = c, *e; |
96 |
+ |
97 |
+ while (*d && *d == ' ') |
98 |
+ d++; |
99 |
+ e = c; |
100 |
+ while ((*e++ = *d++) != '\0') |
101 |
+ ; |
102 |
+ } |
103 |
+ } |
104 |
+#endif |
105 |
+ |
106 |
/* count fields */ |
107 |
for (c = text; *c != '\0'; c++) { |
108 |
if (*c == '\n') { |
109 |
@@ -320,6 +360,14 @@ acl_to_info(name, type, acltext) |
110 |
entries++; |
111 |
} |
112 |
} |
113 |
+#ifdef HAVE_FREEBSD_NFSV4_ACL |
114 |
+ if (type == ACL_TYPE_NFS4) { |
115 |
+ if (strcpy_pspace(PS_EXIT, acltext, text) < 0) { |
116 |
+ acl_free((acl_t)text); |
117 |
+ return (FALSE); |
118 |
+ } |
119 |
+ } else |
120 |
+#endif |
121 |
if ((entries > 3) || /* > 4 on Solaris? */ |
122 |
(type == ACL_TYPE_DEFAULT && entries >= 3)) { |
123 |
if ((entries * 56) > acltext->ps_size) |
124 |
@@ -446,6 +494,55 @@ set_acls(info) |
125 |
|
126 |
aclps.ps_path = acltext; |
127 |
aclps.ps_size = PATH_MAX; |
128 |
+ |
129 |
+#ifdef HAVE_FREEBSD_NFSV4_ACL |
130 |
+ if (info->f_xflags & XF_ACL_ACE) { |
131 |
+ ssize_t len = strlen(info->f_acl_ace) + 2; |
132 |
+ |
133 |
+ if (len > aclps.ps_size) { |
134 |
+ aclps.ps_path = NULL; |
135 |
+ aclps.ps_size = 0; |
136 |
+ grow_pspace(PS_EXIT, &aclps, len); |
137 |
+ if (aclps.ps_size <= len) { |
138 |
+ free_pspace(&aclps); |
139 |
+ return; |
140 |
+ } |
141 |
+ } |
142 |
+ acl_check_ids(aclps.ps_path, info->f_acl_ace, TRUE); |
143 |
+ |
144 |
+ if ((acl = acl_from_text(aclps.ps_path)) == NULL) { |
145 |
+ if (!errhidden(E_BADACL, info->f_name)) { |
146 |
+ if (!errwarnonly(E_BADACL, info->f_name)) |
147 |
+ xstats.s_badacl++; |
148 |
+ errmsg("Cannot convert NFSv4 ACL '%s' to internal format for ' %s'.\n", |
149 |
+ aclps.ps_path, info->f_name); |
150 |
+ (void) errabort(E_BADACL, info->f_name, TRUE); |
151 |
+ } |
152 |
+ } else { |
153 |
+ if (acl_set_file(info->f_name, ACL_TYPE_NFS4, |
154 |
+ acl) < 0) { |
155 |
+ /* |
156 |
+ * XXX What should we do if errno is |
157 |
+ * ENOTSUP/ENOSYS? |
158 |
+ */ |
159 |
+ if (!errhidden(E_SETACL, info->f_name)) { |
160 |
+ if (!errwarnonly(E_SETACL, |
161 |
+ info->f_name)) |
162 |
+ xstats.s_setacl++; |
163 |
+ errmsg("Cannot set NFSv4 ACL '%s' for '%s'.\n", |
164 |
+ aclps.ps_path, info->f_name); |
165 |
+ (void) errabort(E_SETACL, info->f_name, |
166 |
+ TRUE); |
167 |
+ } |
168 |
+ } |
169 |
+ acl_free(acl); |
170 |
+ } |
171 |
+ if (aclps.ps_path != acltext) |
172 |
+ free_pspace(&aclps); |
173 |
+ return; |
174 |
+ } |
175 |
+#endif /* HAVE_FREEBSD_NFSV4_ACL */ |
176 |
+ |
177 |
if (info->f_xflags & XF_ACL_ACCESS) { |
178 |
ssize_t len = strlen(info->f_acl_access) + 2; |
179 |
|