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 267588Samw@Sun.COM #include <sys/errno.h> 27*11963SAfshin.Ardakani@Sun.COM #include <sys/tzfile.h> 287588Samw@Sun.COM #include <stdlib.h> 295331Samw #include <unistd.h> 307588Samw@Sun.COM #include <strings.h> 317588Samw@Sun.COM #include <string.h> 327588Samw@Sun.COM #include <rpc/xdr.h> 337588Samw@Sun.COM #include <synch.h> 345772Sas200622 #include <pthread.h> 357588Samw@Sun.COM #include <smbsrv/libsmb.h> 365331Samw #include <smbsrv/libmlsvc.h> 378334SJose.Borrego@Sun.COM #include <mlsvc.h> 385772Sas200622 39*11963SAfshin.Ardakani@Sun.COM static void *mlsvc_timecheck(void *); 405772Sas200622 41*11963SAfshin.Ardakani@Sun.COM #define MLSVC_TIMECHECK_INTERVAL (10 * SECSPERMIN) /* 10 minutes */ 425331Samw 435331Samw /* 448334SJose.Borrego@Sun.COM * All NDR RPC service initialization is invoked from here. 455331Samw * Returns 0 upon success. Otherwise, returns -1. 465331Samw */ 475331Samw int 485331Samw mlsvc_init(void) 495331Samw { 50*11963SAfshin.Ardakani@Sun.COM pthread_t tid; 515772Sas200622 pthread_attr_t tattr; 525772Sas200622 int rc; 535772Sas200622 5410504SKeyur.Desai@Sun.COM smb_proc_initsem(); 5510504SKeyur.Desai@Sun.COM 569832Samw@Sun.COM if (smb_logon_init() != NT_STATUS_SUCCESS) 579832Samw@Sun.COM return (-1); 589832Samw@Sun.COM 598334SJose.Borrego@Sun.COM if ((rc = smb_dclocator_init()) != 0) 608334SJose.Borrego@Sun.COM return (rc); 618334SJose.Borrego@Sun.COM 62*11963SAfshin.Ardakani@Sun.COM smb_quota_init(); 6310717Samw@Sun.COM ndr_rpc_init(); 645331Samw srvsvc_initialize(); 655331Samw wkssvc_initialize(); 665331Samw lsarpc_initialize(); 675331Samw netr_initialize(); 685331Samw dssetup_initialize(); 695331Samw samr_initialize(); 705331Samw svcctl_initialize(); 715331Samw winreg_initialize(); 725331Samw logr_initialize(); 738334SJose.Borrego@Sun.COM msgsvcsend_initialize(); 748334SJose.Borrego@Sun.COM spoolss_initialize(); 75*11963SAfshin.Ardakani@Sun.COM netdfs_initialize(); 765331Samw 775772Sas200622 (void) pthread_attr_init(&tattr); 785772Sas200622 (void) pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); 79*11963SAfshin.Ardakani@Sun.COM rc = pthread_create(&tid, &tattr, mlsvc_timecheck, 0); 805772Sas200622 (void) pthread_attr_destroy(&tattr); 815772Sas200622 return (rc); 825331Samw } 835772Sas200622 849832Samw@Sun.COM void 859832Samw@Sun.COM mlsvc_fini(void) 869832Samw@Sun.COM { 879832Samw@Sun.COM smb_logon_fini(); 8810122SJordan.Brown@Sun.COM svcctl_finalize(); 8910122SJordan.Brown@Sun.COM logr_finalize(); 90*11963SAfshin.Ardakani@Sun.COM netdfs_finalize(); 9110717Samw@Sun.COM ndr_rpc_fini(); 92*11963SAfshin.Ardakani@Sun.COM smb_quota_fini(); 939832Samw@Sun.COM } 949832Samw@Sun.COM 955772Sas200622 /*ARGSUSED*/ 965772Sas200622 static void * 97*11963SAfshin.Ardakani@Sun.COM mlsvc_timecheck(void *arg) 985772Sas200622 { 99*11963SAfshin.Ardakani@Sun.COM smb_domainex_t di; 1005772Sas200622 1015772Sas200622 for (;;) { 102*11963SAfshin.Ardakani@Sun.COM (void) sleep(MLSVC_TIMECHECK_INTERVAL); 1035772Sas200622 104*11963SAfshin.Ardakani@Sun.COM if (smb_config_get_secmode() == SMB_SECMODE_DOMAIN) { 105*11963SAfshin.Ardakani@Sun.COM if (!smb_domain_getinfo(&di)) 106*11963SAfshin.Ardakani@Sun.COM continue; 107*11963SAfshin.Ardakani@Sun.COM 108*11963SAfshin.Ardakani@Sun.COM ndr_srvsvc_timecheck(di.d_dc, di.d_primary.di_nbname); 109*11963SAfshin.Ardakani@Sun.COM } 1105772Sas200622 } 1115772Sas200622 1125772Sas200622 /*NOTREACHED*/ 1135772Sas200622 return (NULL); 1145772Sas200622 } 115