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*5772Sas200622 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 235331Samw * Use is subject to license terms. 245331Samw */ 255331Samw 265331Samw #pragma ident "%Z%%M% %I% %E% SMI" 275331Samw 285331Samw #include <unistd.h> 29*5772Sas200622 #include <pthread.h> 305331Samw #include <smbsrv/libmlsvc.h> 315331Samw 325331Samw void dssetup_initialize(void); 335331Samw void srvsvc_initialize(void); 345331Samw void wkssvc_initialize(void); 355331Samw void lsarpc_initialize(void); 365331Samw void logr_initialize(void); 375331Samw void netr_initialize(void); 385331Samw void samr_initialize(void); 395331Samw void svcctl_initialize(void); 405331Samw void winreg_initialize(void); 41*5772Sas200622 int srvsvc_gettime(unsigned long *); 42*5772Sas200622 43*5772Sas200622 static void *mlsvc_keepalive(void *); 44*5772Sas200622 45*5772Sas200622 static pthread_t mlsvc_keepalive_thr; 46*5772Sas200622 #define MLSVC_KEEPALIVE_INTERVAL (10 * 60) /* 10 minutes */ 475331Samw 485331Samw /* 495331Samw * All mlrpc initialization is invoked from here. 505331Samw * Returns 0 upon success. Otherwise, returns -1. 515331Samw */ 525331Samw int 535331Samw mlsvc_init(void) 545331Samw { 55*5772Sas200622 pthread_attr_t tattr; 56*5772Sas200622 int rc; 57*5772Sas200622 585331Samw srvsvc_initialize(); 595331Samw wkssvc_initialize(); 605331Samw lsarpc_initialize(); 615331Samw netr_initialize(); 625331Samw dssetup_initialize(); 635331Samw samr_initialize(); 645331Samw svcctl_initialize(); 655331Samw winreg_initialize(); 665331Samw logr_initialize(); 675331Samw 68*5772Sas200622 (void) lsa_query_primary_domain_info(); 69*5772Sas200622 70*5772Sas200622 (void) pthread_attr_init(&tattr); 71*5772Sas200622 (void) pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); 72*5772Sas200622 rc = pthread_create(&mlsvc_keepalive_thr, &tattr, 73*5772Sas200622 mlsvc_keepalive, 0); 74*5772Sas200622 (void) pthread_attr_destroy(&tattr); 75*5772Sas200622 return (rc); 765331Samw } 77*5772Sas200622 78*5772Sas200622 /*ARGSUSED*/ 79*5772Sas200622 static void * 80*5772Sas200622 mlsvc_keepalive(void *arg) 81*5772Sas200622 { 82*5772Sas200622 unsigned long t; 83*5772Sas200622 nt_domain_t *domain; 84*5772Sas200622 85*5772Sas200622 for (;;) { 86*5772Sas200622 (void) sleep(MLSVC_KEEPALIVE_INTERVAL); 87*5772Sas200622 88*5772Sas200622 if (smb_config_get_secmode() == SMB_SECMODE_DOMAIN) { 89*5772Sas200622 domain = nt_domain_lookupbytype(NT_DOMAIN_PRIMARY); 90*5772Sas200622 if (domain == NULL) 91*5772Sas200622 (void) lsa_query_primary_domain_info(); 92*5772Sas200622 } 93*5772Sas200622 94*5772Sas200622 (void) srvsvc_gettime(&t); 95*5772Sas200622 } 96*5772Sas200622 97*5772Sas200622 /*NOTREACHED*/ 98*5772Sas200622 return (NULL); 99*5772Sas200622 } 100