xref: /titanic_51/usr/src/uts/common/fs/smbsrv/smb2_setinfo_sec.c (revision a90cf9f29973990687fa61de9f1f6ea22e924e40)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 /*
28  * Dispatch function for SMB2_SET_INFO
29  * Similar to smb_nt_transact_security.c
30  */
31 
32 #include <smbsrv/smb2_kproto.h>
33 #include <smbsrv/smb_fsops.h>
34 #include <smbsrv/ntifs.h>
35 
36 uint32_t
37 smb2_setinfo_sec(smb_request_t *sr, smb_setinfo_t *si, uint32_t secinfo)
38 {
39 	smb_sd_t sd;
40 	uint32_t status;
41 
42 	/*
43 	 * secinfo & ...
44 	 * OWNER_SECURITY_INFORMATION,
45 	 * GROUP_SECURITY_INFORMATION,
46 	 * DACL_SECURITY_INFORMATION, ...
47 	 */
48 
49 	if ((sr->fid_ofile->f_node == NULL) ||
50 	    (sr->fid_ofile->f_ftype != SMB_FTYPE_DISK))
51 		return (NT_STATUS_INVALID_PARAMETER);
52 
53 	if (SMB_TREE_IS_READONLY(sr))
54 		return (NT_STATUS_MEDIA_WRITE_PROTECTED);
55 
56 	if (sr->tid_tree->t_acltype != ACE_T) {
57 		/*
58 		 * If target filesystem doesn't support ACE_T acls then
59 		 * don't process SACL
60 		 */
61 		secinfo &= ~SMB_SACL_SECINFO;
62 	}
63 
64 	if ((secinfo & SMB_ALL_SECINFO) == 0)
65 		return (NT_STATUS_SUCCESS);
66 
67 	status = smb_decode_sd(&si->si_data, &sd);
68 	if (status != NT_STATUS_SUCCESS)
69 		return (status);
70 
71 	if (((secinfo & SMB_OWNER_SECINFO) && (sd.sd_owner == NULL)) ||
72 	    ((secinfo & SMB_GROUP_SECINFO) && (sd.sd_group == NULL)))
73 		return (NT_STATUS_INVALID_PARAMETER);
74 
75 	if (!smb_node_is_system(sr->fid_ofile->f_node))
76 		status = smb_sd_write(sr, &sd, secinfo);
77 
78 	smb_sd_term(&sd);
79 	return (status);
80 }
81