1da6c28aaSamw /*
2da6c28aaSamw * CDDL HEADER START
3da6c28aaSamw *
4da6c28aaSamw * The contents of this file are subject to the terms of the
5da6c28aaSamw * Common Development and Distribution License (the "License").
6da6c28aaSamw * You may not use this file except in compliance with the License.
7da6c28aaSamw *
8da6c28aaSamw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da6c28aaSamw * or http://www.opensolaris.org/os/licensing.
10da6c28aaSamw * See the License for the specific language governing permissions
11da6c28aaSamw * and limitations under the License.
12da6c28aaSamw *
13da6c28aaSamw * When distributing Covered Code, include this CDDL HEADER in each
14da6c28aaSamw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da6c28aaSamw * If applicable, add the following below this CDDL HEADER, with the
16da6c28aaSamw * fields enclosed by brackets "[]" replaced with your own identifying
17da6c28aaSamw * information: Portions Copyright [yyyy] [name of copyright owner]
18da6c28aaSamw *
19da6c28aaSamw * CDDL HEADER END
20da6c28aaSamw */
21da6c28aaSamw /*
22cb174861Sjoyce mcintosh * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23*975041ddSGordon Ross * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
24da6c28aaSamw */
25da6c28aaSamw
268d96b23eSAlan Wright #include <sys/errno.h>
279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <sys/tzfile.h>
288d96b23eSAlan Wright #include <stdlib.h>
29da6c28aaSamw #include <unistd.h>
308d96b23eSAlan Wright #include <strings.h>
318d96b23eSAlan Wright #include <string.h>
328d96b23eSAlan Wright #include <rpc/xdr.h>
338d96b23eSAlan Wright #include <synch.h>
34dc20a302Sas #include <pthread.h>
358d96b23eSAlan Wright #include <smbsrv/libsmb.h>
36da6c28aaSamw #include <smbsrv/libmlsvc.h>
378d7e4166Sjose borrego #include <mlsvc.h>
38dc20a302Sas
399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static void *mlsvc_timecheck(void *);
40dc20a302Sas
419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define MLSVC_TIMECHECK_INTERVAL (10 * SECSPERMIN) /* 10 minutes */
42da6c28aaSamw
43da6c28aaSamw /*
448d7e4166Sjose borrego * All NDR RPC service initialization is invoked from here.
45da6c28aaSamw * Returns 0 upon success. Otherwise, returns -1.
46da6c28aaSamw */
47da6c28aaSamw int
mlsvc_init(void)48da6c28aaSamw mlsvc_init(void)
49da6c28aaSamw {
509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States pthread_t tid;
51dc20a302Sas pthread_attr_t tattr;
52dc20a302Sas int rc;
53dc20a302Sas
54e3f2c991SKeyur Desai smb_proc_initsem();
55e3f2c991SKeyur Desai
5629bd2886SAlan Wright if (smb_logon_init() != NT_STATUS_SUCCESS)
5729bd2886SAlan Wright return (-1);
5829bd2886SAlan Wright
598d7e4166Sjose borrego if ((rc = smb_dclocator_init()) != 0)
608d7e4166Sjose borrego return (rc);
618d7e4166Sjose borrego
629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_quota_init();
631ed6b69aSGordon Ross smbrdr_initialize();
64da6c28aaSamw srvsvc_initialize();
65da6c28aaSamw wkssvc_initialize();
66da6c28aaSamw lsarpc_initialize();
67da6c28aaSamw netr_initialize();
68da6c28aaSamw dssetup_initialize();
69da6c28aaSamw samr_initialize();
70da6c28aaSamw svcctl_initialize();
71da6c28aaSamw winreg_initialize();
72da6c28aaSamw logr_initialize();
738d7e4166Sjose borrego msgsvcsend_initialize();
748d7e4166Sjose borrego spoolss_initialize();
759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_initialize();
76da6c28aaSamw
77dc20a302Sas (void) pthread_attr_init(&tattr);
78dc20a302Sas (void) pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rc = pthread_create(&tid, &tattr, mlsvc_timecheck, 0);
80dc20a302Sas (void) pthread_attr_destroy(&tattr);
81dc20a302Sas return (rc);
82dc20a302Sas }
83dc20a302Sas
8429bd2886SAlan Wright void
mlsvc_fini(void)8529bd2886SAlan Wright mlsvc_fini(void)
8629bd2886SAlan Wright {
8729bd2886SAlan Wright smb_logon_fini();
88cb174861Sjoyce mcintosh spoolss_finalize();
891fcced4cSJordan Brown svcctl_finalize();
901fcced4cSJordan Brown logr_finalize();
919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_finalize();
929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_quota_fini();
9329bd2886SAlan Wright }
9429bd2886SAlan Wright
95dc20a302Sas /*ARGSUSED*/
96dc20a302Sas static void *
mlsvc_timecheck(void * arg)979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States mlsvc_timecheck(void *arg)
98dc20a302Sas {
999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_domainex_t di;
100dc20a302Sas
101dc20a302Sas for (;;) {
1029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) sleep(MLSVC_TIMECHECK_INTERVAL);
103dc20a302Sas
104380acbbeSGordon Ross if (smb_config_get_secmode() != SMB_SECMODE_DOMAIN)
105380acbbeSGordon Ross continue;
1069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States
107380acbbeSGordon Ross if (!smb_domain_getinfo(&di))
108380acbbeSGordon Ross continue;
109380acbbeSGordon Ross
1103299f39fSGordon Ross srvsvc_timecheck(di.d_dci.dc_name,
111b3700b07SGordon Ross di.d_primary.di_nbname);
112dc20a302Sas }
113dc20a302Sas
114dc20a302Sas /*NOTREACHED*/
115dc20a302Sas return (NULL);
116da6c28aaSamw }
117