mgr_cache.cc revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "mgr_cache.h"
#include <string.h>
#include <syslog.h>
#include <errno.h>
#include <ctype.h>
#include <unistd.h>
#include "nis_cache.h"
{
}
{
markDown();
}
void
NisMgrCache::start()
{
(void) loadPreferredServers();
(void) readColdStart();
}
{
/* figure out how long until the next timer goes off */
if (config_time < next_time)
if (next_time == 0)
return (MIN_REFRESH_WAIT);
if (ret_value == 0)
return (ret_value);
}
{
int rt;
refresh();
if (rt < MIN_REFRESH_WAIT)
else
}
ping();
}
config_time = config();
}
return (nextTime());
}
/*
* Reload the server information.
*/
{
if (config_time = loadLocalFile()) {
ll = writeDotFile();
ping();
return (ll);
}
if (config_time = loadNisTable()) {
ll = writeDotFile();
ping();
return (ll);
}
/*
* Failed to load preferred info from both the local file and
* NIS+ table. Keep the current list for now.
*/
"Failed to load the new preferred server info. Reusing current list.");
return (0);
}
{
config_time = config();
return (nextTime());
}
/*
* Reload all stale entries. We only remove a cache entry if we
* get a definitive answer that says the directory no longer
* exists. We keep the cache entry if we get other errors on the
* assumption that out-of-date information is better than no
* information at all.
*
* It might make more sense to only do one of them if the cache manager
* is single-threaded.
*/
void
{
int i;
int n;
n = getStaleEntries(&bindings);
for (i = 0; i < n; i++) {
refreshBinding(bindings[i]);
nis_free_binding(bindings[i]);
}
}
void
NisMgrCache::ping()
{
int i;
int n;
int nsrv;
n = getAllEntries(&bindings);
for (i = 0; i < n; i++) {
nis_free_binding(bindings[i]);
}
}
{
__NSL_FILE *fp;
char buf[64];
return (0);
(void) __nsl_fclose(fp);
return (0);
}
return (config_time);
}
void
{
char *p, *buf;
int l;
return;
while (*info) {
info++;
if (*info == '\0')
break;
p = info;
info++;
/* preferred server info */
continue;
p++;
l = info - p;
break;
}
buf[l] = '\0';
/* preferred type info */
continue;
p++;
l = info - p;
break;
}
buf[l] = '\0';
}
}
}
char *
{
char *p;
char buf[1024];
cont = 0;
cont = 1;
}
return (NULL);
}
} else {
return (NULL);
}
while (*p && isspace(*p))
p++;
}
if (!cont)
break; /* complete line */
}
return (value);
}
{
char hosts[256];
int hostfound = 0;
int n = 0, i;
struct in_addr in4addr_loopback;
/* For IPv4, we want the loopback net, not the loopback address */
return (0);
errno);
return (0);
}
p = value;
while (*p && !isspace(*p))
p++;
if (*p == '\0') {
continue;
}
*p++ = '\0';
while (*p && isspace(*p))
p++;
info = p;
/*
* If hostfound not already set, set hostfound and
* reset the preferred server info to remove all
* subnet specific entries.
* This will skip the search by subnet.
*/
if (!hostfound) {
hostfound = 1;
}
} else if (hostfound) {
/* don't check subnet entries */
continue;
} else {
/* Assume subnet entry; check if it is a local subnet */
void *addr;
} else {
/* Don't know what kind of address this is */
continue;
}
continue;
}
continue;
}
continue;
}
}
}
if (local) {
}
return (expireTime(config_interval));
}
{
int i;
int n;
int old_format;
void *local;
char name[NIS_MAXNAMELEN];
return (0);
}
/* table does not exist */
return (expireTime(config_interval));
}
else
old_format = 0;
/*
* lookup in the client_info table based on the
* the host name first.
*/
errno);
return (0);
}
if (old_format)
host, nis_local_directory());
else /* new format */
"[client=%s,attr=%s],client_info.org_dir.%s",
return (0);
}
if (old_format)
else { /* new format */
}
if (old_format) {
if (p_srvr)
if (p_type)
}
return (expireTime(ttl));
} else
/*
* no host specific entries found. Now try looking up subnet
* entries.
*/
return (0);
n = __inet_address_count(local);
for (i = 0; i < n; i++) {
continue;
}
if (old_format)
"[client=%s],client_info.org_dir.%s",
else /* new format */
"[client=%s,attr=%s],client_info.org_dir.%s",
return (0);
continue;
}
if (old_format)
else { /* new format */
}
if (old_format) {
if (p_srvr)
if (p_type)
}
}
return (expireTime(ttl));
}
{
extern char *__nis_prefsrv;
/*
* read from the "dot" file first. If successful, no need to
* look at the local client_info file and table.
*/
if (config_time = loadDotFile())
return (config_time);
/*
* read from the local client_info file. If file is found and
* not empty, no need to look at the client_info table.
*/
if (config_time = loadLocalFile()) {
(void) writeDotFile();
return (config_time);
}
/*
* read from the NIS+ table.
*/
if (config_time = loadNisTable()) {
(void) writeDotFile();
return (config_time);
}
return (0);
}