r12694: Move some headers to the directory of the subsystem they belong to.
[jelmer/samba4-debian.git] / source / libcli / raw / rawacl.c
index c45152381d63fcc5fcf92e673bf75310db23e3e4..08515eadde112a9e0c96e5b3b0b752de202c3bfe 100644 (file)
@@ -1,7 +1,8 @@
 /* 
    Unix SMB/CIFS implementation.
    ACL get/set operations
-   Copyright (C) Andrew Tridgell 2003
+
+   Copyright (C) Andrew Tridgell 2003-2004
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 */
 
 #include "includes.h"
+#include "libcli/raw/libcliraw.h"
 
 /****************************************************************************
 fetch file ACL (async send)
 ****************************************************************************/
-struct cli_request *smb_raw_query_secdesc_send(struct cli_tree *tree, 
-                                              struct smb_query_secdesc *query)
+struct smbcli_request *smb_raw_query_secdesc_send(struct smbcli_tree *tree, 
+                                                 union smb_fileinfo *io)
 {
        struct smb_nttrans nt;
-       uint8 params[8];
+       uint8_t params[8];
 
        nt.in.max_setup = 0;
        nt.in.max_param = 4;
-       nt.in.max_data = 0x10000;
+       nt.in.max_data = 0xFFFF;
        nt.in.setup_count = 0;
        nt.in.function = NT_TRANSACT_QUERY_SECURITY_DESC;
        nt.in.setup = NULL;
 
-       SSVAL(params, 0, query->in.fnum);
+       SSVAL(params, 0, io->query_secdesc.in.fnum);
        SSVAL(params, 2, 0); /* padding */
-       SIVAL(params, 4, query->in.secinfo_flags);
+       SIVAL(params, 4, io->query_secdesc.secinfo_flags);
 
        nt.in.params.data = params;
        nt.in.params.length = 8;
@@ -52,9 +54,9 @@ struct cli_request *smb_raw_query_secdesc_send(struct cli_tree *tree,
 /****************************************************************************
 fetch file ACL (async recv)
 ****************************************************************************/
-NTSTATUS smb_raw_query_secdesc_recv(struct cli_request *req, 
+NTSTATUS smb_raw_query_secdesc_recv(struct smbcli_request *req, 
                                    TALLOC_CTX *mem_ctx, 
-                                   struct smb_query_secdesc *query)
+                                   union smb_fileinfo *io)
 {
        NTSTATUS status;
        struct smb_nttrans nt;
@@ -78,21 +80,26 @@ NTSTATUS smb_raw_query_secdesc_recv(struct cli_request *req,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       status = ndr_pull_security_descriptor(ndr, &query->out.sd);
+       io->query_secdesc.out.sd = talloc(mem_ctx, struct security_descriptor);
+       if (!io->query_secdesc.out.sd) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       status = ndr_pull_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, 
+                                             io->query_secdesc.out.sd);
 
-       return NT_STATUS_OK;
+       return status;
 }
 
 
 /****************************************************************************
 fetch file ACL (sync interface)
 ****************************************************************************/
-NTSTATUS smb_raw_query_secdesc(struct cli_tree *tree, 
+NTSTATUS smb_raw_query_secdesc(struct smbcli_tree *tree, 
                               TALLOC_CTX *mem_ctx, 
-                              struct smb_query_secdesc *query)
+                              union smb_fileinfo *io)
 {
-       struct cli_request *req = smb_raw_query_secdesc_send(tree, query);
-       return smb_raw_query_secdesc_recv(req, mem_ctx, query);
+       struct smbcli_request *req = smb_raw_query_secdesc_send(tree, io);
+       return smb_raw_query_secdesc_recv(req, mem_ctx, io);
 }
 
 
@@ -100,13 +107,13 @@ NTSTATUS smb_raw_query_secdesc(struct cli_tree *tree,
 /****************************************************************************
 set file ACL (async send)
 ****************************************************************************/
-struct cli_request *smb_raw_set_secdesc_send(struct cli_tree *tree, 
-                                            struct smb_set_secdesc *set)
+struct smbcli_request *smb_raw_set_secdesc_send(struct smbcli_tree *tree, 
+                                               union smb_setfileinfo *io)
 {
        struct smb_nttrans nt;
-       uint8 params[8];
+       uint8_t params[8];
        struct ndr_push *ndr;
-       struct cli_request *req;
+       struct smbcli_request *req;
        NTSTATUS status;
 
        nt.in.max_setup = 0;
@@ -116,9 +123,9 @@ struct cli_request *smb_raw_set_secdesc_send(struct cli_tree *tree,
        nt.in.function = NT_TRANSACT_SET_SECURITY_DESC;
        nt.in.setup = NULL;
 
-       SSVAL(params, 0, set->in.fnum);
+       SSVAL(params, 0, io->set_secdesc.file.fnum);
        SSVAL(params, 2, 0); /* padding */
-       SIVAL(params, 4, set->in.secinfo_flags);
+       SIVAL(params, 4, io->set_secdesc.in.secinfo_flags);
 
        nt.in.params.data = params;
        nt.in.params.length = 8;
@@ -126,12 +133,12 @@ struct cli_request *smb_raw_set_secdesc_send(struct cli_tree *tree,
        ndr = ndr_push_init();
        if (!ndr) return NULL;
 
-//     status = ndr_push_security_descriptor(ndr, set->in.sd);
+       status = ndr_push_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, io->set_secdesc.in.sd);
        if (!NT_STATUS_IS_OK(status)) {
                ndr_push_free(ndr);
                return NULL;
        }
-       
+
        nt.in.data = ndr_push_blob(ndr);
 
        req = smb_raw_nttrans_send(tree, &nt);
@@ -139,3 +146,13 @@ struct cli_request *smb_raw_set_secdesc_send(struct cli_tree *tree,
        ndr_push_free(ndr);
        return req;
 }
+
+/****************************************************************************
+set file ACL (sync interface)
+****************************************************************************/
+NTSTATUS smb_raw_set_secdesc(struct smbcli_tree *tree, 
+                            union smb_setfileinfo *io)
+{
+       struct smbcli_request *req = smb_raw_set_secdesc_send(tree, io);
+       return smbcli_request_simple_recv(req);
+}