s4:kdc: Implement KDC plugin hardware authentication policy
[samba.git] / source3 / modules / vfs_afsacl.c
index 5838fd01c2f1a846d47e0c838630fd97cc7e7c6a..3dc80d3bddc7173fdeb86e72ecbae16ae72b1356 100644 (file)
@@ -25,6 +25,7 @@
 #include "../libcli/security/dom_sid.h"
 #include "passdb.h"
 #include "lib/afs/afs_settoken.h"
+#include "lib/util/string_wrappers.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -74,7 +75,7 @@ static bool init_afs_acl(struct afs_acl *acl)
        ZERO_STRUCT(*acl);
        acl->ctx = talloc_init("afs_acl");
        if (acl->ctx == NULL) {
-               DEBUG(10, ("Could not init afs_acl"));
+               DEBUG(10, ("Could not init afs_acl\n"));
                return false;
        }
        return true;
@@ -690,7 +691,7 @@ static size_t afs_fto_nt_acl(struct afs_acl *afs_acl,
 {
        SMB_STRUCT_STAT sbuf;
 
-       if (fsp->fh->fd == -1) {
+       if (fsp_get_pathref_fd(fsp) == -1) {
                /* Get the stat struct for the owner info. */
                return afs_to_nt_acl(afs_acl, fsp->conn, fsp->fsp_name,
                                     security_info, mem_ctx, ppdesc);
@@ -722,7 +723,7 @@ static bool mappable_sid(const struct dom_sid *sid)
 
        string_to_sid(&domain_sid, "S-1-5-21");
 
-       if (sid_compare_domain(sid, &domain_sid) == 0)
+       if (dom_sid_compare_domain(sid, &domain_sid) == 0)
                return true;
 
        return false;
@@ -761,8 +762,9 @@ static bool nt_to_afs_acl(const char *filename,
                }
 
                if (!mappable_sid(&ace->trustee)) {
+                       struct dom_sid_buf buf;
                        DEBUG(10, ("Ignoring unmappable SID %s\n",
-                                  sid_string_dbg(&ace->trustee)));
+                                  dom_sid_str_buf(&ace->trustee, &buf)));
                        continue;
                }
 
@@ -791,8 +793,9 @@ static bool nt_to_afs_acl(const char *filename,
 
                        if (!lookup_sid(talloc_tos(), &ace->trustee,
                                        &dom_name, &name, &name_type)) {
+                               struct dom_sid_buf buf;
                                DEBUG(1, ("AFSACL: Could not lookup SID %s on file %s\n",
-                                         sid_string_dbg(&ace->trustee),
+                                         dom_sid_str_buf(&ace->trustee, &buf),
                                          filename));
                                continue;
                        }
@@ -814,10 +817,11 @@ static bool nt_to_afs_acl(const char *filename,
                        }
 
                        if (sidpts) {
+                               struct dom_sid_buf buf;
                                /* Expect all users/groups in pts as SIDs */
                                name = talloc_strdup(
                                        talloc_tos(),
-                                       sid_string_tos(&ace->trustee));
+                                       dom_sid_str_buf(&ace->trustee, &buf));
                                if (name == NULL) {
                                        return false;
                                }
@@ -927,7 +931,7 @@ static NTSTATUS afs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
                return NT_STATUS_NO_MEMORY;
        }
 
-       if (!fsp->is_directory) {
+       if (!fsp->fsp_flags.is_directory) {
                /* We need to get the name of the directory containing the
                 * file, this is where the AFS acls live */
                char *p = strrchr(name, '/');
@@ -948,7 +952,7 @@ static NTSTATUS afs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
 
        split_afs_acl(&old_afs_acl, &dir_acl, &file_acl);
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
 
                if (!strequal(fileacls, "yes")) {
                        /* Throw away file acls, we depend on the
@@ -1032,31 +1036,6 @@ static NTSTATUS afsacl_fget_nt_acl(struct vfs_handle_struct *handle,
        return (sd_size != 0) ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED;
 }
 
-static NTSTATUS afsacl_get_nt_acl(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint32_t security_info,
-                               TALLOC_CTX *mem_ctx,
-                               struct security_descriptor **ppdesc)
-{
-       struct afs_acl acl;
-       size_t sd_size;
-
-       DEBUG(5, ("afsacl_get_nt_acl: %s\n", smb_fname->base_name));
-
-       sidpts = lp_parm_bool(SNUM(handle->conn), "afsacl", "sidpts", false);
-
-       if (!afs_get_afs_acl(smb_fname->base_name, &acl)) {
-               return NT_STATUS_ACCESS_DENIED;
-       }
-
-       sd_size = afs_to_nt_acl(&acl, handle->conn, smb_fname, security_info,
-                               mem_ctx, ppdesc);
-
-       free_afs_acl(&acl);
-
-       return (sd_size != 0) ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED;
-}
-
 static NTSTATUS afsacl_fset_nt_acl(vfs_handle_struct *handle,
                         files_struct *fsp,
                         uint32_t security_info_sent,
@@ -1084,13 +1063,6 @@ static int afsacl_connect(vfs_handle_struct *handle,
        return 0;
 }
 
-/* We don't have a linear form of the AFS ACL yet */
-static int afsacl_sys_acl_blob_get_file(vfs_handle_struct *handle, const char *path_p, TALLOC_CTX *mem_ctx, char **blob_description, DATA_BLOB *blob)
-{
-       errno = ENOSYS;
-       return -1;
-}
-
 /* We don't have a linear form of the AFS ACL yet */
 static int afsacl_sys_acl_blob_get_fd(vfs_handle_struct *handle, files_struct *fsp, TALLOC_CTX *mem_ctx, char **blob_description, DATA_BLOB *blob)
 {
@@ -1101,14 +1073,12 @@ static int afsacl_sys_acl_blob_get_fd(vfs_handle_struct *handle, files_struct *f
 static struct vfs_fn_pointers vfs_afsacl_fns = {
        .connect_fn = afsacl_connect,
        .fget_nt_acl_fn = afsacl_fget_nt_acl,
-       .get_nt_acl_fn = afsacl_get_nt_acl,
        .fset_nt_acl_fn = afsacl_fset_nt_acl,
-       .sys_acl_blob_get_file_fn = afsacl_sys_acl_blob_get_file,
        .sys_acl_blob_get_fd_fn = afsacl_sys_acl_blob_get_fd
 };
 
-NTSTATUS vfs_afsacl_init(void);
-NTSTATUS vfs_afsacl_init(void)
+static_decl_vfs;
+NTSTATUS vfs_afsacl_init(TALLOC_CTX *ctx)
 {
        return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "afsacl",
                                &vfs_afsacl_fns);