xref: /illumos-gate/usr/src/uts/common/fs/smbsrv/smb_logoff_andx.c (revision 1fa2a66491e7d8ae0be84e7da4da8e812480c710)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
26  */
27 
28 #include <smbsrv/smb_kproto.h>
29 
30 
31 /*
32  * smb_com_logoff_andx
33  *
34  * This SMB is the inverse of SMB_COM_SESSION_SETUP_ANDX.
35  *
36  * Client Request                     Description
37  * ================================== =================================
38  *
39  * UCHAR WordCount;                   Count of parameter words = 2
40  * UCHAR AndXCommand;                 Secondary (X) command;  0xFF = none
41  * UCHAR AndXReserved;                Reserved (must be 0)
42  * USHORT AndXOffset;                 Offset to next command WordCount
43  * USHORT ByteCount;                  Count of data bytes = 0
44  *
45  * Server Response                    Description
46  * ================================== =================================
47  *
48  * UCHAR WordCount;                   Count of parameter words = 2
49  * UCHAR AndXCommand;                 Secondary (X) command;  0xFF = none
50  * UCHAR AndXReserved;                Reserved (must be 0)
51  * USHORT AndXOffset;                 Offset to next command WordCount
52  * USHORT ByteCount;                  Count of data bytes = 0
53  *
54  * The user represented by Uid in the SMB header is logged off.  The server
55  * closes all files currently open by this user, and invalidates any
56  * outstanding requests with this Uid.
57  *
58  * SMB_COM_SESSION_SETUP_ANDX is the only valid AndX command for this SMB.
59  *
60  * 4.1.3.1   Errors
61  *
62  * ERRSRV/invnid  - TID was invalid
63  * ERRSRV/baduid  - UID was invalid
64  */
65 smb_sdrc_t
66 smb_pre_logoff_andx(smb_request_t *sr)
67 {
68 	DTRACE_SMB_START(op__LogoffX, smb_request_t *, sr);
69 	return (SDRC_SUCCESS);
70 }
71 
72 void
73 smb_post_logoff_andx(smb_request_t *sr)
74 {
75 	DTRACE_SMB_DONE(op__LogoffX, smb_request_t *, sr);
76 }
77 
78 smb_sdrc_t
79 smb_com_logoff_andx(smb_request_t *sr)
80 {
81 	if (sr->uid_user == NULL) {
82 		smbsr_error(sr, 0, ERRSRV, ERRbaduid);
83 		return (SDRC_ERROR);
84 	}
85 
86 	smb_user_logoff(sr->uid_user);
87 
88 	if (smbsr_encode_result(sr, 2, 0, "bb.ww", 2, sr->andx_com, -1, 0))
89 		return (SDRC_ERROR);
90 	return (SDRC_SUCCESS);
91 }
92