2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 2003
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 /****************************************************************************
24 fetch file ACL (async send)
25 ****************************************************************************/
26 struct cli_request *smb_raw_query_secdesc_send(struct cli_tree *tree,
27 struct smb_query_secdesc *query)
29 struct smb_nttrans nt;
34 nt.in.max_data = 0x10000;
35 nt.in.setup_count = 0;
36 nt.in.function = NT_TRANSACT_QUERY_SECURITY_DESC;
39 SSVAL(params, 0, query->in.fnum);
40 SSVAL(params, 2, 0); /* padding */
41 SIVAL(params, 4, query->in.secinfo_flags);
43 nt.in.params.data = params;
44 nt.in.params.length = 8;
46 nt.in.data = data_blob(NULL, 0);
48 return smb_raw_nttrans_send(tree, &nt);
52 /****************************************************************************
53 fetch file ACL (async recv)
54 ****************************************************************************/
55 NTSTATUS smb_raw_query_secdesc_recv(struct cli_request *req,
57 struct smb_query_secdesc *query)
60 struct smb_nttrans nt;
63 status = smb_raw_nttrans_recv(req, mem_ctx, &nt);
64 if (!NT_STATUS_IS_OK(status)) {
68 /* check that the basics are valid */
69 if (nt.out.params.length != 4 ||
70 IVAL(nt.out.params.data, 0) > nt.out.data.length) {
71 return NT_STATUS_INVALID_PARAMETER;
74 nt.out.data.length = IVAL(nt.out.params.data, 0);
76 ndr = ndr_pull_init_blob(&nt.out.data, mem_ctx);
78 return NT_STATUS_INVALID_PARAMETER;
81 query->out.sd = talloc(mem_ctx, sizeof(query->out.sd));
83 return NT_STATUS_NO_MEMORY;
85 status = ndr_pull_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, query->out.sd);
91 /****************************************************************************
92 fetch file ACL (sync interface)
93 ****************************************************************************/
94 NTSTATUS smb_raw_query_secdesc(struct cli_tree *tree,
96 struct smb_query_secdesc *query)
98 struct cli_request *req = smb_raw_query_secdesc_send(tree, query);
99 return smb_raw_query_secdesc_recv(req, mem_ctx, query);
104 /****************************************************************************
105 set file ACL (async send)
106 ****************************************************************************/
107 struct cli_request *smb_raw_set_secdesc_send(struct cli_tree *tree,
108 struct smb_set_secdesc *set)
110 struct smb_nttrans nt;
112 struct ndr_push *ndr;
113 struct cli_request *req;
119 nt.in.setup_count = 0;
120 nt.in.function = NT_TRANSACT_SET_SECURITY_DESC;
123 SSVAL(params, 0, set->in.fnum);
124 SSVAL(params, 2, 0); /* padding */
125 SIVAL(params, 4, set->in.secinfo_flags);
127 nt.in.params.data = params;
128 nt.in.params.length = 8;
130 ndr = ndr_push_init();
131 if (!ndr) return NULL;
133 // status = ndr_push_security_descriptor(ndr, set->in.sd);
134 if (!NT_STATUS_IS_OK(status)) {
139 nt.in.data = ndr_push_blob(ndr);
141 req = smb_raw_nttrans_send(tree, &nt);