X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=source3%2Fmodules%2Fvfs_zfsacl.c;h=c5277a6b2c4e97a3138d3100ae7d689eeaa90c44;hb=HEAD;hp=c5c4718d6ce55eec283467d25b53d104ca7d2122;hpb=c10ae30c1185463eb937f69c1fc9914558087167;p=samba.git diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index c5c4718d6ce..695abf1e0df 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -58,7 +58,6 @@ static NTSTATUS zfs_get_nt_acl_common(struct connection_struct *conn, int i; struct SMB4ACL_T *pacl; SMB_STRUCT_STAT sbuf; - SMB_ACE4PROP_T blocking_ace; const SMB_STRUCT_STAT *psbuf = NULL; int ret; bool inherited_is_present = false; @@ -87,6 +86,7 @@ static NTSTATUS zfs_get_nt_acl_common(struct connection_struct *conn, } for(i=0; ifh->fd != -1) { - rv = facl(fsp->fh->fd, ACE_SETACL, naces, acebuf); - } - else { - rv = acl(fsp->fsp_name->base_name, ACE_SETACL, naces, acebuf); + fd = fsp_get_pathref_fd(fsp); + if (fd == -1) { + errno = EBADF; + return false; } + rv = facl(fd, ACE_SETACL, naces, acebuf); if (rv != 0) { if(errno == ENOSYS) { DEBUG(9, ("acl(ACE_SETACL, %s): Operation is not " "supported on the filesystem where the file " - "reside", fsp_str_dbg(fsp))); + "resides\n", fsp_str_dbg(fsp))); } else { - DEBUG(9, ("acl(ACE_SETACL, %s): %s ", fsp_str_dbg(fsp), + DEBUG(9, ("acl(ACE_SETACL, %s): %s\n", fsp_str_dbg(fsp), strerror(errno))); } return false; @@ -265,60 +278,27 @@ static NTSTATUS zfs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, zfs_process_smbacl); } -static int get_zfsacl(TALLOC_CTX *mem_ctx, - const struct smb_filename *smb_fname, - ace_t **outbuf) -{ - int naces, rv; - ace_t *acebuf = NULL; - - naces = acl(smb_fname->base_name, ACE_GETACLCNT, 0, NULL); - if (naces == -1) { - int dbg_level = 10; - - if (errno == ENOSYS) { - dbg_level = 1; - } - DEBUG(dbg_level, ("acl(ACE_GETACLCNT, %s): %s ", - smb_fname->base_name, strerror(errno))); - return naces; - } - acebuf = talloc_size(mem_ctx, sizeof(ace_t)*naces); - if (acebuf == NULL) { - errno = ENOMEM; - return -1; - } - - rv = acl(smb_fname->base_name, ACE_GETACL, naces, acebuf); - if (rv == -1) { - DBG_DEBUG("acl(ACE_GETACL, %s) failed: %s ", - smb_fname->base_name, strerror(errno)); - return -1; - } - - *outbuf = acebuf; - return naces; -} - static int fget_zfsacl(TALLOC_CTX *mem_ctx, struct files_struct *fsp, ace_t **outbuf) { int naces, rv; ace_t *acebuf = NULL; + int fd; - if (fsp->fh->fd == -1) { - return get_zfsacl(mem_ctx, fsp->fsp_name, outbuf); + fd = fsp_get_pathref_fd(fsp); + if (fd == -1) { + errno = EBADF; + return -1; } - - naces = facl(fsp->fh->fd, ACE_GETACLCNT, 0, NULL); + naces = facl(fd, ACE_GETACLCNT, 0, NULL); if (naces == -1) { int dbg_level = 10; if (errno == ENOSYS) { dbg_level = 1; } - DEBUG(dbg_level, ("facl(ACE_GETACLCNT, %s): %s ", + DEBUG(dbg_level, ("facl(ACE_GETACLCNT, %s): %s\n", fsp_str_dbg(fsp), strerror(errno))); return naces; } @@ -329,9 +309,9 @@ static int fget_zfsacl(TALLOC_CTX *mem_ctx, return -1; } - rv = facl(fsp->fh->fd, ACE_GETACL, naces, acebuf); + rv = facl(fd, ACE_GETACL, naces, acebuf); if (rv == -1) { - DBG_DEBUG("acl(ACE_GETACL, %s): %s ", + DBG_DEBUG("acl(ACE_GETACL, %s): %s\n", fsp_str_dbg(fsp), strerror(errno)); return -1; } @@ -346,6 +326,7 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx, struct security_descriptor **ppdesc) { + TALLOC_CTX *frame = NULL; struct SMB4ACL_T *pacl; NTSTATUS status; struct zfsacl_config_data *config = NULL; @@ -356,7 +337,7 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle, struct zfsacl_config_data, return NT_STATUS_INTERNAL_ERROR); - TALLOC_CTX *frame = talloc_stackframe(); + frame = talloc_stackframe(); naces = fget_zfsacl(talloc_tos(), fsp, &acebuf); if (naces == -1) { @@ -396,78 +377,6 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle, return status; } -static NTSTATUS zfsacl_get_nt_acl_at(struct 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) -{ - struct SMB4ACL_T *pacl = NULL; - NTSTATUS status; - struct zfsacl_config_data *config = NULL; - TALLOC_CTX *frame = NULL; - int naces; - ace_t *acebuf = NULL; - - SMB_ASSERT(dirfsp == handle->conn->cwd_fsp); - - SMB_VFS_HANDLE_GET_DATA(handle, - config, - struct zfsacl_config_data, - return NT_STATUS_INTERNAL_ERROR); - - frame = talloc_stackframe(); - - naces = get_zfsacl(frame, smb_fname, &acebuf); - if (naces == -1) { - status = map_nt_error_from_unix(errno); - TALLOC_FREE(frame); - if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { - return status; - } - - if (!VALID_STAT(smb_fname->st)) { - DBG_ERR("No stat info for [%s]\n", - smb_fname_str_dbg(smb_fname)); - return NT_STATUS_INTERNAL_ERROR; - } - - status = make_default_filesystem_acl(mem_ctx, - DEFAULT_ACL_POSIX, - smb_fname->base_name, - &smb_fname->st, - ppdesc); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - (*ppdesc)->type |= SEC_DESC_DACL_PROTECTED; - return NT_STATUS_OK; - } - - status = zfs_get_nt_acl_common(handle->conn, - frame, - smb_fname, - acebuf, - naces, - &pacl, - config); - if (!NT_STATUS_IS_OK(status)) { - TALLOC_FREE(frame); - return status; - } - - status = smb_get_nt_acl_nfs4(handle->conn, - smb_fname, - NULL, - security_info, - mem_ctx, - ppdesc, - pacl); - TALLOC_FREE(frame); - return status; -} - static NTSTATUS zfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32_t security_info_sent, @@ -507,47 +416,24 @@ static NTSTATUS zfsacl_fset_nt_acl(vfs_handle_struct *handle, Function declarations taken from vfs_solarisacl */ -static SMB_ACL_T zfsacl_fail__sys_acl_get_file(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - SMB_ACL_TYPE_T type, - TALLOC_CTX *mem_ctx) -{ - return (SMB_ACL_T)NULL; -} - static SMB_ACL_T zfsacl_fail__sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, + SMB_ACL_TYPE_T type, TALLOC_CTX *mem_ctx) { return (SMB_ACL_T)NULL; } -static int zfsacl_fail__sys_acl_set_file(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - SMB_ACL_TYPE_T type, - SMB_ACL_T theacl) -{ - return -1; -} - static int zfsacl_fail__sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, + SMB_ACL_TYPE_T type, SMB_ACL_T theacl) { return -1; } -static int zfsacl_fail__sys_acl_delete_def_file(vfs_handle_struct *handle, - const struct smb_filename *smb_fname) -{ - return -1; -} - -static int zfsacl_fail__sys_acl_blob_get_file(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - TALLOC_CTX *mem_ctx, - char **blob_description, - DATA_BLOB *blob) +static int zfsacl_fail__sys_acl_delete_def_fd(vfs_handle_struct *handle, + files_struct *fsp) { return -1; } @@ -601,15 +487,15 @@ static int zfsacl_connect(struct vfs_handle_struct *handle, static struct vfs_fn_pointers zfsacl_fns = { .connect_fn = zfsacl_connect, - .sys_acl_get_file_fn = zfsacl_fail__sys_acl_get_file, + .stat_fn = nfs4_acl_stat, + .fstat_fn = nfs4_acl_fstat, + .lstat_fn = nfs4_acl_lstat, + .fstatat_fn = nfs4_acl_fstatat, .sys_acl_get_fd_fn = zfsacl_fail__sys_acl_get_fd, - .sys_acl_blob_get_file_fn = zfsacl_fail__sys_acl_blob_get_file, .sys_acl_blob_get_fd_fn = zfsacl_fail__sys_acl_blob_get_fd, - .sys_acl_set_file_fn = zfsacl_fail__sys_acl_set_file, .sys_acl_set_fd_fn = zfsacl_fail__sys_acl_set_fd, - .sys_acl_delete_def_file_fn = zfsacl_fail__sys_acl_delete_def_file, + .sys_acl_delete_def_fd_fn = zfsacl_fail__sys_acl_delete_def_fd, .fget_nt_acl_fn = zfsacl_fget_nt_acl, - .get_nt_acl_at_fn = zfsacl_get_nt_acl_at, .fset_nt_acl_fn = zfsacl_fset_nt_acl, };