2 Unix SMB/CIFS implementation.
3 client security descriptor functions
4 Copyright (C) Andrew Tridgell 2000
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 query the security descriptor for a open file
25 ****************************************************************************/
26 SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum,
30 char *rparam=NULL, *rdata=NULL;
31 int rparam_count=0, rdata_count=0;
35 SIVAL(param, 0, fnum);
38 if (!cli_send_nt_trans(cli,
39 NT_TRANSACT_QUERY_SECURITY_DESC,
44 DEBUG(1,("Failed to send NT_TRANSACT_QUERY_SECURITY_DESC\n"));
49 if (!cli_receive_nt_trans(cli,
50 &rparam, &rparam_count,
51 &rdata, &rdata_count)) {
52 DEBUG(1,("Failed to recv NT_TRANSACT_QUERY_SECURITY_DESC\n"));
56 prs_init(&pd, rdata_count, mem_ctx, UNMARSHALL);
57 prs_append_data(&pd, rdata, rdata_count);
60 if (!sec_io_desc("sd data", &psd, &pd, 1)) {
61 DEBUG(1,("Failed to parse secdesc\n"));
74 /****************************************************************************
75 set the security descriptor for a open file
76 ****************************************************************************/
77 BOOL cli_set_secdesc(struct cli_state *cli, int fnum, SEC_DESC *sd)
80 char *rparam=NULL, *rdata=NULL;
81 int rparam_count=0, rdata_count=0;
86 if ((mem_ctx = talloc_init()) == NULL) {
87 DEBUG(0,("talloc_init failed.\n"));
91 prs_init(&pd, 0, mem_ctx, MARSHALL);
92 prs_give_memory(&pd, NULL, 0, True);
94 if (!sec_io_desc("sd data", &sd, &pd, 1)) {
95 DEBUG(1,("Failed to marshall secdesc\n"));
99 SIVAL(param, 0, fnum);
100 SSVAL(param, 4, 0x7);
102 if (!cli_send_nt_trans(cli,
103 NT_TRANSACT_SET_SECURITY_DESC,
107 pd.data_p, pd.data_offset, 0)) {
108 DEBUG(1,("Failed to send NT_TRANSACT_SET_SECURITY_DESC\n"));
113 if (!cli_receive_nt_trans(cli,
114 &rparam, &rparam_count,
115 &rdata, &rdata_count)) {
116 DEBUG(1,("NT_TRANSACT_SET_SECURITY_DESC failed\n"));
127 talloc_destroy(mem_ctx);