mlsvc_init.c revision c8ec8eea9849cac239663c46be8a7f5d2ba7ca00
2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#pragma ident "@(#)mlsvc_init.c 1.5 08/07/22 SMI"
2N/A
2N/A#include <unistd.h>
2N/A#include <pthread.h>
2N/A#include <smbsrv/libmlsvc.h>
2N/A
2N/Avoid dssetup_initialize(void);
2N/Avoid srvsvc_initialize(void);
2N/Avoid wkssvc_initialize(void);
2N/Avoid lsarpc_initialize(void);
2N/Avoid logr_initialize(void);
2N/Avoid netr_initialize(void);
2N/Avoid samr_initialize(void);
2N/Avoid svcctl_initialize(void);
2N/Avoid winreg_initialize(void);
2N/Aint srvsvc_gettime(unsigned long *);
2N/A
2N/Astatic void *mlsvc_keepalive(void *);
2N/A
2N/Astatic pthread_t mlsvc_keepalive_thr;
2N/A#define MLSVC_KEEPALIVE_INTERVAL (10 * 60) /* 10 minutes */
2N/A
2N/A/*
2N/A * All mlrpc initialization is invoked from here.
2N/A * Returns 0 upon success. Otherwise, returns -1.
2N/A */
2N/Aint
2N/Amlsvc_init(void)
2N/A{
2N/A pthread_attr_t tattr;
2N/A int rc;
2N/A
2N/A srvsvc_initialize();
2N/A wkssvc_initialize();
2N/A lsarpc_initialize();
2N/A netr_initialize();
2N/A dssetup_initialize();
2N/A samr_initialize();
2N/A svcctl_initialize();
2N/A winreg_initialize();
2N/A logr_initialize();
2N/A
2N/A (void) pthread_attr_init(&tattr);
2N/A (void) pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
2N/A rc = pthread_create(&mlsvc_keepalive_thr, &tattr,
mlsvc_keepalive, 0);
(void) pthread_attr_destroy(&tattr);
return (rc);
}
/*ARGSUSED*/
static void *
mlsvc_keepalive(void *arg)
{
unsigned long t;
nt_domain_t *domain;
for (;;) {
(void) sleep(MLSVC_KEEPALIVE_INTERVAL);
if (smb_config_get_secmode() == SMB_SECMODE_DOMAIN) {
domain = nt_domain_lookupbytype(NT_DOMAIN_PRIMARY);
if (domain == NULL)
(void) lsa_query_primary_domain_info();
(void) srvsvc_gettime(&t);
}
}
/*NOTREACHED*/
return (NULL);
}