2 * Store Windows ACLs in a tdb.
4 * Copyright (C) Volker Lendecke, 2008
5 * Copyright (C) Jeremy Allison, 2008
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 /* NOTE: This is an experimental module, not yet finished. JRA. */
24 #include "librpc/gen_ndr/xattr.h"
25 #include "librpc/gen_ndr/ndr_xattr.h"
28 #define DBGC_CLASS DBGC_VFS
30 static unsigned int ref_count
;
31 static struct db_context
*acl_db
;
33 /*******************************************************************
34 Open acl_db if not already open, increment ref count.
35 *******************************************************************/
37 static bool acl_tdb_init(struct db_context
**pp_db
)
47 dbname
= lock_path("file_ntacls.tdb");
55 *pp_db
= db_open(NULL
, dbname
, 0, TDB_DEFAULT
, O_RDWR
|O_CREAT
, 0600);
71 /*******************************************************************
72 Lower ref count and close acl_db if zero.
73 *******************************************************************/
75 static void free_acl_tdb_data(void **pptr
)
77 struct db_context
**pp_db
= (struct db_context
**)pptr
;
86 /*******************************************************************
87 Fetch_lock the tdb acl record for a file
88 *******************************************************************/
90 static struct db_record
*acl_tdb_lock(TALLOC_CTX
*mem_ctx
,
91 struct db_context
*db
,
92 const struct file_id
*id
)
95 push_file_id_16((char *)id_buf
, id
);
96 return db
->fetch_locked(db
,
102 /*******************************************************************
103 Delete the tdb acl record for a file
104 *******************************************************************/
106 static NTSTATUS
acl_tdb_delete(vfs_handle_struct
*handle
,
107 struct db_context
*db
,
108 SMB_STRUCT_STAT
*psbuf
)
111 struct file_id id
= vfs_file_id_from_sbuf(handle
->conn
, psbuf
);
112 struct db_record
*rec
= acl_tdb_lock(talloc_tos(), db
, &id
);
115 * If rec == NULL there's not much we can do about it
119 DEBUG(10,("acl_tdb_delete: rec == NULL\n"));
124 status
= rec
->delete_rec(rec
);
129 /*******************************************************************
130 Parse out a struct security_descriptor from a DATA_BLOB.
131 *******************************************************************/
133 static NTSTATUS
parse_acl_blob(const DATA_BLOB
*pblob
,
134 uint32 security_info
,
135 struct security_descriptor
**ppdesc
)
137 TALLOC_CTX
*ctx
= talloc_tos();
138 struct xattr_NTACL xacl
;
139 enum ndr_err_code ndr_err
;
142 ndr_err
= ndr_pull_struct_blob(pblob
, ctx
, &xacl
,
143 (ndr_pull_flags_fn_t
)ndr_pull_xattr_NTACL
);
145 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
146 DEBUG(5, ("parse_acl_blob: ndr_pull_xattr_NTACL failed: %s\n",
147 ndr_errstr(ndr_err
)));
148 return ndr_map_error2ntstatus(ndr_err
);;
151 if (xacl
.version
!= 2) {
152 return NT_STATUS_REVISION_MISMATCH
;
155 *ppdesc
= make_sec_desc(ctx
, SEC_DESC_REVISION
, xacl
.info
.sd_hs
->sd
->type
| SEC_DESC_SELF_RELATIVE
,
156 (security_info
& OWNER_SECURITY_INFORMATION
)
157 ? xacl
.info
.sd_hs
->sd
->owner_sid
: NULL
,
158 (security_info
& GROUP_SECURITY_INFORMATION
)
159 ? xacl
.info
.sd_hs
->sd
->group_sid
: NULL
,
160 (security_info
& SACL_SECURITY_INFORMATION
)
161 ? xacl
.info
.sd_hs
->sd
->sacl
: NULL
,
162 (security_info
& DACL_SECURITY_INFORMATION
)
163 ? xacl
.info
.sd_hs
->sd
->dacl
: NULL
,
166 TALLOC_FREE(xacl
.info
.sd
);
168 return (*ppdesc
!= NULL
) ? NT_STATUS_OK
: NT_STATUS_NO_MEMORY
;
171 /*******************************************************************
172 Pull a security descriptor into a DATA_BLOB from a tdb store.
173 *******************************************************************/
175 static NTSTATUS
get_acl_blob(TALLOC_CTX
*ctx
,
176 vfs_handle_struct
*handle
,
184 struct db_context
*db
;
185 SMB_STRUCT_STAT sbuf
;
187 SMB_VFS_HANDLE_GET_DATA(handle
, db
, struct db_context
,
188 return NT_STATUS_INTERNAL_DB_CORRUPTION
);
190 if (fsp
&& fsp
->fh
->fd
!= -1) {
191 if (SMB_VFS_FSTAT(fsp
, &sbuf
) == -1) {
192 return map_nt_error_from_unix(errno
);
195 if (SMB_VFS_STAT(handle
->conn
, name
, &sbuf
) == -1) {
196 return map_nt_error_from_unix(errno
);
199 id
= vfs_file_id_from_sbuf(handle
->conn
, &sbuf
);
201 push_file_id_16((char *)id_buf
, &id
);
205 make_tdb_data(id_buf
, sizeof(id_buf
)),
207 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
210 pblob
->data
= data
.dptr
;
211 pblob
->length
= data
.dsize
;
213 DEBUG(10,("get_acl_blob: returned %u bytes from file %s\n",
214 (unsigned int)data
.dsize
, name
));
216 if (pblob
->length
== 0 || pblob
->data
== NULL
) {
217 return NT_STATUS_OBJECT_NAME_NOT_FOUND
;
222 /*******************************************************************
223 Create a DATA_BLOB from a security descriptor.
224 *******************************************************************/
226 static NTSTATUS
create_acl_blob(const struct security_descriptor
*psd
, DATA_BLOB
*pblob
)
228 struct xattr_NTACL xacl
;
229 struct security_descriptor_hash sd_hs
;
230 enum ndr_err_code ndr_err
;
231 TALLOC_CTX
*ctx
= talloc_tos();
237 xacl
.info
.sd_hs
= &sd_hs
;
238 xacl
.info
.sd_hs
->sd
= CONST_DISCARD(struct security_descriptor
*, psd
);
239 memset(&xacl
.info
.sd_hs
->hash
[0], '\0', 16);
241 ndr_err
= ndr_push_struct_blob(
243 (ndr_push_flags_fn_t
)ndr_push_xattr_NTACL
);
245 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
246 DEBUG(5, ("create_acl_blob: ndr_push_xattr_NTACL failed: %s\n",
247 ndr_errstr(ndr_err
)));
248 return ndr_map_error2ntstatus(ndr_err
);;
254 /*******************************************************************
255 Store a DATA_BLOB into a tdb record given an fsp pointer.
256 *******************************************************************/
258 static NTSTATUS
store_acl_blob_fsp(vfs_handle_struct
*handle
,
264 SMB_STRUCT_STAT sbuf
;
266 struct db_context
*db
;
267 struct db_record
*rec
;
269 DEBUG(10,("store_acl_blob_fsp: storing blob length %u on file %s\n",
270 (unsigned int)pblob
->length
, fsp
->fsp_name
));
272 SMB_VFS_HANDLE_GET_DATA(handle
, db
, struct db_context
,
273 return NT_STATUS_INTERNAL_DB_CORRUPTION
);
275 if (fsp
->fh
->fd
!= -1) {
276 if (SMB_VFS_FSTAT(fsp
, &sbuf
) == -1) {
277 return map_nt_error_from_unix(errno
);
280 if (SMB_VFS_STAT(handle
->conn
, fsp
->fsp_name
, &sbuf
) == -1) {
281 return map_nt_error_from_unix(errno
);
284 id
= vfs_file_id_from_sbuf(handle
->conn
, &sbuf
);
286 push_file_id_16((char *)id_buf
, &id
);
287 rec
= db
->fetch_locked(db
, talloc_tos(),
288 make_tdb_data(id_buf
,
291 DEBUG(0, ("store_acl_blob_fsp_tdb: fetch_lock failed\n"));
292 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
294 data
.dptr
= pblob
->data
;
295 data
.dsize
= pblob
->length
;
296 return rec
->store(rec
, data
, 0);
299 /*******************************************************************
300 Store a DATA_BLOB into a tdb record given a pathname.
301 *******************************************************************/
303 static NTSTATUS
store_acl_blob_pathname(vfs_handle_struct
*handle
,
310 SMB_STRUCT_STAT sbuf
;
311 struct db_context
*db
;
312 struct db_record
*rec
;
314 DEBUG(10,("store_acl_blob_pathname: storing blob "
315 "length %u on file %s\n",
316 (unsigned int)pblob
->length
, fname
));
318 SMB_VFS_HANDLE_GET_DATA(handle
, db
, struct db_context
,
319 return NT_STATUS_INTERNAL_DB_CORRUPTION
);
321 if (SMB_VFS_STAT(handle
->conn
, fname
, &sbuf
) == -1) {
322 return map_nt_error_from_unix(errno
);
325 id
= vfs_file_id_from_sbuf(handle
->conn
, &sbuf
);
326 push_file_id_16((char *)id_buf
, &id
);
328 rec
= db
->fetch_locked(db
, talloc_tos(),
329 make_tdb_data(id_buf
,
332 DEBUG(0, ("store_acl_blob_pathname_tdb: fetch_lock failed\n"));
333 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
335 data
.dptr
= pblob
->data
;
336 data
.dsize
= pblob
->length
;
337 return rec
->store(rec
, data
, 0);
340 /*******************************************************************
341 Store a DATA_BLOB into an tdb given a pathname.
342 *******************************************************************/
344 static NTSTATUS
get_nt_acl_tdb_internal(vfs_handle_struct
*handle
,
347 uint32 security_info
,
348 struct security_descriptor
**ppdesc
)
350 TALLOC_CTX
*ctx
= talloc_tos();
354 if (fsp
&& name
== NULL
) {
355 name
= fsp
->fsp_name
;
358 DEBUG(10, ("get_nt_acl_tdb_internal: name=%s\n", name
));
360 status
= get_acl_blob(ctx
, handle
, fsp
, name
, &blob
);
361 if (!NT_STATUS_IS_OK(status
)) {
362 DEBUG(10, ("get_acl_blob returned %s\n", nt_errstr(status
)));
366 status
= parse_acl_blob(&blob
, security_info
, ppdesc
);
367 if (!NT_STATUS_IS_OK(status
)) {
368 DEBUG(10, ("parse_acl_blob returned %s\n",
373 TALLOC_FREE(blob
.data
);
377 /*********************************************************************
378 Create a default security descriptor for a file in case no inheritance
379 exists. All permissions to the owner and SYSTEM.
380 *********************************************************************/
382 static struct security_descriptor
*default_file_sd(TALLOC_CTX
*mem_ctx
,
383 SMB_STRUCT_STAT
*psbuf
)
385 struct dom_sid owner_sid
, group_sid
;
387 struct security_ace
*pace
= NULL
;
388 struct security_acl
*pacl
= NULL
;
390 uid_to_sid(&owner_sid
, psbuf
->st_uid
);
391 gid_to_sid(&group_sid
, psbuf
->st_gid
);
393 pace
= TALLOC_ARRAY(mem_ctx
, struct security_ace
, 2);
398 init_sec_ace(&pace
[0], &owner_sid
, SEC_ACE_TYPE_ACCESS_ALLOWED
,
399 SEC_RIGHTS_FILE_ALL
, 0);
400 init_sec_ace(&pace
[1], &global_sid_System
, SEC_ACE_TYPE_ACCESS_ALLOWED
,
401 SEC_RIGHTS_FILE_ALL
, 0);
403 pacl
= make_sec_acl(mem_ctx
,
410 return make_sec_desc(mem_ctx
,
411 SECURITY_DESCRIPTOR_REVISION_1
,
412 SEC_DESC_SELF_RELATIVE
|SEC_DESC_DACL_PRESENT
,
420 /*********************************************************************
421 *********************************************************************/
423 static NTSTATUS
inherit_new_acl(vfs_handle_struct
*handle
,
428 TALLOC_CTX
*ctx
= talloc_tos();
430 struct security_descriptor
*parent_desc
= NULL
;
431 struct security_descriptor
*psd
= NULL
;
436 if (!parent_dirname_talloc(ctx
,
440 return NT_STATUS_NO_MEMORY
;
443 DEBUG(10,("inherit_new_acl: check directory %s\n",
446 status
= get_nt_acl_tdb_internal(handle
,
449 (OWNER_SECURITY_INFORMATION
|
450 GROUP_SECURITY_INFORMATION
|
451 DACL_SECURITY_INFORMATION
),
453 if (NT_STATUS_IS_OK(status
)) {
454 /* Create an inherited descriptor from the parent. */
456 if (DEBUGLEVEL
>= 10) {
457 DEBUG(10,("inherit_new_acl: parent acl is:\n"));
458 NDR_PRINT_DEBUG(security_descriptor
, parent_desc
);
461 status
= se_create_child_secdesc(ctx
,
465 &handle
->conn
->server_info
->ptok
->user_sids
[PRIMARY_USER_SID_INDEX
],
466 &handle
->conn
->server_info
->ptok
->user_sids
[PRIMARY_GROUP_SID_INDEX
],
468 if (!NT_STATUS_IS_OK(status
)) {
472 if (DEBUGLEVEL
>= 10) {
473 DEBUG(10,("inherit_new_acl: child acl is:\n"));
474 NDR_PRINT_DEBUG(security_descriptor
, psd
);
478 DEBUG(10,("inherit_new_acl: directory %s failed "
481 nt_errstr(status
) ));
484 if (!psd
|| psd
->dacl
== NULL
) {
485 SMB_STRUCT_STAT sbuf
;
489 if (fsp
&& !fsp
->is_directory
&& fsp
->fh
->fd
!= -1) {
490 ret
= SMB_VFS_FSTAT(fsp
, &sbuf
);
492 ret
= SMB_VFS_STAT(handle
->conn
,fname
, &sbuf
);
495 return map_nt_error_from_unix(errno
);
497 psd
= default_file_sd(ctx
, &sbuf
);
499 return NT_STATUS_NO_MEMORY
;
502 if (DEBUGLEVEL
>= 10) {
503 DEBUG(10,("inherit_new_acl: default acl is:\n"));
504 NDR_PRINT_DEBUG(security_descriptor
, psd
);
508 status
= create_acl_blob(psd
, &blob
);
509 if (!NT_STATUS_IS_OK(status
)) {
513 return store_acl_blob_fsp(handle
, fsp
, &blob
);
515 return store_acl_blob_pathname(handle
, fname
, &blob
);
519 /*********************************************************************
520 Check ACL on open. For new files inherit from parent directory.
521 *********************************************************************/
523 static int open_acl_tdb(vfs_handle_struct
*handle
,
529 uint32_t access_granted
= 0;
530 struct security_descriptor
*pdesc
= NULL
;
531 bool file_existed
= true;
532 NTSTATUS status
= get_nt_acl_tdb_internal(handle
,
535 (OWNER_SECURITY_INFORMATION
|
536 GROUP_SECURITY_INFORMATION
|
537 DACL_SECURITY_INFORMATION
),
539 if (NT_STATUS_IS_OK(status
)) {
540 /* See if we can access it. */
541 status
= smb1_file_se_access_check(pdesc
,
542 handle
->conn
->server_info
->ptok
,
545 if (!NT_STATUS_IS_OK(status
)) {
546 DEBUG(10,("open_acl_tdb: file %s open "
547 "refused with error %s\n",
549 nt_errstr(status
) ));
550 errno
= map_errno_from_nt_status(status
);
553 } else if (NT_STATUS_EQUAL(status
,NT_STATUS_OBJECT_NAME_NOT_FOUND
)) {
554 file_existed
= false;
557 DEBUG(10,("open_acl_tdb: get_nt_acl_attr_internal for "
558 "file %s returned %s\n",
560 nt_errstr(status
) ));
562 fsp
->fh
->fd
= SMB_VFS_NEXT_OPEN(handle
, fname
, fsp
, flags
, mode
);
564 if (!file_existed
&& fsp
->fh
->fd
!= -1) {
565 /* File was created. Inherit from parent directory. */
566 string_set(&fsp
->fsp_name
, fname
);
567 inherit_new_acl(handle
, fname
, fsp
, false);
573 /*********************************************************************
574 On unlink we need to delete the tdb record (if using tdb).
575 *********************************************************************/
577 static int unlink_acl_tdb(vfs_handle_struct
*handle
, const char *path
)
579 SMB_STRUCT_STAT sbuf
;
580 struct db_context
*db
;
583 SMB_VFS_HANDLE_GET_DATA(handle
, db
, struct db_context
, return -1);
585 if (SMB_VFS_STAT(handle
->conn
, path
, &sbuf
) == -1) {
589 ret
= SMB_VFS_NEXT_UNLINK(handle
, path
);
595 acl_tdb_delete(handle
, db
, &sbuf
);
599 /*********************************************************************
600 Store an inherited SD on mkdir.
601 *********************************************************************/
603 static int mkdir_acl_tdb(vfs_handle_struct
*handle
, const char *path
, mode_t mode
)
605 int ret
= SMB_VFS_NEXT_MKDIR(handle
, path
, mode
);
610 /* New directory - inherit from parent. */
611 inherit_new_acl(handle
, path
, NULL
, true);
615 /*********************************************************************
616 On rmdir we need to delete the tdb record (if using tdb).
617 *********************************************************************/
619 static int rmdir_acl_tdb(vfs_handle_struct
*handle
, const char *path
)
622 SMB_STRUCT_STAT sbuf
;
623 struct db_context
*db
;
626 SMB_VFS_HANDLE_GET_DATA(handle
, db
, struct db_context
, return -1);
628 if (SMB_VFS_STAT(handle
->conn
, path
, &sbuf
) == -1) {
632 ret
= SMB_VFS_NEXT_RMDIR(handle
, path
);
637 acl_tdb_delete(handle
, db
, &sbuf
);
641 /*********************************************************************
642 Fetch a security descriptor given an fsp.
643 *********************************************************************/
645 static NTSTATUS
fget_nt_acl_tdb(vfs_handle_struct
*handle
, files_struct
*fsp
,
646 uint32 security_info
, struct security_descriptor
**ppdesc
)
648 NTSTATUS status
= get_nt_acl_tdb_internal(handle
, fsp
,
649 NULL
, security_info
, ppdesc
);
650 if (NT_STATUS_IS_OK(status
)) {
651 if (DEBUGLEVEL
>= 10) {
652 DEBUG(10,("fget_nt_acl_tdb: returning tdb sd for file %s\n",
654 NDR_PRINT_DEBUG(security_descriptor
, *ppdesc
);
659 DEBUG(10,("fget_nt_acl_tdb: failed to get tdb sd for file %s, Error %s\n",
661 nt_errstr(status
) ));
663 return SMB_VFS_NEXT_FGET_NT_ACL(handle
, fsp
,
664 security_info
, ppdesc
);
667 /*********************************************************************
668 Fetch a security descriptor given a pathname.
669 *********************************************************************/
671 static NTSTATUS
get_nt_acl_tdb(vfs_handle_struct
*handle
,
672 const char *name
, uint32 security_info
, struct security_descriptor
**ppdesc
)
674 NTSTATUS status
= get_nt_acl_tdb_internal(handle
, NULL
,
675 name
, security_info
, ppdesc
);
676 if (NT_STATUS_IS_OK(status
)) {
677 if (DEBUGLEVEL
>= 10) {
678 DEBUG(10,("get_nt_acl_tdb: returning tdb sd for file %s\n",
680 NDR_PRINT_DEBUG(security_descriptor
, *ppdesc
);
685 DEBUG(10,("get_nt_acl_tdb: failed to get tdb sd for file %s, Error %s\n",
687 nt_errstr(status
) ));
689 return SMB_VFS_NEXT_GET_NT_ACL(handle
, name
,
690 security_info
, ppdesc
);
693 /*********************************************************************
694 Store a security descriptor given an fsp.
695 *********************************************************************/
697 static NTSTATUS
fset_nt_acl_tdb(vfs_handle_struct
*handle
, files_struct
*fsp
,
698 uint32 security_info_sent
, const struct security_descriptor
*psd
)
703 if (DEBUGLEVEL
>= 10) {
704 DEBUG(10,("fset_nt_acl_tdb: incoming sd for file %s\n",
706 NDR_PRINT_DEBUG(security_descriptor
,
707 CONST_DISCARD(struct security_descriptor
*,psd
));
710 status
= SMB_VFS_NEXT_FSET_NT_ACL(handle
, fsp
, security_info_sent
, psd
);
711 if (!NT_STATUS_IS_OK(status
)) {
715 /* Ensure owner and group are set. */
716 if (!psd
->owner_sid
|| !psd
->group_sid
) {
718 SMB_STRUCT_STAT sbuf
;
719 DOM_SID owner_sid
, group_sid
;
720 struct security_descriptor
*nc_psd
= dup_sec_desc(talloc_tos(), psd
);
725 if (fsp
->is_directory
|| fsp
->fh
->fd
== -1) {
726 ret
= SMB_VFS_STAT(fsp
->conn
,fsp
->fsp_name
, &sbuf
);
728 ret
= SMB_VFS_FSTAT(fsp
, &sbuf
);
731 /* Lower level acl set succeeded,
732 * so still return OK. */
735 create_file_sids(&sbuf
, &owner_sid
, &group_sid
);
736 /* This is safe as nc_psd is discarded at fn exit. */
737 nc_psd
->owner_sid
= &owner_sid
;
738 nc_psd
->group_sid
= &group_sid
;
739 security_info_sent
|= (OWNER_SECURITY_INFORMATION
|GROUP_SECURITY_INFORMATION
);
744 if ((security_info_sent
& DACL_SECURITY_INFORMATION
) &&
746 (psd
->type
& (SE_DESC_DACL_AUTO_INHERITED
|
747 SE_DESC_DACL_AUTO_INHERIT_REQ
))==
748 (SE_DESC_DACL_AUTO_INHERITED
|
749 SE_DESC_DACL_AUTO_INHERIT_REQ
) ) {
750 struct security_descriptor
*new_psd
= NULL
;
751 status
= append_parent_acl(fsp
, psd
, &new_psd
);
752 if (!NT_STATUS_IS_OK(status
)) {
753 /* Lower level acl set succeeded,
754 * so still return OK. */
761 if (DEBUGLEVEL
>= 10) {
762 DEBUG(10,("fset_nt_acl_tdb: storing tdb sd for file %s\n",
764 NDR_PRINT_DEBUG(security_descriptor
,
765 CONST_DISCARD(struct security_descriptor
*,psd
));
767 create_acl_blob(psd
, &blob
);
768 store_acl_blob_fsp(handle
, fsp
, &blob
);
773 /*******************************************************************
774 Handle opening the storage tdb if so configured.
775 *******************************************************************/
777 static int connect_acl_tdb(struct vfs_handle_struct
*handle
,
781 struct db_context
*db
;
784 res
= SMB_VFS_NEXT_CONNECT(handle
, service
, user
);
789 if (!acl_tdb_init(&db
)) {
790 SMB_VFS_NEXT_DISCONNECT(handle
);
794 SMB_VFS_HANDLE_SET_DATA(handle
, db
, free_acl_tdb_data
,
795 struct db_context
, return -1);
800 /*********************************************************************
801 Remove a Windows ACL - we're setting the underlying POSIX ACL.
802 *********************************************************************/
804 static int sys_acl_set_file_tdb(vfs_handle_struct
*handle
,
809 SMB_STRUCT_STAT sbuf
;
810 struct db_context
*db
;
813 SMB_VFS_HANDLE_GET_DATA(handle
, db
, struct db_context
, return -1);
815 if (SMB_VFS_STAT(handle
->conn
, path
, &sbuf
) == -1) {
819 ret
= SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle
,
827 acl_tdb_delete(handle
, db
, &sbuf
);
831 /*********************************************************************
832 Remove a Windows ACL - we're setting the underlying POSIX ACL.
833 *********************************************************************/
835 static int sys_acl_set_fd_tdb(vfs_handle_struct
*handle
,
839 SMB_STRUCT_STAT sbuf
;
840 struct db_context
*db
;
843 SMB_VFS_HANDLE_GET_DATA(handle
, db
, struct db_context
, return -1);
845 if (fsp
->is_directory
|| fsp
->fh
->fd
== -1) {
846 ret
= SMB_VFS_STAT(fsp
->conn
,fsp
->fsp_name
, &sbuf
);
848 ret
= SMB_VFS_FSTAT(fsp
, &sbuf
);
854 ret
= SMB_VFS_NEXT_SYS_ACL_SET_FD(handle
,
861 acl_tdb_delete(handle
, db
, &sbuf
);
865 /* VFS operations structure */
867 static vfs_op_tuple skel_op_tuples
[] =
869 {SMB_VFS_OP(connect_acl_tdb
), SMB_VFS_OP_CONNECT
, SMB_VFS_LAYER_TRANSPARENT
},
871 {SMB_VFS_OP(mkdir_acl_tdb
), SMB_VFS_OP_MKDIR
, SMB_VFS_LAYER_TRANSPARENT
},
872 {SMB_VFS_OP(rmdir_acl_tdb
), SMB_VFS_OP_RMDIR
, SMB_VFS_LAYER_TRANSPARENT
},
874 {SMB_VFS_OP(open_acl_tdb
), SMB_VFS_OP_OPEN
, SMB_VFS_LAYER_TRANSPARENT
},
875 {SMB_VFS_OP(unlink_acl_tdb
), SMB_VFS_OP_UNLINK
, SMB_VFS_LAYER_TRANSPARENT
},
877 /* NT File ACL operations */
879 {SMB_VFS_OP(fget_nt_acl_tdb
),SMB_VFS_OP_FGET_NT_ACL
,SMB_VFS_LAYER_TRANSPARENT
},
880 {SMB_VFS_OP(get_nt_acl_tdb
), SMB_VFS_OP_GET_NT_ACL
, SMB_VFS_LAYER_TRANSPARENT
},
881 {SMB_VFS_OP(fset_nt_acl_tdb
),SMB_VFS_OP_FSET_NT_ACL
,SMB_VFS_LAYER_TRANSPARENT
},
883 /* POSIX ACL operations. */
884 {SMB_VFS_OP(sys_acl_set_file_tdb
), SMB_VFS_OP_SYS_ACL_SET_FILE
, SMB_VFS_LAYER_TRANSPARENT
},
885 {SMB_VFS_OP(sys_acl_set_fd_tdb
), SMB_VFS_OP_SYS_ACL_SET_FD
, SMB_VFS_LAYER_TRANSPARENT
},
887 {SMB_VFS_OP(NULL
), SMB_VFS_OP_NOOP
, SMB_VFS_LAYER_NOOP
}
890 NTSTATUS
vfs_acl_tdb_init(void)
892 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "acl_tdb", skel_op_tuples
);