xref: /onnv-gate/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_init.c (revision 10504:ee04788f8605)
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 /*
229832Samw@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
235331Samw  * Use is subject to license terms.
245331Samw  */
255331Samw 
267588Samw@Sun.COM #include <sys/errno.h>
277588Samw@Sun.COM #include <stdlib.h>
285331Samw #include <unistd.h>
297588Samw@Sun.COM #include <strings.h>
307588Samw@Sun.COM #include <string.h>
317588Samw@Sun.COM #include <rpc/xdr.h>
327588Samw@Sun.COM #include <synch.h>
335772Sas200622 #include <pthread.h>
347588Samw@Sun.COM #include <smbsrv/smb_door_svc.h>
357588Samw@Sun.COM #include <smbsrv/smb_common_door.h>
367588Samw@Sun.COM #include <smbsrv/libsmb.h>
375331Samw #include <smbsrv/libmlsvc.h>
388334SJose.Borrego@Sun.COM #include <mlsvc.h>
395772Sas200622 
405772Sas200622 static void *mlsvc_keepalive(void *);
415772Sas200622 
425772Sas200622 static pthread_t mlsvc_keepalive_thr;
435772Sas200622 #define	MLSVC_KEEPALIVE_INTERVAL	(10 * 60)	/* 10 minutes */
445331Samw 
455331Samw /*
468334SJose.Borrego@Sun.COM  * All NDR RPC service initialization is invoked from here.
475331Samw  * Returns 0 upon success.  Otherwise, returns -1.
485331Samw  */
495331Samw int
505331Samw mlsvc_init(void)
515331Samw {
525772Sas200622 	pthread_attr_t tattr;
535772Sas200622 	int rc;
545772Sas200622 
55*10504SKeyur.Desai@Sun.COM 	smb_proc_initsem();
56*10504SKeyur.Desai@Sun.COM 
579832Samw@Sun.COM 	if (smb_logon_init() != NT_STATUS_SUCCESS)
589832Samw@Sun.COM 		return (-1);
599832Samw@Sun.COM 
608334SJose.Borrego@Sun.COM 	if ((rc = smb_dclocator_init()) != 0)
618334SJose.Borrego@Sun.COM 		return (rc);
628334SJose.Borrego@Sun.COM 
635331Samw 	srvsvc_initialize();
645331Samw 	wkssvc_initialize();
655331Samw 	lsarpc_initialize();
665331Samw 	netr_initialize();
675331Samw 	dssetup_initialize();
685331Samw 	samr_initialize();
695331Samw 	svcctl_initialize();
705331Samw 	winreg_initialize();
715331Samw 	logr_initialize();
728334SJose.Borrego@Sun.COM 	msgsvcsend_initialize();
738334SJose.Borrego@Sun.COM 	spoolss_initialize();
745331Samw 
755772Sas200622 	(void) pthread_attr_init(&tattr);
765772Sas200622 	(void) pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
775772Sas200622 	rc = pthread_create(&mlsvc_keepalive_thr, &tattr,
785772Sas200622 	    mlsvc_keepalive, 0);
795772Sas200622 	(void) pthread_attr_destroy(&tattr);
805772Sas200622 	return (rc);
815331Samw }
825772Sas200622 
839832Samw@Sun.COM void
849832Samw@Sun.COM mlsvc_fini(void)
859832Samw@Sun.COM {
869832Samw@Sun.COM 	smb_logon_fini();
8710122SJordan.Brown@Sun.COM 	svcctl_finalize();
8810122SJordan.Brown@Sun.COM 	logr_finalize();
899832Samw@Sun.COM }
909832Samw@Sun.COM 
915772Sas200622 /*ARGSUSED*/
925772Sas200622 static void *
935772Sas200622 mlsvc_keepalive(void *arg)
945772Sas200622 {
955772Sas200622 	unsigned long t;
965772Sas200622 
975772Sas200622 	for (;;) {
985772Sas200622 		(void) sleep(MLSVC_KEEPALIVE_INTERVAL);
995772Sas200622 
1008334SJose.Borrego@Sun.COM 		if (smb_config_get_secmode() == SMB_SECMODE_DOMAIN)
1017348SJose.Borrego@Sun.COM 			(void) srvsvc_gettime(&t);
1025772Sas200622 	}
1035772Sas200622 
1045772Sas200622 	/*NOTREACHED*/
1055772Sas200622 	return (NULL);
1065772Sas200622 }
107