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*12890SJoyce.McIntosh@Sun.COM * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
235331Samw */
245331Samw
257588Samw@Sun.COM #include <sys/errno.h>
2611963SAfshin.Ardakani@Sun.COM #include <sys/tzfile.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/libsmb.h>
355331Samw #include <smbsrv/libmlsvc.h>
368334SJose.Borrego@Sun.COM #include <mlsvc.h>
375772Sas200622
3811963SAfshin.Ardakani@Sun.COM static void *mlsvc_timecheck(void *);
395772Sas200622
4011963SAfshin.Ardakani@Sun.COM #define MLSVC_TIMECHECK_INTERVAL (10 * SECSPERMIN) /* 10 minutes */
415331Samw
425331Samw /*
438334SJose.Borrego@Sun.COM * All NDR RPC service initialization is invoked from here.
445331Samw * Returns 0 upon success. Otherwise, returns -1.
455331Samw */
465331Samw int
mlsvc_init(void)475331Samw mlsvc_init(void)
485331Samw {
4911963SAfshin.Ardakani@Sun.COM pthread_t tid;
505772Sas200622 pthread_attr_t tattr;
515772Sas200622 int rc;
525772Sas200622
5310504SKeyur.Desai@Sun.COM smb_proc_initsem();
5410504SKeyur.Desai@Sun.COM
559832Samw@Sun.COM if (smb_logon_init() != NT_STATUS_SUCCESS)
569832Samw@Sun.COM return (-1);
579832Samw@Sun.COM
588334SJose.Borrego@Sun.COM if ((rc = smb_dclocator_init()) != 0)
598334SJose.Borrego@Sun.COM return (rc);
608334SJose.Borrego@Sun.COM
6111963SAfshin.Ardakani@Sun.COM smb_quota_init();
6210717Samw@Sun.COM ndr_rpc_init();
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();
7411963SAfshin.Ardakani@Sun.COM netdfs_initialize();
755331Samw
765772Sas200622 (void) pthread_attr_init(&tattr);
775772Sas200622 (void) pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
7811963SAfshin.Ardakani@Sun.COM rc = pthread_create(&tid, &tattr, mlsvc_timecheck, 0);
795772Sas200622 (void) pthread_attr_destroy(&tattr);
805772Sas200622 return (rc);
815331Samw }
825772Sas200622
839832Samw@Sun.COM void
mlsvc_fini(void)849832Samw@Sun.COM mlsvc_fini(void)
859832Samw@Sun.COM {
869832Samw@Sun.COM smb_logon_fini();
87*12890SJoyce.McIntosh@Sun.COM spoolss_finalize();
8810122SJordan.Brown@Sun.COM svcctl_finalize();
8910122SJordan.Brown@Sun.COM logr_finalize();
9011963SAfshin.Ardakani@Sun.COM netdfs_finalize();
9110717Samw@Sun.COM ndr_rpc_fini();
9211963SAfshin.Ardakani@Sun.COM smb_quota_fini();
939832Samw@Sun.COM }
949832Samw@Sun.COM
955772Sas200622 /*ARGSUSED*/
965772Sas200622 static void *
mlsvc_timecheck(void * arg)9711963SAfshin.Ardakani@Sun.COM mlsvc_timecheck(void *arg)
985772Sas200622 {
9911963SAfshin.Ardakani@Sun.COM smb_domainex_t di;
1005772Sas200622
1015772Sas200622 for (;;) {
10211963SAfshin.Ardakani@Sun.COM (void) sleep(MLSVC_TIMECHECK_INTERVAL);
1035772Sas200622
10411963SAfshin.Ardakani@Sun.COM if (smb_config_get_secmode() == SMB_SECMODE_DOMAIN) {
10511963SAfshin.Ardakani@Sun.COM if (!smb_domain_getinfo(&di))
10611963SAfshin.Ardakani@Sun.COM continue;
10711963SAfshin.Ardakani@Sun.COM
10811963SAfshin.Ardakani@Sun.COM ndr_srvsvc_timecheck(di.d_dc, di.d_primary.di_nbname);
10911963SAfshin.Ardakani@Sun.COM }
1105772Sas200622 }
1115772Sas200622
1125772Sas200622 /*NOTREACHED*/
1135772Sas200622 return (NULL);
1145772Sas200622 }
115