1 /*
2    Unix SMB/CIFS implementation.
3    Samba system utilities for ACL support.
4    Copyright (C) Jeremy Allison 2000.
5    Copyright (C) Volker Lendecke 2006
6    Copyright (C) Michael Adam 2006,2008
7 
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12 
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include "includes.h"
23 #include "system/passwd.h"
24 
25 #if defined(HAVE_POSIX_ACLS)
26 #include "modules/vfs_posixacl.h"
27 #endif
28 
29 #if defined(HAVE_TRU64_ACLS)
30 #include "modules/vfs_tru64acl.h"
31 #endif
32 
33 #if defined(HAVE_SOLARIS_UNIXWARE_ACLS)
34 #include "modules/vfs_solarisacl.h"
35 #endif
36 
37 #if defined(HAVE_HPUX_ACLS)
38 #include "modules/vfs_hpuxacl.h"
39 #endif
40 
41 /*
42  * NFSv4 ACL's should be understood and a first class citizen. Work
43  * needs to be done in librpc/idl/smb_acl.idl for this to occur.
44  */
45 #if defined(HAVE_LIBSUNACL) && defined(FREEBSD)
46 #if 0
47 #include "modules/nfs4_acls.h"
48 #endif
49 #endif
50 
51 #undef  DBGC_CLASS
52 #define DBGC_CLASS DBGC_ACLS
53 
54 /*
55  * Note that while this code implements sufficient functionality
56  * to support the sys_acl_* interfaces it does not provide all
57  * of the semantics of the POSIX ACL interfaces.
58  *
59  * In particular, an ACL entry descriptor (SMB_ACL_ENTRY_T) returned
60  * from a call to sys_acl_get_entry() should not be assumed to be
61  * valid after calling any of the following functions, which may
62  * reorder the entries in the ACL.
63  *
64  *	sys_acl_valid()
65  *	sys_acl_set_file()
66  *	sys_acl_set_fd()
67  */
68 
sys_acl_get_entry(SMB_ACL_T acl_d,int entry_id,SMB_ACL_ENTRY_T * entry_p)69 int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p)
70 {
71 	if (entry_id != SMB_ACL_FIRST_ENTRY && entry_id != SMB_ACL_NEXT_ENTRY) {
72 		errno = EINVAL;
73 		return -1;
74 	}
75 
76 	if (entry_p == NULL) {
77 		errno = EINVAL;
78 		return -1;
79 	}
80 
81 	if (entry_id == SMB_ACL_FIRST_ENTRY) {
82 		acl_d->next = 0;
83 	}
84 
85 	if (acl_d->next < 0) {
86 		errno = EINVAL;
87 		return -1;
88 	}
89 
90 	if (acl_d->next >= acl_d->count) {
91 		return 0;
92 	}
93 
94 	*entry_p = &acl_d->acl[acl_d->next++];
95 
96 	return 1;
97 }
98 
sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d,SMB_ACL_TAG_T * type_p)99 int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p)
100 {
101 	*type_p = entry_d->a_type;
102 
103 	return 0;
104 }
105 
sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d,SMB_ACL_PERMSET_T * permset_p)106 int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p)
107 {
108 	*permset_p = &entry_d->a_perm;
109 
110 	return 0;
111 }
112 
sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d)113 void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d)
114 {
115 	if (entry_d->a_type == SMB_ACL_USER) {
116 		return &entry_d->info.user.uid;
117 	}
118 
119 	if (entry_d->a_type == SMB_ACL_GROUP) {
120 		return &entry_d->info.group.gid;
121 	}
122 
123 	errno = EINVAL;
124 	return NULL;
125 }
126 
sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d)127 int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d)
128 {
129 	*permset_d = 0;
130 
131 	return 0;
132 }
133 
sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d,SMB_ACL_PERM_T perm)134 int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm)
135 {
136 	if (perm != SMB_ACL_READ && perm != SMB_ACL_WRITE
137 	    && perm != SMB_ACL_EXECUTE) {
138 		errno = EINVAL;
139 		return -1;
140 	}
141 
142 	if (permset_d == NULL) {
143 		errno = EINVAL;
144 		return -1;
145 	}
146 
147 	*permset_d |= perm;
148 
149 	return 0;
150 }
151 
sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d,SMB_ACL_PERM_T perm)152 int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm)
153 {
154 	return *permset_d & perm;
155 }
156 
sys_acl_to_text(const struct smb_acl_t * acl_d,ssize_t * len_p)157 char *sys_acl_to_text(const struct smb_acl_t *acl_d, ssize_t *len_p)
158 {
159 	int	i;
160 	int	len, maxlen;
161 	char	*text;
162 
163 	/*
164 	 * use an initial estimate of 20 bytes per ACL entry
165 	 * when allocating memory for the text representation
166 	 * of the ACL
167 	 */
168 	len	= 0;
169 	maxlen	= 20 * acl_d->count;
170 	if ((text = (char *)SMB_MALLOC(maxlen)) == NULL) {
171 		errno = ENOMEM;
172 		return NULL;
173 	}
174 
175 	for (i = 0; i < acl_d->count; i++) {
176 		struct smb_acl_entry *ap = &acl_d->acl[i];
177 		struct group	*gr;
178 		char		tagbuf[12];
179 		char		idbuf[12];
180 		const char	*tag;
181 		const char	*id	= "";
182 		char		perms[4];
183 		int		nbytes;
184 
185 		switch (ap->a_type) {
186 			/*
187 			 * for debugging purposes it's probably more
188 			 * useful to dump unknown tag types rather
189 			 * than just returning an error
190 			 */
191 			default:
192 				slprintf(tagbuf, sizeof(tagbuf)-1, "0x%x",
193 					 ap->a_type);
194 				tag = tagbuf;
195 				break;
196 
197 			case SMB_ACL_USER:
198 				id = uidtoname(ap->info.user.uid);
199 
200 				FALL_THROUGH;
201 			case SMB_ACL_USER_OBJ:
202 				tag = "user";
203 				break;
204 
205 			case SMB_ACL_GROUP:
206 				if ((gr = getgrgid(ap->info.group.gid)) == NULL) {
207 					slprintf(idbuf, sizeof(idbuf)-1, "%ld",
208 						(long)ap->info.group.gid);
209 					id = idbuf;
210 				} else {
211 					id = gr->gr_name;
212 				}
213 
214 				FALL_THROUGH;
215 			case SMB_ACL_GROUP_OBJ:
216 				tag = "group";
217 				break;
218 
219 			case SMB_ACL_OTHER:
220 				tag = "other";
221 				break;
222 
223 			case SMB_ACL_MASK:
224 				tag = "mask";
225 				break;
226 
227 		}
228 
229 		perms[0] = (ap->a_perm & SMB_ACL_READ) ? 'r' : '-';
230 		perms[1] = (ap->a_perm & SMB_ACL_WRITE) ? 'w' : '-';
231 		perms[2] = (ap->a_perm & SMB_ACL_EXECUTE) ? 'x' : '-';
232 		perms[3] = '\0';
233 
234 		/*          <tag>      :  <qualifier>   :  rwx \n  \0 */
235 		nbytes = strlen(tag) + 1 + strlen(id) + 1 + 3 + 1 + 1;
236 
237 		/*
238 		 * If this entry would overflow the buffer
239 		 * allocate enough additional memory for this
240 		 * entry and an estimate of another 20 bytes
241 		 * for each entry still to be processed
242 		 */
243 		if ((len + nbytes) > maxlen) {
244 			maxlen += nbytes + 20 * (acl_d->count - i);
245 			if ((text = (char *)SMB_REALLOC(text, maxlen)) == NULL) {
246 				errno = ENOMEM;
247 				return NULL;
248 			}
249 		}
250 
251 
252 		slprintf(&text[len], nbytes, "%s:%s:%s\n", tag, id, perms);
253 		len += (nbytes - 1);
254 	}
255 
256 	if (len_p)
257 		*len_p = len;
258 
259 	return text;
260 }
261 
sys_acl_init(TALLOC_CTX * mem_ctx)262 SMB_ACL_T sys_acl_init(TALLOC_CTX *mem_ctx)
263 {
264 	SMB_ACL_T	a;
265 
266 	if ((a = talloc(mem_ctx, struct smb_acl_t)) == NULL) {
267 		errno = ENOMEM;
268 		return NULL;
269 	}
270 
271 	a->count = 0;
272 	a->next = -1;
273 
274 	a->acl = talloc_array(a, struct smb_acl_entry, 0);
275 	if (!a->acl) {
276 		TALLOC_FREE(a);
277 		errno = ENOMEM;
278 		return NULL;
279 	}
280 
281 	return a;
282 }
283 
sys_acl_create_entry(SMB_ACL_T * acl_p,SMB_ACL_ENTRY_T * entry_p)284 int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p)
285 {
286 	SMB_ACL_T	acl_d;
287 	SMB_ACL_ENTRY_T	entry_d;
288 	struct smb_acl_entry *acl;
289 
290 	if (acl_p == NULL || entry_p == NULL || (acl_d = *acl_p) == NULL) {
291 		errno = EINVAL;
292 		return -1;
293 	}
294 
295 	acl = talloc_realloc(acl_d, acl_d->acl, struct smb_acl_entry, acl_d->count+1);
296 	if (!acl) {
297 		errno = ENOMEM;
298 		return -1;
299 	}
300 	acl_d->acl = acl;
301 	entry_d		= &acl_d->acl[acl_d->count];
302 	entry_d->a_type	= SMB_ACL_TAG_INVALID;
303 	entry_d->a_perm	= 0;
304 	*entry_p	= entry_d;
305 
306 	acl_d->count++;
307 	return 0;
308 }
309 
sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d,SMB_ACL_TAG_T tag_type)310 int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type)
311 {
312 	switch (tag_type) {
313 		case SMB_ACL_USER:
314 		case SMB_ACL_USER_OBJ:
315 		case SMB_ACL_GROUP:
316 		case SMB_ACL_GROUP_OBJ:
317 		case SMB_ACL_OTHER:
318 		case SMB_ACL_MASK:
319 			entry_d->a_type = tag_type;
320 			break;
321 		default:
322 			errno = EINVAL;
323 			return -1;
324 		}
325 
326 	return 0;
327 }
328 
sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d,void * qual_p)329 int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p)
330 {
331 	if (entry_d->a_type == SMB_ACL_USER) {
332 		entry_d->info.user.uid = *((uid_t *)qual_p);
333 		return 0;
334 	}
335 	if (entry_d->a_type == SMB_ACL_GROUP) {
336 		entry_d->info.group.gid = *((gid_t *)qual_p);
337 		return 0;
338 	}
339 
340 	errno = EINVAL;
341 	return -1;
342 }
343 
sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d,SMB_ACL_PERMSET_T permset_d)344 int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d)
345 {
346 	if (*permset_d & ~(SMB_ACL_READ|SMB_ACL_WRITE|SMB_ACL_EXECUTE)) {
347 		errno = EINVAL;
348 		return -1;
349 	}
350 
351 	entry_d->a_perm = *permset_d;
352 
353 	return 0;
354 }
355 
sys_acl_free_text(char * text)356 int sys_acl_free_text(char *text)
357 {
358 	SAFE_FREE(text);
359 	return 0;
360 }
361 
sys_acl_valid(SMB_ACL_T acl_d)362 int sys_acl_valid(SMB_ACL_T acl_d)
363 {
364 	errno = EINVAL;
365 	return -1;
366 }
367 
368 /*
369  * acl_get_file, acl_get_fd, acl_set_file, acl_set_fd and
370  * sys_acl_delete_def_file are to be redirected to the default
371  * statically-bound acl vfs module, but they are replacable.
372  */
373 
374 #if defined(HAVE_POSIX_ACLS)
375 
sys_acl_get_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,TALLOC_CTX * mem_ctx)376 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
377 			const struct smb_filename *smb_fname,
378 			SMB_ACL_TYPE_T type,
379 			TALLOC_CTX *mem_ctx)
380 {
381 	return posixacl_sys_acl_get_file(handle, smb_fname, type, mem_ctx);
382 }
383 
sys_acl_get_fd(vfs_handle_struct * handle,files_struct * fsp,TALLOC_CTX * mem_ctx)384 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, TALLOC_CTX *mem_ctx)
385 {
386 	return posixacl_sys_acl_get_fd(handle, fsp, mem_ctx);
387 }
388 
sys_acl_set_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,SMB_ACL_T acl_d)389 int sys_acl_set_file(vfs_handle_struct *handle,
390 			const struct smb_filename *smb_fname,
391 			SMB_ACL_TYPE_T type,
392 			SMB_ACL_T acl_d)
393 {
394 	return posixacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
395 }
396 
sys_acl_set_fd(vfs_handle_struct * handle,files_struct * fsp,SMB_ACL_T acl_d)397 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
398 		   SMB_ACL_T acl_d)
399 {
400 	return posixacl_sys_acl_set_fd(handle, fsp, acl_d);
401 }
402 
sys_acl_delete_def_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname)403 int sys_acl_delete_def_file(vfs_handle_struct *handle,
404 			const struct smb_filename *smb_fname)
405 {
406 	return posixacl_sys_acl_delete_def_file(handle, smb_fname);
407 }
408 
409 #elif defined(HAVE_AIX_ACLS)
410 
sys_acl_get_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,TALLOC_CTX * mem_ctx)411 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
412 			const struct smb_filename *smb_fname,
413 			SMB_ACL_TYPE_T type,
414 			TALLOC_CTX *mem_ctx)
415 {
416 	return aixacl_sys_acl_get_file(handle, smb_fname, type, mem_ctx);
417 }
418 
sys_acl_get_fd(vfs_handle_struct * handle,files_struct * fsp,TALLOC_CTX * mem_ctx)419 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
420 			   TALLOC_CTX *mem_ctx)
421 {
422 	return aixacl_sys_acl_get_fd(handle, fsp, mem_ctx);
423 }
424 
sys_acl_set_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,SMB_ACL_T acl_d)425 int sys_acl_set_file(vfs_handle_struct *handle,
426 			const struct smb_filename *smb_fname,
427 			SMB_ACL_TYPE_T type,
428 			SMB_ACL_T acl_d)
429 {
430 	return aixacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
431 }
432 
sys_acl_set_fd(vfs_handle_struct * handle,files_struct * fsp,SMB_ACL_T acl_d)433 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
434 		   SMB_ACL_T acl_d)
435 {
436 	return aixacl_sys_acl_set_fd(handle, fsp, acl_d);
437 }
438 
sys_acl_delete_def_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname)439 int sys_acl_delete_def_file(vfs_handle_struct *handle,
440 				const struct smb_filename *smb_fname)
441 {
442 	return aixacl_sys_acl_delete_def_file(handle, smb_fname);
443 }
444 
445 #elif defined(HAVE_TRU64_ACLS)
446 
sys_acl_get_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,TALLOC_CTX * mem_ctx)447 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
448 			const struct smb_filename *smb_fname,
449 			SMB_ACL_TYPE_T type,
450 			TALLOC_CTX *mem_ctx)
451 {
452 	return tru64acl_sys_acl_get_file(handle, smb_fname, type,
453 					 mem_ctx);
454 }
455 
sys_acl_get_fd(vfs_handle_struct * handle,files_struct * fsp,TALLOC_CTX * mem_ctx)456 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
457 			 TALLOC_CTX *mem_ctx)
458 {
459 	return tru64acl_sys_acl_get_fd(handle, fsp, mem_ctx);
460 }
461 
sys_acl_set_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,SMB_ACL_T acl_d)462 int sys_acl_set_file(vfs_handle_struct *handle,
463 			const struct smb_filename *smb_fname,
464 			SMB_ACL_TYPE_T type,
465 			SMB_ACL_T acl_d)
466 {
467 	return tru64acl_sys_acl_set_file(handle, smb_fname, type, acl_d);
468 }
469 
sys_acl_set_fd(vfs_handle_struct * handle,files_struct * fsp,SMB_ACL_T acl_d)470 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
471 		   SMB_ACL_T acl_d)
472 {
473 	return tru64acl_sys_acl_set_fd(handle, fsp, acl_d);
474 }
475 
sys_acl_delete_def_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname)476 int sys_acl_delete_def_file(vfs_handle_struct *handle,
477 				const struct smb_filename *smb_fname)
478 {
479 	return tru64acl_sys_acl_delete_def_file(handle, smb_fname);
480 }
481 
482 #elif defined(HAVE_SOLARIS_UNIXWARE_ACLS)
483 
sys_acl_get_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,TALLOC_CTX * mem_ctx)484 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
485 			const struct smb_filename *smb_fname,
486 			SMB_ACL_TYPE_T type,
487 			TALLOC_CTX *mem_ctx)
488 {
489 	return solarisacl_sys_acl_get_file(handle, smb_fname, type,
490 					   mem_ctx);
491 }
492 
sys_acl_get_fd(vfs_handle_struct * handle,files_struct * fsp,TALLOC_CTX * mem_ctx)493 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
494 			 TALLOC_CTX *mem_ctx)
495 {
496 	return solarisacl_sys_acl_get_fd(handle, fsp,
497 					 mem_ctx);
498 }
499 
sys_acl_set_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,SMB_ACL_T acl_d)500 int sys_acl_set_file(vfs_handle_struct *handle,
501 			const struct smb_filename *smb_fname,
502 			SMB_ACL_TYPE_T type,
503 			SMB_ACL_T acl_d)
504 {
505 	return solarisacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
506 }
507 
sys_acl_set_fd(vfs_handle_struct * handle,files_struct * fsp,SMB_ACL_T acl_d)508 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
509 		   SMB_ACL_T acl_d)
510 {
511 	return solarisacl_sys_acl_set_fd(handle, fsp, acl_d);
512 }
513 
sys_acl_delete_def_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname)514 int sys_acl_delete_def_file(vfs_handle_struct *handle,
515 				const struct smb_filename *smb_fname)
516 {
517 	return solarisacl_sys_acl_delete_def_file(handle, smb_fname);
518 }
519 
520 #elif defined(HAVE_HPUX_ACLS)
521 
sys_acl_get_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,TALLOC_CTX * mem_ctx)522 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
523 			const struct smb_filename *smb_fname,
524 			SMB_ACL_TYPE_T type,
525 			TALLOC_CTX *mem_ctx)
526 {
527 	return hpuxacl_sys_acl_get_file(handle, smb_fname, type, mem_ctx);
528 }
529 
sys_acl_get_fd(vfs_handle_struct * handle,files_struct * fsp,TALLOC_CTX * mem_ctx)530 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
531 			   TALLOC_CTX *mem_ctx)
532 {
533 	return hpuxacl_sys_acl_get_fd(handle, fsp, mem_ctx);
534 }
535 
sys_acl_set_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,SMB_ACL_T acl_d)536 int sys_acl_set_file(vfs_handle_struct *handle,
537 			const struct smb_filename *smb_fname,
538 			SMB_ACL_TYPE_T type,
539 			SMB_ACL_T acl_d)
540 {
541 	return hpuxacl_sys_acl_set_file(handle, smb_fname, type, acl_d);
542 }
543 
sys_acl_set_fd(vfs_handle_struct * handle,files_struct * fsp,SMB_ACL_T acl_d)544 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
545 		   SMB_ACL_T acl_d)
546 {
547 	return hpuxacl_sys_acl_set_fd(handle, fsp, acl_d);
548 }
549 
sys_acl_delete_def_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname)550 int sys_acl_delete_def_file(vfs_handle_struct *handle,
551 				const struct smb_filename *smb_fname)
552 {
553 	return hpuxacl_sys_acl_delete_def_file(handle, smb_fname);
554 }
555 
556 #else /* No ACLs. */
557 
sys_acl_get_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,TALLOC_CTX * mem_ctx)558 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
559 			const struct smb_filename *smb_fname,
560 			SMB_ACL_TYPE_T type,
561 			TALLOC_CTX *mem_ctx)
562 {
563 #ifdef ENOTSUP
564 	errno = ENOTSUP;
565 #else
566 	errno = ENOSYS;
567 #endif
568 	return NULL;
569 }
570 
sys_acl_get_fd(vfs_handle_struct * handle,files_struct * fsp,TALLOC_CTX * mem_ctx)571 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
572 			 TALLOC_CTX *mem_ctx)
573 {
574 #ifdef ENOTSUP
575 	errno = ENOTSUP;
576 #else
577 	errno = ENOSYS;
578 #endif
579 	return NULL;
580 }
581 
sys_acl_set_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname,SMB_ACL_TYPE_T type,SMB_ACL_T acl_d)582 int sys_acl_set_file(vfs_handle_struct *handle,
583 			const struct smb_filename *smb_fname,
584 			SMB_ACL_TYPE_T type,
585 			SMB_ACL_T acl_d)
586 {
587 #ifdef ENOTSUP
588 	errno = ENOTSUP;
589 #else
590 	errno = ENOSYS;
591 #endif
592 	return -1;
593 }
594 
sys_acl_set_fd(vfs_handle_struct * handle,files_struct * fsp,SMB_ACL_T acl_d)595 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
596 		   SMB_ACL_T acl_d)
597 {
598 #ifdef ENOTSUP
599 	errno = ENOTSUP;
600 #else
601 	errno = ENOSYS;
602 #endif
603 	return -1;
604 }
605 
sys_acl_delete_def_file(vfs_handle_struct * handle,const struct smb_filename * smb_fname)606 int sys_acl_delete_def_file(vfs_handle_struct *handle,
607 				const struct smb_filename *smb_fname)
608 {
609 #ifdef ENOTSUP
610 	errno = ENOTSUP;
611 #else
612 	errno = ENOSYS;
613 #endif
614 	return -1;
615 }
616 
617 #endif
618 
619 /************************************************************************
620  Deliberately outside the ACL defines. Return 1 if this is a "no acls"
621  errno, 0 if not.
622 ************************************************************************/
623 
no_acl_syscall_error(int err)624 int no_acl_syscall_error(int err)
625 {
626 #if defined(ENOSYS)
627 	if (err == ENOSYS) {
628 		return 1;
629 	}
630 #endif
631 #if defined(ENOTSUP)
632 	if (err == ENOTSUP) {
633 		return 1;
634 	}
635 #endif
636 	return 0;
637 }
638