da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * or http://www.opensolaris.org/os/licensing.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
8d96b23e24cf8db8618f698bfa580a25d7dc6029Alan Wright#include <sys/errno.h>
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States#include <sys/tzfile.h>
8d96b23e24cf8db8618f698bfa580a25d7dc6029Alan Wright#include <stdlib.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <unistd.h>
8d96b23e24cf8db8618f698bfa580a25d7dc6029Alan Wright#include <strings.h>
8d96b23e24cf8db8618f698bfa580a25d7dc6029Alan Wright#include <string.h>
8d96b23e24cf8db8618f698bfa580a25d7dc6029Alan Wright#include <rpc/xdr.h>
8d96b23e24cf8db8618f698bfa580a25d7dc6029Alan Wright#include <synch.h>
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as#include <pthread.h>
8d96b23e24cf8db8618f698bfa580a25d7dc6029Alan Wright#include <smbsrv/libsmb.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <smbsrv/libmlsvc.h>
8d7e41661dc4633488e93b13363137523ce59977jose borrego#include <mlsvc.h>
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United Statesstatic void *mlsvc_timecheck(void *);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States#define MLSVC_TIMECHECK_INTERVAL (10 * SECSPERMIN) /* 10 minutes */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
8d7e41661dc4633488e93b13363137523ce59977jose borrego * All NDR RPC service initialization is invoked from here.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Returns 0 upon success. Otherwise, returns -1.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwmlsvc_init(void)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States pthread_t tid;
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as pthread_attr_t tattr;
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as int rc;
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai smb_proc_initsem();
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright if (smb_logon_init() != NT_STATUS_SUCCESS)
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright return (-1);
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright
8d7e41661dc4633488e93b13363137523ce59977jose borrego if ((rc = smb_dclocator_init()) != 0)
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (rc);
8d7e41661dc4633488e93b13363137523ce59977jose borrego
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_quota_init();
1ed6b69a5ca1ca3ee5e9a4931f74e2237c7e1c9fGordon Ross smbrdr_initialize();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw srvsvc_initialize();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw wkssvc_initialize();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw lsarpc_initialize();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw netr_initialize();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw dssetup_initialize();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw samr_initialize();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw svcctl_initialize();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw winreg_initialize();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw logr_initialize();
8d7e41661dc4633488e93b13363137523ce59977jose borrego msgsvcsend_initialize();
8d7e41661dc4633488e93b13363137523ce59977jose borrego spoolss_initialize();
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States netdfs_initialize();
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as (void) pthread_attr_init(&tattr);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as (void) pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States rc = pthread_create(&tid, &tattr, mlsvc_timecheck, 0);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as (void) pthread_attr_destroy(&tattr);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as return (rc);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as}
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wrightvoid
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wrightmlsvc_fini(void)
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright{
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright smb_logon_fini();
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh spoolss_finalize();
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown svcctl_finalize();
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown logr_finalize();
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States netdfs_finalize();
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_quota_fini();
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright}
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as/*ARGSUSED*/
dc20a3024900c47dd2ee44b9707e6df38f7d62a5asstatic void *
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United Statesmlsvc_timecheck(void *arg)
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as{
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_domainex_t di;
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as for (;;) {
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States (void) sleep(MLSVC_TIMECHECK_INTERVAL);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as
380acbbe9da7dc2cbab5b6db169ec6968dd927faGordon Ross if (smb_config_get_secmode() != SMB_SECMODE_DOMAIN)
380acbbe9da7dc2cbab5b6db169ec6968dd927faGordon Ross continue;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
380acbbe9da7dc2cbab5b6db169ec6968dd927faGordon Ross /* Avoid interfering with DC discovery. */
380acbbe9da7dc2cbab5b6db169ec6968dd927faGordon Ross if (smb_ddiscover_wait() != 0)
380acbbe9da7dc2cbab5b6db169ec6968dd927faGordon Ross continue;
380acbbe9da7dc2cbab5b6db169ec6968dd927faGordon Ross
380acbbe9da7dc2cbab5b6db169ec6968dd927faGordon Ross if (!smb_domain_getinfo(&di))
380acbbe9da7dc2cbab5b6db169ec6968dd927faGordon Ross continue;
380acbbe9da7dc2cbab5b6db169ec6968dd927faGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross ndr_srvsvc_timecheck(di.d_dci.dc_name,
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross di.d_primary.di_nbname);
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as }
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as /*NOTREACHED*/
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as return (NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}