Merge branch 'master' of ssh://git.samba.org/data/git/samba
[ira/wip.git] / source3 / modules / vfs_aixacl2.c
index b4e28be5d8c567c1c58863f2045060586b64ead0..a078b9f9f62c9801cb6a4a5059e4f8b004c9fdf4 100644 (file)
 
 #define AIXACL2_MODULE_NAME "aixacl2"
 
-extern struct current_user current_user;
 extern int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_t gid);
-extern BOOL unpack_nt_owners(int snum, uid_t *puser, gid_t *pgrp,
-       uint32 security_info_sent, SEC_DESC *psd);
 
 extern SMB_ACL_T aixacl_to_smbacl( struct acl *file_acl);
 extern struct acl *aixacl_smb_to_aixacl(SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
@@ -66,7 +63,7 @@ static AIXJFS2_ACL_T *aixjfs2_getacl_alloc(const char *fname, acl_type_t *type)
        uint64_t ctl_flag=0;
        TALLOC_CTX      *mem_ctx;
 
-       mem_ctx = main_loop_talloc_get();
+       mem_ctx = talloc_tos();
        acl = (AIXJFS2_ACL_T *)TALLOC_SIZE(mem_ctx, len);
        if (acl == NULL) {
                errno = ENOMEM;
@@ -98,8 +95,8 @@ static AIXJFS2_ACL_T *aixjfs2_getacl_alloc(const char *fname, acl_type_t *type)
        return acl;
 }
 
-static BOOL aixjfs2_get_nfs4_acl(files_struct *fsp,
-       SMB4ACL_T **ppacl, BOOL *pretryPosix)
+static bool aixjfs2_get_nfs4_acl(const char *name,
+       SMB4ACL_T **ppacl, bool *pretryPosix)
 {
        int32_t i;
        
@@ -108,15 +105,15 @@ static BOOL aixjfs2_get_nfs4_acl(files_struct *fsp,
        nfs4_ace_int_t *jfs2_ace = NULL;
        acl_type_t type;
 
-       DEBUG(10,("jfs2 get_nt_acl invoked for %s\n", fsp->fsp_name));
+       DEBUG(10,("jfs2 get_nt_acl invoked for %s\n", name));
 
        memset(&type, 0, sizeof(acl_type_t));
        type.u64 = ACL_NFS4;
 
-       pacl = aixjfs2_getacl_alloc(fsp->fsp_name, &type);
+       pacl = aixjfs2_getacl_alloc(name, &type);
         if (pacl == NULL) {
                DEBUG(9, ("aixjfs2_getacl_alloc failed for %s with %s\n",
-                               fsp->fsp_name, strerror(errno)));
+                               name, strerror(errno)));
                if (errno==ENOSYS)
                        *pretryPosix = True;
                return False;
@@ -158,38 +155,48 @@ static BOOL aixjfs2_get_nfs4_acl(files_struct *fsp,
        return True;
 }
 
-static size_t aixjfs2_get_nt_acl_common(files_struct *fsp,
-       uint32 security_info, SEC_DESC **ppdesc)
+static NTSTATUS aixjfs2_fget_nt_acl(vfs_handle_struct *handle,
+       files_struct *fsp, uint32 security_info,
+       SEC_DESC **ppdesc)
 {
        SMB4ACL_T *pacl = NULL;
-       BOOL    result;
-       BOOL    retryPosix = False;
+       bool    result;
+       bool    retryPosix = False;
 
        *ppdesc = NULL;
-       result = aixjfs2_get_nfs4_acl(fsp, &pacl, &retryPosix);
+       result = aixjfs2_get_nfs4_acl(fsp->fsp_name, &pacl, &retryPosix);
        if (retryPosix)
        {
                DEBUG(10, ("retrying with posix acl...\n"));
-               return get_nt_acl(fsp, security_info, ppdesc);
+               return posix_fget_nt_acl(fsp, security_info, ppdesc);
        }
        if (result==False)
-               return 0;
-
-       return smb_get_nt_acl_nfs4(fsp, security_info, ppdesc, pacl);
-}
+               return NT_STATUS_ACCESS_DENIED;
 
-size_t aixjfs2_fget_nt_acl(vfs_handle_struct *handle,
-       files_struct *fsp, int fd, uint32 security_info,
-       SEC_DESC **ppdesc)
-{
-       return aixjfs2_get_nt_acl_common(fsp, security_info, ppdesc);
+       return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl);
 }
 
-size_t aixjfs2_get_nt_acl(vfs_handle_struct *handle,
-       files_struct *fsp, const char *name,
+static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle,
+       const char *name,
        uint32 security_info, SEC_DESC **ppdesc)
 {
-       return aixjfs2_get_nt_acl_common(fsp, security_info, ppdesc);
+       SMB4ACL_T *pacl = NULL;
+       bool    result;
+       bool    retryPosix = False;
+
+       *ppdesc = NULL;
+       result = aixjfs2_get_nfs4_acl(name, &pacl, &retryPosix);
+       if (retryPosix)
+       {
+               DEBUG(10, ("retrying with posix acl...\n"));
+               return posix_get_nt_acl(handle->conn, name, security_info,
+                                       ppdesc);
+       }
+       if (result==False)
+               return NT_STATUS_ACCESS_DENIED;
+
+       return smb_get_nt_acl_nfs4(handle->conn, name, security_info, ppdesc,
+                                  pacl);
 }
 
 static SMB_ACL_T aixjfs2_get_posix_acl(const char *path, acl_type_t type)
@@ -248,8 +255,7 @@ SMB_ACL_T aixjfs2_sys_acl_get_file(vfs_handle_struct *handle,
 }
 
 SMB_ACL_T aixjfs2_sys_acl_get_fd(vfs_handle_struct *handle,
-                                  files_struct *fsp,
-                                  int fd)
+                                  files_struct *fsp)
 {
         acl_type_t aixjfs2_type;
         aixjfs2_type.u64 = ACL_AIXC;
@@ -290,7 +296,7 @@ static int aixjfs2_query_acl_support(
        return 1; /* haven't found that ACL type. */
 }
 
-static BOOL aixjfs2_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl)
+static bool aixjfs2_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl)
 {
        SMB4ACE_T       *smbace;
        TALLOC_CTX      *mem_ctx;
@@ -303,7 +309,7 @@ static BOOL aixjfs2_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl)
        DEBUG(10, ("jfs2_process_smbacl invoked on %s\n", fsp->fsp_name));
 
        /* no need to be freed which is alloced with mem_ctx */
-       mem_ctx = main_loop_talloc_get();
+       mem_ctx = talloc_tos();
 
        entryLen = sizeof(nfs4_ace_int_t);
        if (entryLen & 0x03)
@@ -365,7 +371,7 @@ static BOOL aixjfs2_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl)
        return True;
 }
 
-static NTSTATUS aixjfs2_set_nt_acl_common(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
+static NTSTATUS aixjfs2_set_nt_acl_common(files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd)
 {
        acl_type_t      acl_type_info;
        NTSTATUS        result = NT_STATUS_ACCESS_DENIED;
@@ -389,12 +395,7 @@ static NTSTATUS aixjfs2_set_nt_acl_common(files_struct *fsp, uint32 security_inf
        return result;
 }
 
-NTSTATUS aixjfs2_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd)
-{
-       return aixjfs2_set_nt_acl_common(fsp, security_info_sent, psd);
-}
-
-NTSTATUS aixjfs2_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, SEC_DESC *psd)
+NTSTATUS aixjfs2_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd)
 {
        return aixjfs2_set_nt_acl_common(fsp, security_info_sent, psd);
 }
@@ -439,7 +440,7 @@ int aixjfs2_sys_acl_set_file(vfs_handle_struct *handle,
 
 int aixjfs2_sys_acl_set_fd(vfs_handle_struct *handle,
                            files_struct *fsp,
-                           int fd, SMB_ACL_T theacl)
+                           SMB_ACL_T theacl)
 {
        struct acl      *acl_aixc;
        acl_type_t      acl_type_info;
@@ -458,7 +459,7 @@ int aixjfs2_sys_acl_set_fd(vfs_handle_struct *handle,
                return -1;
 
        rc = aclx_fput(
-               fd,
+               fsp->fh->fd,
                SET_ACL, /* set only the ACL, not mode bits */
                acl_type_info,
                acl_aixc,
@@ -500,10 +501,6 @@ static vfs_op_tuple aixjfs2_ops[] =
        SMB_VFS_OP_FSET_NT_ACL,
        SMB_VFS_LAYER_TRANSPARENT},
 
-       {SMB_VFS_OP(aixjfs2_set_nt_acl),
-       SMB_VFS_OP_SET_NT_ACL,
-       SMB_VFS_LAYER_TRANSPARENT},
-
        {SMB_VFS_OP(aixjfs2_sys_acl_get_file),
        SMB_VFS_OP_SYS_ACL_GET_FILE,
        SMB_VFS_LAYER_TRANSPARENT},