2 * Convert AFS acls to NT acls and vice versa.
4 * Copyright (C) Volker Lendecke, 2003
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define DBGC_CLASS DBGC_VFS
29 #include <afs/venus.h>
30 #include <afs/prs_fs.h>
34 extern DOM_SID global_sid_World
;
35 extern DOM_SID global_sid_Builtin_Administrators
;
36 extern DOM_SID global_sid_Builtin_Backup_Operators
;
37 extern DOM_SID global_sid_Authenticated_Users
;
38 extern DOM_SID global_sid_NULL
;
40 extern int afs_syscall(int, char *, int, char *, int);
46 enum SID_NAME_USE type
;
55 struct afs_ace
*acelist
;
60 uint16 in_size
, out_size
;
64 static BOOL
init_afs_acl(struct afs_acl
*acl
)
67 acl
->ctx
= talloc_init("afs_acl");
68 if (acl
->ctx
== NULL
) {
69 DEBUG(10, ("Could not init afs_acl"));
75 static void free_afs_acl(struct afs_acl
*acl
)
78 talloc_destroy(acl
->ctx
);
84 static struct afs_ace
*clone_afs_ace(TALLOC_CTX
*mem_ctx
, struct afs_ace
*ace
)
86 struct afs_ace
*result
= talloc(mem_ctx
, sizeof(struct afs_ace
));
94 result
->name
= talloc_strdup(mem_ctx
, ace
->name
);
96 if (result
->name
== NULL
) {
104 /* Ok, this is sort-of a hack. We assume here that we have winbind users in
105 * AFS. And yet another copy of parse_domain_user.... */
107 static BOOL
parse_domain_user(const char *domuser
, fstring domain
,
110 char *p
= strchr(domuser
,*lp_winbind_separator());
117 fstrcpy(domain
, domuser
);
118 domain
[PTR_DIFF(p
, domuser
)] = 0;
124 static struct afs_ace
*new_afs_ace(TALLOC_CTX
*mem_ctx
,
126 const char *name
, uint32 rights
)
129 enum SID_NAME_USE type
;
130 struct afs_ace
*result
;
132 if (strcmp(name
, "system:administrators") == 0) {
134 sid_copy(&sid
, &global_sid_Builtin_Administrators
);
135 type
= SID_NAME_ALIAS
;
137 } else if (strcmp(name
, "system:anyuser") == 0) {
139 sid_copy(&sid
, &global_sid_World
);
140 type
= SID_NAME_ALIAS
;
142 } else if (strcmp(name
, "system:authuser") == 0) {
144 sid_copy(&sid
, &global_sid_Authenticated_Users
);
145 type
= SID_NAME_WKN_GRP
;
147 } else if (strcmp(name
, "system:backup") == 0) {
149 sid_copy(&sid
, &global_sid_Builtin_Backup_Operators
);
150 type
= SID_NAME_ALIAS
;
154 fstring user
, domain
;
156 if (!parse_domain_user(name
, domain
, user
)) {
158 fstrcpy(domain
, lp_workgroup());
161 if (!lookup_name(domain
, user
, &sid
, &type
)) {
162 DEBUG(10, ("Could not find AFS user %s\n", name
));
164 sid_copy(&sid
, &global_sid_NULL
);
165 type
= SID_NAME_UNKNOWN
;
170 result
= talloc(mem_ctx
, sizeof(struct afs_ace
));
172 if (result
== NULL
) {
173 DEBUG(0, ("Could not talloc AFS ace\n"));
177 result
->name
= talloc_strdup(mem_ctx
, name
);
178 if (result
->name
== NULL
) {
179 DEBUG(0, ("Could not talloc AFS ace name\n"));
186 result
->positive
= positive
;
187 result
->rights
= rights
;
192 static void add_afs_ace(struct afs_acl
*acl
,
194 const char *name
, uint32 rights
)
198 for (ace
= acl
->acelist
; ace
!= NULL
; ace
= ace
->next
) {
199 if ((ace
->positive
== positive
) &&
200 (strequal(ace
->name
, name
))) {
201 ace
->rights
|= rights
;
206 ace
= new_afs_ace(acl
->ctx
, positive
, name
, rights
);
208 ace
->next
= acl
->acelist
;
213 DEBUG(10, ("add_afs_ace: Added %s entry for %s with rights %d\n",
214 ace
->positive
?"positive":"negative",
215 ace
->name
, ace
->rights
));
220 /* AFS ACLs in string form are a long string of fields delimited with \n.
222 * First line: Number of positive entries
223 * Second line: Number of negative entries
224 * Third and following lines: The entries themselves
226 * An ACE is a line of two fields, delimited by \t.
229 * Second field: Rights
232 static BOOL
parse_afs_acl(struct afs_acl
*acl
, const char *acl_str
)
240 strncpy(str
, acl_str
, MAXSIZE
);
242 if (sscanf(p
, "%d", &nplus
) != 1)
245 DEBUG(10, ("Found %d positive entries\n", nplus
));
247 if ((p
= strchr(p
, '\n')) == NULL
)
251 if (sscanf(p
, "%d", &nminus
) != 1)
254 DEBUG(10, ("Found %d negative entries\n", nminus
));
256 if ((p
= strchr(p
, '\n')) == NULL
)
260 for (aces
= nplus
+nminus
; aces
> 0; aces
--)
268 if ((p
= strchr(p
, '\t')) == NULL
)
273 if (sscanf(p
, "%d", &rights
) != 1)
276 if ((p
= strchr(p
, '\n')) == NULL
)
280 add_afs_ace(acl
, nplus
>0, name
, rights
);
288 static BOOL
unparse_afs_acl(struct afs_acl
*acl
, char *acl_str
)
290 /* TODO: String length checks!!!! */
298 struct afs_ace
*ace
= acl
->acelist
;
300 while (ace
!= NULL
) {
308 fstr_sprintf(line
, "%d\n", positives
);
309 safe_strcat(acl_str
, line
, MAXSIZE
);
311 fstr_sprintf(line
, "%d\n", negatives
);
312 safe_strcat(acl_str
, line
, MAXSIZE
);
316 while (ace
!= NULL
) {
317 fstr_sprintf(line
, "%s\t%d\n", ace
->name
, ace
->rights
);
318 safe_strcat(acl_str
, line
, MAXSIZE
);
324 static uint32
afs_to_nt_file_rights(uint32 rights
)
328 if (rights
& PRSFS_READ
)
329 result
|= FILE_READ_DATA
| FILE_READ_EA
|
330 FILE_EXECUTE
| FILE_READ_ATTRIBUTES
|
331 READ_CONTROL_ACCESS
| SYNCHRONIZE_ACCESS
;
333 if (rights
& PRSFS_WRITE
)
334 result
|= FILE_WRITE_DATA
| FILE_WRITE_ATTRIBUTES
|
335 FILE_WRITE_EA
| FILE_APPEND_DATA
;
337 if (rights
& PRSFS_LOCK
)
338 result
|= WRITE_OWNER_ACCESS
;
340 if (rights
& PRSFS_DELETE
)
341 result
|= DELETE_ACCESS
;
346 static void afs_to_nt_dir_rights(uint32 afs_rights
, uint32
*nt_rights
,
350 *flag
= SEC_ACE_FLAG_OBJECT_INHERIT
|
351 SEC_ACE_FLAG_CONTAINER_INHERIT
;
353 if (afs_rights
& PRSFS_INSERT
)
354 *nt_rights
|= FILE_ADD_FILE
| FILE_ADD_SUBDIRECTORY
;
356 if (afs_rights
& PRSFS_LOOKUP
)
357 *nt_rights
|= FILE_READ_DATA
| FILE_READ_EA
|
358 FILE_EXECUTE
| FILE_READ_ATTRIBUTES
|
359 READ_CONTROL_ACCESS
| SYNCHRONIZE_ACCESS
;
361 if (afs_rights
& PRSFS_WRITE
)
362 *nt_rights
|= FILE_WRITE_ATTRIBUTES
| FILE_WRITE_DATA
|
363 FILE_APPEND_DATA
| FILE_WRITE_EA
;
365 if ((afs_rights
& (PRSFS_INSERT
|PRSFS_LOOKUP
|PRSFS_DELETE
)) ==
366 (PRSFS_INSERT
|PRSFS_LOOKUP
|PRSFS_DELETE
))
367 *nt_rights
|= FILE_WRITE_ATTRIBUTES
| FILE_WRITE_EA
|
368 GENERIC_WRITE_ACCESS
;
370 if (afs_rights
& PRSFS_DELETE
)
371 *nt_rights
|= DELETE_ACCESS
;
373 if (afs_rights
& PRSFS_ADMINISTER
)
374 *nt_rights
|= FILE_DELETE_CHILD
| WRITE_DAC_ACCESS
|
377 if ( (afs_rights
& PRSFS_LOOKUP
) ==
378 (afs_rights
& (PRSFS_LOOKUP
|PRSFS_READ
)) ) {
379 /* Only lookup right */
380 *flag
= SEC_ACE_FLAG_CONTAINER_INHERIT
;
386 #define AFS_FILE_RIGHTS (PRSFS_READ|PRSFS_WRITE|PRSFS_LOCK)
387 #define AFS_DIR_RIGHTS (PRSFS_INSERT|PRSFS_LOOKUP|PRSFS_DELETE|PRSFS_ADMINISTER)
389 static void split_afs_acl(struct afs_acl
*acl
,
390 struct afs_acl
*dir_acl
,
391 struct afs_acl
*file_acl
)
395 init_afs_acl(dir_acl
);
396 init_afs_acl(file_acl
);
398 for (ace
= acl
->acelist
; ace
!= NULL
; ace
= ace
->next
) {
399 if (ace
->rights
& AFS_FILE_RIGHTS
) {
400 add_afs_ace(file_acl
, ace
->positive
, ace
->name
,
401 ace
->rights
& AFS_FILE_RIGHTS
);
404 if (ace
->rights
& AFS_DIR_RIGHTS
) {
405 add_afs_ace(dir_acl
, ace
->positive
, ace
->name
,
406 ace
->rights
& AFS_DIR_RIGHTS
);
412 static BOOL
same_principal(struct afs_ace
*x
, struct afs_ace
*y
)
414 return ( (x
->positive
== y
->positive
) &&
415 (sid_compare(&x
->sid
, &y
->sid
) == 0) );
418 static void merge_afs_acls(struct afs_acl
*dir_acl
,
419 struct afs_acl
*file_acl
,
420 struct afs_acl
*target
)
424 init_afs_acl(target
);
426 for (ace
= dir_acl
->acelist
; ace
!= NULL
; ace
= ace
->next
) {
427 struct afs_ace
*file_ace
;
430 for (file_ace
= file_acl
->acelist
;
432 file_ace
= file_ace
->next
) {
433 if (!same_principal(ace
, file_ace
))
436 add_afs_ace(target
, ace
->positive
, ace
->name
,
437 ace
->rights
| file_ace
->rights
);
442 add_afs_ace(target
, ace
->positive
, ace
->name
,
446 for (ace
= file_acl
->acelist
; ace
!= NULL
; ace
= ace
->next
) {
447 struct afs_ace
*dir_ace
;
448 BOOL already_seen
= False
;
450 for (dir_ace
= dir_acl
->acelist
;
452 dir_ace
= dir_ace
->next
) {
453 if (!same_principal(ace
, dir_ace
))
459 add_afs_ace(target
, ace
->positive
, ace
->name
,
464 #define PERMS_READ 0x001200a9
465 #define PERMS_CHANGE 0x001301bf
466 #define PERMS_FULL 0x001f01ff
468 static struct static_dir_ace_mapping
{
476 { 0, SEC_ACE_FLAG_OBJECT_INHERIT
|SEC_ACE_FLAG_CONTAINER_INHERIT
,
477 PERMS_FULL
, 127 /* rlidwka */ },
480 { 0, SEC_ACE_FLAG_OBJECT_INHERIT
|SEC_ACE_FLAG_CONTAINER_INHERIT
,
481 PERMS_CHANGE
, 63 /* rlidwk */ },
483 /* Read (including list folder content) */
484 { 0, SEC_ACE_FLAG_OBJECT_INHERIT
|SEC_ACE_FLAG_CONTAINER_INHERIT
,
485 PERMS_READ
, 9 /* rl */ },
487 /* Read without list folder content -- same as "l" */
488 { 0, SEC_ACE_FLAG_OBJECT_INHERIT
|SEC_ACE_FLAG_CONTAINER_INHERIT
,
489 0x00120089, 8 /* l */ },
492 { 0, SEC_ACE_FLAG_CONTAINER_INHERIT
,
493 PERMS_READ
, 8 /* l */ },
495 /* FULL without inheritance -- in all cases here we also get
496 the corresponding INHERIT_ONLY ACE in the same ACL */
497 { 0, 0, PERMS_FULL
, 127 /* rlidwka */ },
499 /* FULL inherit only -- counterpart to previous one */
500 { 0, SEC_ACE_FLAG_OBJECT_INHERIT
|SEC_ACE_FLAG_CONTAINER_INHERIT
|SEC_ACE_FLAG_INHERIT_ONLY
,
501 PERMS_FULL
| GENERIC_RIGHT_WRITE_ACCESS
, 127 /* rlidwka */ },
503 /* CHANGE without inheritance -- in all cases here we also get
504 the corresponding INHERIT_ONLY ACE in the same ACL */
505 { 0, 0, PERMS_CHANGE
, 63 /* rlidwk */ },
507 /* CHANGE inherit only -- counterpart to previous one */
508 { 0, SEC_ACE_FLAG_OBJECT_INHERIT
|SEC_ACE_FLAG_CONTAINER_INHERIT
|SEC_ACE_FLAG_INHERIT_ONLY
,
509 PERMS_CHANGE
| GENERIC_RIGHT_WRITE_ACCESS
, 63 /* rlidwk */ },
511 /* End marker, hopefully there's no afs right 9999 :-) */
515 static uint32
nt_to_afs_dir_rights(const char *filename
, const SEC_ACE
*ace
)
518 uint32 rights
= ace
->info
.mask
;
519 uint8 flags
= ace
->flags
;
521 struct static_dir_ace_mapping
*m
;
523 for (m
= &ace_mappings
[0]; m
->afs_rights
!= 9999; m
++) {
524 if ( (ace
->type
== m
->type
) &&
525 (ace
->flags
== m
->flags
) &&
526 (ace
->info
.mask
== m
->mask
) )
527 return m
->afs_rights
;
530 DEBUG(1, ("AFSACL FALLBACK: 0x%X 0x%X 0x%X %s\n",
531 ace
->type
, ace
->flags
, ace
->info
.mask
, filename
));
533 if (rights
& (GENERIC_ALL_ACCESS
|WRITE_DAC_ACCESS
)) {
534 result
|= PRSFS_READ
| PRSFS_WRITE
| PRSFS_INSERT
|
535 PRSFS_LOOKUP
| PRSFS_DELETE
| PRSFS_LOCK
|
539 if (rights
& (GENERIC_READ_ACCESS
|FILE_READ_DATA
)) {
540 result
|= PRSFS_LOOKUP
;
541 if (flags
& SEC_ACE_FLAG_OBJECT_INHERIT
) {
542 result
|= PRSFS_READ
;
546 if (rights
& (GENERIC_WRITE_ACCESS
|FILE_WRITE_DATA
)) {
547 result
|= PRSFS_INSERT
| PRSFS_DELETE
;
548 if (flags
& SEC_ACE_FLAG_OBJECT_INHERIT
) {
549 result
|= PRSFS_WRITE
| PRSFS_LOCK
;
556 static uint32
nt_to_afs_file_rights(const char *filename
, const SEC_ACE
*ace
)
559 uint32 rights
= ace
->info
.mask
;
561 if (rights
& (GENERIC_READ_ACCESS
|FILE_READ_DATA
)) {
562 result
|= PRSFS_READ
;
565 if (rights
& (GENERIC_WRITE_ACCESS
|FILE_WRITE_DATA
)) {
566 result
|= PRSFS_WRITE
| PRSFS_LOCK
;
572 static size_t afs_to_nt_acl(struct afs_acl
*afs_acl
,
573 struct files_struct
*fsp
,
574 uint32 security_info
,
575 struct security_descriptor_info
**ppdesc
)
577 SEC_ACE
*nt_ace_list
;
578 DOM_SID owner_sid
, group_sid
;
580 SMB_STRUCT_STAT sbuf
;
584 TALLOC_CTX
*mem_ctx
= main_loop_talloc_get();
586 struct afs_ace
*afs_ace
;
588 if (fsp
->is_directory
|| fsp
->fd
== -1) {
589 /* Get the stat struct for the owner info. */
590 if(SMB_VFS_STAT(fsp
->conn
,fsp
->fsp_name
, &sbuf
) != 0) {
594 if(SMB_VFS_FSTAT(fsp
,fsp
->fd
,&sbuf
) != 0) {
599 uid_to_sid(&owner_sid
, sbuf
.st_uid
);
600 gid_to_sid(&group_sid
, sbuf
.st_gid
);
602 nt_ace_list
= (SEC_ACE
*)malloc(afs_acl
->num_aces
* sizeof(SEC_ACE
));
604 if (nt_ace_list
== NULL
)
607 afs_ace
= afs_acl
->acelist
;
610 while (afs_ace
!= NULL
) {
612 uint8 flag
= SEC_ACE_FLAG_OBJECT_INHERIT
|
613 SEC_ACE_FLAG_CONTAINER_INHERIT
;
615 if (afs_ace
->type
== SID_NAME_UNKNOWN
) {
616 DEBUG(10, ("Ignoring unknown name %s\n",
618 afs_ace
= afs_ace
->next
;
622 if (fsp
->is_directory
)
623 afs_to_nt_dir_rights(afs_ace
->rights
, &nt_rights
,
626 nt_rights
= afs_to_nt_file_rights(afs_ace
->rights
);
628 init_sec_access(&mask
, nt_rights
);
629 init_sec_ace(&nt_ace_list
[good_aces
++], &(afs_ace
->sid
),
630 SEC_ACE_TYPE_ACCESS_ALLOWED
, mask
, flag
);
631 afs_ace
= afs_ace
->next
;
634 psa
= make_sec_acl(mem_ctx
, NT4_ACL_REVISION
,
635 good_aces
, nt_ace_list
);
640 *ppdesc
= make_sec_desc(mem_ctx
, SEC_DESC_REVISION
,
641 SEC_DESC_SELF_RELATIVE
,
642 (security_info
& OWNER_SECURITY_INFORMATION
)
644 (security_info
& GROUP_SECURITY_INFORMATION
)
646 NULL
, psa
, &sd_size
);
651 static BOOL
mappable_sid(const DOM_SID
*sid
)
655 if (sid_compare(sid
, &global_sid_Builtin_Administrators
) == 0)
658 if (sid_compare(sid
, &global_sid_World
) == 0)
661 if (sid_compare(sid
, &global_sid_Authenticated_Users
) == 0)
664 if (sid_compare(sid
, &global_sid_Builtin_Backup_Operators
) == 0)
667 string_to_sid(&domain_sid
, "S-1-5-21");
669 if (sid_compare_domain(sid
, &domain_sid
) == 0)
675 static BOOL
nt_to_afs_acl(const char *filename
,
676 uint32 security_info_sent
,
677 struct security_descriptor_info
*psd
,
678 uint32 (*nt_to_afs_rights
)(const char *filename
,
680 struct afs_acl
*afs_acl
)
685 /* Currently we *only* look at the dacl */
687 if (((security_info_sent
& DACL_SECURITY_INFORMATION
) == 0) ||
691 if (!init_afs_acl(afs_acl
))
696 for (i
= 0; i
< dacl
->num_aces
; i
++) {
697 SEC_ACE
*ace
= &(dacl
->ace
[i
]);
700 enum SID_NAME_USE name_type
;
702 if (ace
->type
!= SEC_ACE_TYPE_ACCESS_ALLOWED
) {
703 /* First cut: Only positive ACEs */
707 if (!mappable_sid(&ace
->trustee
)) {
708 DEBUG(10, ("Ignoring unmappable SID %s\n",
709 sid_string_static(&ace
->trustee
)));
713 if (sid_compare(&ace
->trustee
,
714 &global_sid_Builtin_Administrators
) == 0) {
716 fstrcpy(name
, "system:administrators");
718 } else if (sid_compare(&ace
->trustee
,
719 &global_sid_World
) == 0) {
721 fstrcpy(name
, "system:anyuser");
723 } else if (sid_compare(&ace
->trustee
,
724 &global_sid_Authenticated_Users
) == 0) {
726 fstrcpy(name
, "system:authuser");
728 } else if (sid_compare(&ace
->trustee
,
729 &global_sid_Builtin_Backup_Operators
)
732 fstrcpy(name
, "system:backup");
736 if (!lookup_sid(&ace
->trustee
,
737 dom_name
, name
, &name_type
)) {
738 DEBUG(1, ("AFSACL: Could not lookup SID %s on file %s\n",
739 sid_string_static(&ace
->trustee
), filename
));
743 if ( (name_type
== SID_NAME_USER
) ||
744 (name_type
== SID_NAME_DOM_GRP
) ||
745 (name_type
== SID_NAME_ALIAS
) ) {
746 fstring only_username
;
747 fstrcpy(only_username
, name
);
748 fstr_sprintf(name
, "%s%s%s",
749 dom_name
, lp_winbind_separator(),
755 add_afs_ace(afs_acl
, True
, name
,
756 nt_to_afs_rights(filename
, ace
));
762 static BOOL
afs_get_afs_acl(char *filename
, struct afs_acl
*acl
)
770 DEBUG(5, ("afs_get_afs_acl: %s\n", filename
));
773 iob
.out_size
= MAXSIZE
;
774 iob
.in
= iob
.out
= space
;
776 ret
= afs_syscall(AFSCALL_PIOCTL
, filename
, VIOCGETAL
,
780 DEBUG(1, ("got error from PIOCTL: %d\n", ret
));
784 if (!init_afs_acl(acl
))
787 if (!parse_afs_acl(acl
, space
)) {
788 DEBUG(1, ("Could not parse AFS acl\n"));
796 static size_t afs_get_nt_acl(struct files_struct
*fsp
, uint32 security_info
,
797 struct security_descriptor_info
**ppdesc
)
802 DEBUG(5, ("afs_get_nt_acl: %s\n", fsp
->fsp_name
));
804 if (!afs_get_afs_acl(fsp
->fsp_name
, &acl
)) {
808 sd_size
= afs_to_nt_acl(&acl
, fsp
, security_info
, ppdesc
);
815 /* For setting an AFS ACL we have to take care of the ACEs we could
816 * not properly map to SIDs. Merge all of them into the new ACL. */
818 static void merge_unknown_aces(struct afs_acl
*src
, struct afs_acl
*dst
)
822 for (ace
= src
->acelist
; ace
!= NULL
; ace
= ace
->next
)
824 struct afs_ace
*copy
;
826 if (ace
->type
!= SID_NAME_UNKNOWN
) {
827 DEBUG(10, ("Not merging known ACE for %s\n",
832 DEBUG(10, ("Merging unknown ACE for %s\n", ace
->name
));
834 copy
= clone_afs_ace(dst
->ctx
, ace
);
837 DEBUG(0, ("Could not clone ACE for %s\n", ace
->name
));
841 copy
->next
= dst
->acelist
;
847 static BOOL
afs_set_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
848 uint32 security_info_sent
,
849 struct security_descriptor_info
*psd
)
851 struct afs_acl old_afs_acl
, new_afs_acl
;
852 struct afs_acl dir_acl
, file_acl
;
853 char acl_string
[2049];
857 const char *fileacls
;
859 fileacls
= lp_parm_const_string(SNUM(handle
->conn
), "afsacl", "fileacls",
862 ZERO_STRUCT(old_afs_acl
);
863 ZERO_STRUCT(new_afs_acl
);
864 ZERO_STRUCT(dir_acl
);
865 ZERO_STRUCT(file_acl
);
867 pstr_sprintf(name
, fsp
->fsp_name
);
869 if (!fsp
->is_directory
) {
870 char *p
= strrchr(name
, '/');
872 DEBUG(3, ("No / in file string\n"));
878 if (!afs_get_afs_acl(name
, &old_afs_acl
)) {
879 DEBUG(3, ("Could not get old ACL of %s\n", fsp
->fsp_name
));
883 split_afs_acl(&old_afs_acl
, &dir_acl
, &file_acl
);
885 if (fsp
->is_directory
) {
887 if (!strequal(fileacls
, "yes")) {
888 /* Throw away file acls, we depend on the
889 * inheritance ACEs that also give us file
891 free_afs_acl(&file_acl
);
894 free_afs_acl(&dir_acl
);
895 if (!nt_to_afs_acl(fsp
->fsp_name
, security_info_sent
, psd
,
896 nt_to_afs_dir_rights
, &dir_acl
))
899 if (strequal(fileacls
, "no")) {
904 if (strequal(fileacls
, "ignore")) {
909 free_afs_acl(&file_acl
);
910 if (!nt_to_afs_acl(fsp
->fsp_name
, security_info_sent
, psd
,
911 nt_to_afs_file_rights
, &file_acl
))
915 merge_afs_acls(&dir_acl
, &file_acl
, &new_afs_acl
);
917 merge_unknown_aces(&old_afs_acl
, &new_afs_acl
);
919 unparse_afs_acl(&new_afs_acl
, acl_string
);
922 iob
.in_size
= 1+strlen(iob
.in
);
926 DEBUG(10, ("trying to set acl '%s' on file %s\n", iob
.in
, name
));
928 ret
= afs_syscall(AFSCALL_PIOCTL
, name
, VIOCSETAL
, (char *)&iob
, 0);
931 DEBUG(10, ("VIOCSETAL returned %d\n", ret
));
935 free_afs_acl(&dir_acl
);
936 free_afs_acl(&file_acl
);
937 free_afs_acl(&old_afs_acl
);
938 free_afs_acl(&new_afs_acl
);
943 static size_t afsacl_fget_nt_acl(struct vfs_handle_struct
*handle
,
944 struct files_struct
*fsp
,
945 int fd
, uint32 security_info
,
946 struct security_descriptor_info
**ppdesc
)
948 return afs_get_nt_acl(fsp
, security_info
, ppdesc
);
950 static size_t afsacl_get_nt_acl(struct vfs_handle_struct
*handle
,
951 struct files_struct
*fsp
,
952 const char *name
, uint32 security_info
,
953 struct security_descriptor_info
**ppdesc
)
955 return afs_get_nt_acl(fsp
, security_info
, ppdesc
);
958 BOOL
afsacl_fset_nt_acl(vfs_handle_struct
*handle
,
960 int fd
, uint32 security_info_sent
,
963 return afs_set_nt_acl(handle
, fsp
, security_info_sent
, psd
);
966 BOOL
afsacl_set_nt_acl(vfs_handle_struct
*handle
,
968 const char *name
, uint32 security_info_sent
,
971 return afs_set_nt_acl(handle
, fsp
, security_info_sent
, psd
);
974 /* VFS operations structure */
976 static vfs_op_tuple afsacl_ops
[] = {
977 {SMB_VFS_OP(afsacl_fget_nt_acl
), SMB_VFS_OP_FGET_NT_ACL
,
978 SMB_VFS_LAYER_TRANSPARENT
},
979 {SMB_VFS_OP(afsacl_get_nt_acl
), SMB_VFS_OP_GET_NT_ACL
,
980 SMB_VFS_LAYER_TRANSPARENT
},
981 {SMB_VFS_OP(afsacl_fset_nt_acl
), SMB_VFS_OP_FSET_NT_ACL
,
982 SMB_VFS_LAYER_TRANSPARENT
},
983 {SMB_VFS_OP(afsacl_set_nt_acl
), SMB_VFS_OP_SET_NT_ACL
,
984 SMB_VFS_LAYER_TRANSPARENT
},
985 {SMB_VFS_OP(NULL
), SMB_VFS_OP_NOOP
, SMB_VFS_LAYER_NOOP
}
988 NTSTATUS
vfs_afsacl_init(void)
990 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "afsacl",