xref: /onnv-gate/usr/src/uts/common/fs/smbsrv/smb_process_exit.c (revision 11963:061945695ce1)
15331Samw /*
25331Samw  * CDDL HEADER START
35331Samw  *
45331Samw  * The contents of this file are subject to the terms of the
55331Samw  * Common Development and Distribution License (the "License").
65331Samw  * You may not use this file except in compliance with the License.
75331Samw  *
85331Samw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95331Samw  * or http://www.opensolaris.org/os/licensing.
105331Samw  * See the License for the specific language governing permissions
115331Samw  * and limitations under the License.
125331Samw  *
135331Samw  * When distributing Covered Code, include this CDDL HEADER in each
145331Samw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155331Samw  * If applicable, add the following below this CDDL HEADER, with the
165331Samw  * fields enclosed by brackets "[]" replaced with your own identifying
175331Samw  * information: Portions Copyright [yyyy] [name of copyright owner]
185331Samw  *
195331Samw  * CDDL HEADER END
205331Samw  */
215331Samw /*
22*11963SAfshin.Ardakani@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
235331Samw  * Use is subject to license terms.
245331Samw  */
255331Samw 
265331Samw /*
275331Samw  * SMB: process_exit
285331Samw  *
295331Samw  * This command informs the server that a client process has terminated.
305331Samw  * The server must close all files opened by Pid in the SMB header.  This
315331Samw  * must automatically release all locks the process holds.
325331Samw  *
335331Samw  * Client Request                     Description
345331Samw  * ================================== =================================
355331Samw  *
365331Samw  * UCHAR WordCount;                   Count of parameter words = 0
375331Samw  * USHORT ByteCount;                  Count of data bytes = 0
385331Samw  *
395331Samw  * Server Response                    Description
405331Samw  * ================================== =================================
415331Samw  *
425331Samw  * UCHAR WordCount;                   Count of parameter words = 0
435331Samw  *  USHORT ByteCount;                 Count of data bytes = 0
445331Samw  *
455331Samw  * This SMB should not generate any errors from the server, unless the
465331Samw  * server is a user mode server and Uid in the SMB header is invalid.
475331Samw  *
485331Samw  * Clients are not required to send this SMB, they can do all cleanup
495331Samw  * necessary by sending close SMBs to the server to release resources.  In
505331Samw  * fact, clients who have negotiated LANMAN 1.0 and later probably do not
515331Samw  * send this message at all.
525331Samw  */
535331Samw 
5410966SJordan.Brown@Sun.COM #include <smbsrv/smb_kproto.h>
555331Samw 
566030Sjb150015 smb_sdrc_t
smb_pre_process_exit(smb_request_t * sr)576139Sjb150015 smb_pre_process_exit(smb_request_t *sr)
586139Sjb150015 {
596139Sjb150015 	DTRACE_SMB_1(op__ProcessExit__start, smb_request_t *, sr);
606139Sjb150015 	return (SDRC_SUCCESS);
616139Sjb150015 }
626139Sjb150015 
636139Sjb150015 void
smb_post_process_exit(smb_request_t * sr)646139Sjb150015 smb_post_process_exit(smb_request_t *sr)
656139Sjb150015 {
666139Sjb150015 	DTRACE_SMB_1(op__ProcessExit__done, smb_request_t *, sr);
676139Sjb150015 }
686139Sjb150015 
696139Sjb150015 smb_sdrc_t
smb_com_process_exit(smb_request_t * sr)706139Sjb150015 smb_com_process_exit(smb_request_t *sr)
715331Samw {
726030Sjb150015 	int rc;
736030Sjb150015 
74*11963SAfshin.Ardakani@Sun.COM 	sr->uid_user = smb_session_lookup_uid(sr->session, sr->smb_uid);
755331Samw 	if (sr->uid_user == NULL) {
766030Sjb150015 		rc = smbsr_encode_empty_result(sr);
776139Sjb150015 		return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
785331Samw 	}
795331Samw 
807961SNatalie.Li@Sun.COM 	sr->user_cr = smb_user_getcred(sr->uid_user);
817961SNatalie.Li@Sun.COM 
825331Samw 	/*
835331Samw 	 * If request has a valid tree ID, only look for the PID within
845331Samw 	 * that tree.  Otherwise look in all the trees.  smbtorture seems
855331Samw 	 * to be the only thing that sends this request these days and
865331Samw 	 * it doesn't provide a TID.
875331Samw 	 */
887348SJose.Borrego@Sun.COM 	sr->tid_tree = smb_user_lookup_tree(sr->uid_user, sr->smb_tid);
897348SJose.Borrego@Sun.COM 	if (sr->tid_tree != NULL)
907348SJose.Borrego@Sun.COM 		smb_tree_close_pid(sr->tid_tree, sr->smb_pid);
917348SJose.Borrego@Sun.COM 	else
927348SJose.Borrego@Sun.COM 		smb_user_close_pid(sr->uid_user, sr->smb_pid);
935331Samw 
946030Sjb150015 	rc = smbsr_encode_empty_result(sr);
956139Sjb150015 	return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
965331Samw }
97