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 5510504SKeyur.Desai@Sun.COM smb_proc_initsem(); 5610504SKeyur.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 63*10717Samw@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(); 755331Samw 765772Sas200622 (void) pthread_attr_init(&tattr); 775772Sas200622 (void) pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); 785772Sas200622 rc = pthread_create(&mlsvc_keepalive_thr, &tattr, 795772Sas200622 mlsvc_keepalive, 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*10717Samw@Sun.COM ndr_rpc_fini(); 919832Samw@Sun.COM } 929832Samw@Sun.COM 935772Sas200622 /*ARGSUSED*/ 945772Sas200622 static void * 955772Sas200622 mlsvc_keepalive(void *arg) 965772Sas200622 { 975772Sas200622 unsigned long t; 985772Sas200622 995772Sas200622 for (;;) { 1005772Sas200622 (void) sleep(MLSVC_KEEPALIVE_INTERVAL); 1015772Sas200622 1028334SJose.Borrego@Sun.COM if (smb_config_get_secmode() == SMB_SECMODE_DOMAIN) 1037348SJose.Borrego@Sun.COM (void) srvsvc_gettime(&t); 1045772Sas200622 } 1055772Sas200622 1065772Sas200622 /*NOTREACHED*/ 1075772Sas200622 return (NULL); 1085772Sas200622 } 109