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