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/>.
21 #include "libsmb/libsmb.h"
22 #include "../libcli/security/secdesc.h"
24 /****************************************************************************
25 query the security descriptor for a open file
26 ****************************************************************************/
27 struct security_descriptor
*cli_query_secdesc(struct cli_state
*cli
, uint16_t fnum
,
32 uint32_t rdata_count
=0;
33 struct security_descriptor
*psd
= NULL
;
36 SIVAL(param
, 0, fnum
);
39 status
= cli_trans(talloc_tos(), cli
, SMBnttrans
,
40 NULL
, -1, /* name, fid */
41 NT_TRANSACT_QUERY_SECURITY_DESC
, 0, /* function, flags */
42 NULL
, 0, 0, /* setup, length, max */
43 param
, 8, 4, /* param, length, max */
44 NULL
, 0, 0x10000, /* data, length, max */
45 NULL
, /* recv_flags2 */
46 NULL
, 0, NULL
, /* rsetup, length */
48 &rdata
, 0, &rdata_count
);
50 if (!NT_STATUS_IS_OK(status
)) {
51 DEBUG(1, ("NT_TRANSACT_QUERY_SECURITY_DESC failed: %s\n",
56 status
= unmarshall_sec_desc(mem_ctx
, (uint8
*)rdata
, rdata_count
,
59 if (!NT_STATUS_IS_OK(status
)) {
60 DEBUG(10, ("unmarshall_sec_desc failed: %s\n",
72 /****************************************************************************
73 set the security descriptor for a open file
74 ****************************************************************************/
75 NTSTATUS
cli_set_secdesc(struct cli_state
*cli
, uint16_t fnum
,
76 struct security_descriptor
*sd
)
84 status
= marshall_sec_desc(talloc_tos(), sd
, &data
, &len
);
85 if (!NT_STATUS_IS_OK(status
)) {
86 DEBUG(10, ("marshall_sec_desc failed: %s\n",
91 SIVAL(param
, 0, fnum
);
94 sec_info
|= SECINFO_DACL
;
96 sec_info
|= SECINFO_OWNER
;
98 sec_info
|= SECINFO_GROUP
;
99 SSVAL(param
, 4, sec_info
);
101 status
= cli_trans(talloc_tos(), cli
, SMBnttrans
,
102 NULL
, -1, /* name, fid */
103 NT_TRANSACT_SET_SECURITY_DESC
, 0,
104 NULL
, 0, 0, /* setup */
105 param
, 8, 0, /* param */
106 data
, len
, 0, /* data */
107 NULL
, /* recv_flags2 */
108 NULL
, 0, NULL
, /* rsetup */
109 NULL
, 0, NULL
, /* rparam */
110 NULL
, 0, NULL
); /* rdata */
112 if (!NT_STATUS_IS_OK(status
)) {
113 DEBUG(1, ("Failed to send NT_TRANSACT_SET_SECURITY_DESC: %s\n",