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 3 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, see <http://www.gnu.org/licenses/>.
22 /****************************************************************************
23 query the security descriptor for a open file
24 ****************************************************************************/
25 SEC_DESC
*cli_query_secdesc(struct cli_state
*cli
, int fnum
,
29 char *rparam
=NULL
, *rdata
=NULL
;
30 unsigned int rparam_count
=0, rdata_count
=0;
34 SIVAL(param
, 0, fnum
);
37 if (!cli_send_nt_trans(cli
,
38 NT_TRANSACT_QUERY_SECURITY_DESC
,
43 DEBUG(1,("Failed to send NT_TRANSACT_QUERY_SECURITY_DESC\n"));
48 if (!cli_receive_nt_trans(cli
,
49 &rparam
, &rparam_count
,
50 &rdata
, &rdata_count
)) {
51 DEBUG(1,("Failed to recv NT_TRANSACT_QUERY_SECURITY_DESC\n"));
55 if (cli_is_error(cli
))
58 status
= unmarshall_sec_desc(mem_ctx
, (uint8
*)rdata
, rdata_count
,
61 if (!NT_STATUS_IS_OK(status
)) {
62 DEBUG(10, ("unmarshall_sec_desc failed: %s\n",
75 /****************************************************************************
76 set the security descriptor for a open file
77 ****************************************************************************/
78 bool cli_set_secdesc(struct cli_state
*cli
, int fnum
, SEC_DESC
*sd
)
81 char *rparam
=NULL
, *rdata
=NULL
;
82 unsigned int rparam_count
=0, rdata_count
=0;
84 TALLOC_CTX
*frame
= talloc_stackframe();
90 status
= marshall_sec_desc(talloc_tos(), sd
, &data
, &len
);
91 if (!NT_STATUS_IS_OK(status
)) {
92 DEBUG(10, ("marshall_sec_desc failed: %s\n",
97 SIVAL(param
, 0, fnum
);
100 sec_info
|= DACL_SECURITY_INFORMATION
;
102 sec_info
|= OWNER_SECURITY_INFORMATION
;
104 sec_info
|= GROUP_SECURITY_INFORMATION
;
105 SSVAL(param
, 4, sec_info
);
107 if (!cli_send_nt_trans(cli
,
108 NT_TRANSACT_SET_SECURITY_DESC
,
112 (char *)data
, len
, 0)) {
113 DEBUG(1,("Failed to send NT_TRANSACT_SET_SECURITY_DESC\n"));
118 if (!cli_receive_nt_trans(cli
,
119 &rparam
, &rparam_count
,
120 &rdata
, &rdata_count
)) {
121 DEBUG(1,("NT_TRANSACT_SET_SECURITY_DESC failed\n"));