* read the local file's acls and return it in NT form
* using the NFSv4 format conversion
*/
-static NTSTATUS zfs_get_nt_acl(struct files_struct *fsp, uint32 security_info,
- struct security_descriptor **ppdesc)
+static NTSTATUS zfs_get_nt_acl_common(const char *name,
+ uint32 security_info,
+ SMB4ACL_T **ppacl)
{
int naces, i;
ace_t *acebuf;
TALLOC_CTX *mem_ctx;
/* read the number of file aces */
- if((naces = acl(fsp->fsp_name, ACE_GETACLCNT, 0, NULL)) == -1) {
+ if((naces = acl(name, ACE_GETACLCNT, 0, NULL)) == -1) {
if(errno == ENOSYS) {
- DEBUG(9, ("acl(ACE_GETACLCNT, %s): Operation is not supported on the filesystem where the file reside"));
+ DEBUG(9, ("acl(ACE_GETACLCNT, %s): Operation is not "
+ "supported on the filesystem where the file "
+ "reside", name));
} else {
- DEBUG(9, ("acl(ACE_GETACLCNT, %s): %s ", fsp->fsp_name,
+ DEBUG(9, ("acl(ACE_GETACLCNT, %s): %s ", name,
strerror(errno)));
}
return map_nt_error_from_unix(errno);
return NT_STATUS_NO_MEMORY;
}
/* read the aces into the field */
- if(acl(fsp->fsp_name, ACE_GETACL, naces, acebuf) < 0) {
- DEBUG(9, ("acl(ACE_GETACL, %s): %s ", fsp->fsp_name,
+ if(acl(name, ACE_GETACL, naces, acebuf) < 0) {
+ DEBUG(9, ("acl(ACE_GETACL, %s): %s ", name,
strerror(errno)));
return map_nt_error_from_unix(errno);
}
return NT_STATUS_NO_MEMORY;
}
- return smb_get_nt_acl_nfs4(fsp, security_info, ppdesc, pacl);
+ *ppacl = pacl;
+ return NT_STATUS_OK;
}
/* call-back function processing the NT acl -> ZFS acl using NFSv4 conv. */
/* store acl */
if(acl(fsp->fsp_name, ACE_SETACL, naces, acebuf)) {
if(errno == ENOSYS) {
- DEBUG(9, ("acl(ACE_SETACL, %s): Operation is not supported on the filesystem where the file reside"));
+ DEBUG(9, ("acl(ACE_SETACL, %s): Operation is not "
+ "supported on the filesystem where the file "
+ "reside", fsp->fsp_name));
} else {
DEBUG(9, ("acl(ACE_SETACL, %s): %s ", fsp->fsp_name,
strerror(errno)));
*/
static NTSTATUS zfs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
uint32 security_info_sent,
- struct security_descriptor *psd)
+ const struct security_descriptor *psd)
{
return smb_set_nt_acl_nfs4(fsp, security_info_sent, psd,
zfs_process_smbacl);
static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
- int fd, uint32 security_info,
+ uint32 security_info,
struct security_descriptor **ppdesc)
{
- return zfs_get_nt_acl(fsp, security_info, ppdesc);
+ SMB4ACL_T *pacl;
+ NTSTATUS status;
+
+ status = zfs_get_nt_acl_common(fsp->fsp_name, security_info, &pacl);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl);
}
static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle,
- struct files_struct *fsp,
const char *name, uint32 security_info,
struct security_descriptor **ppdesc)
{
- return zfs_get_nt_acl(fsp, security_info, ppdesc);
+ SMB4ACL_T *pacl;
+ NTSTATUS status;
+
+ status = zfs_get_nt_acl_common(name, security_info, &pacl);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return smb_get_nt_acl_nfs4(handle->conn, name, security_info, ppdesc,
+ pacl);
}
static NTSTATUS zfsacl_fset_nt_acl(vfs_handle_struct *handle,
files_struct *fsp,
- int fd, uint32 security_info_sent,
- SEC_DESC *psd)
-{
- return zfs_set_nt_acl(handle, fsp, security_info_sent, psd);
-}
-
-static NTSTATUS zfsacl_set_nt_acl(vfs_handle_struct *handle,
- files_struct *fsp,
- const char *name, uint32 security_info_sent,
- SEC_DESC *psd)
+ uint32 security_info_sent,
+ const SEC_DESC *psd)
{
return zfs_set_nt_acl(handle, fsp, security_info_sent, psd);
}
/* VFS operations structure */
-static vfs_op_tuple zfsacl_ops[] = {
+static vfs_op_tuple zfsacl_ops[] = {
{SMB_VFS_OP(zfsacl_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(zfsacl_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(zfsacl_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(zfsacl_set_nt_acl), SMB_VFS_OP_SET_NT_ACL,
- SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
};
-/* != 0 if this module will be compiled as static */
-
-#define STATIC 0
-
-#if STATIC
NTSTATUS vfs_zfsacl_init(void);
-#else
-NTSTATUS init_module(void);
-#endif
-
-NTSTATUS
-#if STATIC
- vfs_zfsacl_init
-#else
- init_module
-#endif
- (void)
+NTSTATUS vfs_zfsacl_init(void)
{
return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "zfsacl",
zfsacl_ops);