s4:kdc: Implement KDC plugin hardware authentication policy
[samba.git] / source3 / modules / vfs_acl_tdb.c
index 2fb03c03efc21e0f29e9ed9c03f799ae7ef492dc..5ecba7ba75726c2f747aaba4d47ef71a654a51ae 100644 (file)
@@ -102,7 +102,7 @@ static NTSTATUS acl_tdb_delete(vfs_handle_struct *handle,
        uint8_t id_buf[16];
 
        /* For backwards compatibility only store the dev/inode. */
-       push_file_id_16((char *)id_buf, &id);
+       push_file_id_16(id_buf, &id);
 
        status = dbwrap_delete(db, make_tdb_data(id_buf, sizeof(id_buf)));
        return status;
@@ -131,7 +131,7 @@ static NTSTATUS fget_acl_blob(TALLOC_CTX *ctx,
        id = vfs_file_id_from_sbuf(handle->conn, &fsp->fsp_name->st);
 
        /* For backwards compatibility only store the dev/inode. */
-       push_file_id_16((char *)id_buf, &id);
+       push_file_id_16(id_buf, &id);
 
        status = dbwrap_fetch(db,
                              ctx,
@@ -154,62 +154,6 @@ static NTSTATUS fget_acl_blob(TALLOC_CTX *ctx,
        return NT_STATUS_OK;
 }
 
-/*******************************************************************
- Pull a security descriptor into a DATA_BLOB from a tdb store.
-*******************************************************************/
-
-static NTSTATUS get_acl_blob_at(TALLOC_CTX *ctx,
-                       vfs_handle_struct *handle,
-                       struct files_struct *dirfsp,
-                       const struct smb_filename *smb_fname,
-                       DATA_BLOB *pblob)
-{
-       uint8_t id_buf[16];
-       TDB_DATA data;
-       struct file_id id;
-       struct db_context *db = acl_db;
-       NTSTATUS status = NT_STATUS_OK;
-       SMB_STRUCT_STAT sbuf;
-       int ret;
-
-       ZERO_STRUCT(sbuf);
-
-       ret = vfs_stat_smb_basename(handle->conn,
-                               smb_fname,
-                               &sbuf);
-       if (ret == -1) {
-               status = map_nt_error_from_unix(errno);
-       }
-
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
-       id = vfs_file_id_from_sbuf(handle->conn, &sbuf);
-
-       /* For backwards compatibility only store the dev/inode. */
-       push_file_id_16((char *)id_buf, &id);
-
-       status = dbwrap_fetch(db,
-                             ctx,
-                             make_tdb_data(id_buf, sizeof(id_buf)),
-                             &data);
-       if (!NT_STATUS_IS_OK(status)) {
-               return NT_STATUS_INTERNAL_DB_CORRUPTION;
-       }
-
-       pblob->data = data.dptr;
-       pblob->length = data.dsize;
-
-       DBG_DEBUG("returned %u bytes from file %s\n",
-               (unsigned int)data.dsize, smb_fname->base_name );
-
-       if (pblob->length == 0 || pblob->data == NULL) {
-               return NT_STATUS_NOT_FOUND;
-       }
-       return NT_STATUS_OK;
-}
-
 /*******************************************************************
  Store a DATA_BLOB into a tdb record given an fsp pointer.
 *******************************************************************/
@@ -235,7 +179,7 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
        id = vfs_file_id_from_sbuf(handle->conn, &fsp->fsp_name->st);
 
        /* For backwards compatibility only store the dev/inode. */
-       push_file_id_16((char *)id_buf, &id);
+       push_file_id_16(id_buf, &id);
 
        status = dbwrap_store(
                db, make_tdb_data(id_buf, sizeof(id_buf)), data, 0);
@@ -369,55 +313,13 @@ static int connect_acl_tdb(struct vfs_handle_struct *handle,
  Remove a Windows ACL - we're setting the underlying POSIX ACL.
 *********************************************************************/
 
-static int sys_acl_set_file_tdb(vfs_handle_struct *handle,
-                       const struct smb_filename *smb_fname_in,
-                       SMB_ACL_TYPE_T type,
-                       SMB_ACL_T theacl)
-{
-       struct db_context *db = acl_db;
-       int ret = -1;
-       int saved_errno = 0;
-       struct smb_filename *smb_fname = NULL;
-
-       smb_fname = cp_smb_filename_nostream(talloc_tos(), smb_fname_in);
-       if (smb_fname == NULL) {
-               return -1;
-       };
-
-       ret = SMB_VFS_STAT(handle->conn, smb_fname);
-       if (ret == -1) {
-               saved_errno = errno;
-               goto fail;
-       }
-
-       ret = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle,
-                                               smb_fname,
-                                               type,
-                                               theacl);
-       if (ret == -1) {
-               saved_errno = errno;
-               goto fail;
-       }
-
-       acl_tdb_delete(handle, db, &smb_fname->st);
-
-fail:
-       TALLOC_FREE(smb_fname);
-
-       if (saved_errno != 0) {
-               errno = saved_errno;
-       }
-       return ret;
-}
-
-/*********************************************************************
- Remove a Windows ACL - we're setting the underlying POSIX ACL.
-*********************************************************************/
-
 static int sys_acl_set_fd_tdb(vfs_handle_struct *handle,
                             files_struct *fsp,
+                           SMB_ACL_TYPE_T type,
                             SMB_ACL_T theacl)
 {
+       struct acl_common_fsp_ext *ext = (struct acl_common_fsp_ext *)
+               VFS_FETCH_FSP_EXTENSION(handle, fsp);
        struct db_context *db = acl_db;
        NTSTATUS status;
        int ret;
@@ -428,12 +330,17 @@ static int sys_acl_set_fd_tdb(vfs_handle_struct *handle,
        }
 
        ret = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle,
-                                               fsp,
-                                               theacl);
+                                         fsp,
+                                         type,
+                                         theacl);
        if (ret == -1) {
                return -1;
        }
 
+       if (ext != NULL && ext->setting_nt_acl) {
+               return 0;
+       }
+
        acl_tdb_delete(handle, db, &fsp->fsp_name->st);
        return 0;
 }
@@ -450,25 +357,6 @@ static NTSTATUS acl_tdb_fget_nt_acl(vfs_handle_struct *handle,
        return status;
 }
 
-static NTSTATUS acl_tdb_get_nt_acl_at(vfs_handle_struct *handle,
-                               struct files_struct *dirfsp,
-                               const struct smb_filename *smb_fname,
-                               uint32_t security_info,
-                               TALLOC_CTX *mem_ctx,
-                               struct security_descriptor **ppdesc)
-{
-       NTSTATUS status;
-       status = get_nt_acl_common_at(get_acl_blob_at,
-                               handle,
-                               dirfsp,
-                               smb_fname,
-                               security_info,
-                               mem_ctx,
-                               ppdesc);
-       return status;
-}
-
-
 static NTSTATUS acl_tdb_fset_nt_acl(vfs_handle_struct *handle,
                                    files_struct *fsp,
                                    uint32_t security_info_sent,
@@ -485,12 +373,9 @@ static struct vfs_fn_pointers vfs_acl_tdb_fns = {
        .connect_fn = connect_acl_tdb,
        .disconnect_fn = disconnect_acl_tdb,
        .unlinkat_fn = unlinkat_acl_tdb,
-       .chmod_fn = chmod_acl_module_common,
        .fchmod_fn = fchmod_acl_module_common,
        .fget_nt_acl_fn = acl_tdb_fget_nt_acl,
-       .get_nt_acl_at_fn = acl_tdb_get_nt_acl_at,
        .fset_nt_acl_fn = acl_tdb_fset_nt_acl,
-       .sys_acl_set_file_fn = sys_acl_set_file_tdb,
        .sys_acl_set_fd_fn = sys_acl_set_fd_tdb
 };