gethost.c 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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Routines to handle gethost* calls in nscd
*/
#include <assert.h>
#include <errno.h>
#include <memory.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <thread.h>
#include <unistd.h>
#include <ucred.h>
#include <nss_common.h>
#include "getxby_door.h"
#include "server_door.h"
#include "nscd.h"
static void gethost_invalidate_unlocked(void);
static int addr_to_int(char *addr);
static int int_to_addr(int h);
int callnumber);
static int
addr_to_int(char *addr)
{
union {
char data[4];
int hashval;
} u;
/*
* following code is byte order dependant, but since all we use this for
* is hashing this works out just fine.
*/
return (u.hashval);
}
static int
int_to_addr(int h)
{
union {
char data[4];
int hashval;
} u;
/*
* following code is byte order dependant, but since all we use this for
* is hashing this works out just fine.
*/
u.hashval = h;
return (* ((int *)u.data));
}
void
gethost_init(void)
{
}
static void
{
/* leave pending calls alone */
}
}
static void
{
/*
* be careful with ptr - it may be -1 or NULL.
*/
/* leave pending calls alone */
if (tmp != (char *)-1)
}
}
static void
{
/* leave pending calls alone */
}
}
void
gethost_revalidate(void)
{
for (;;) {
int slp;
int interval;
int count;
if (slp < 60)
slp = 60;
if (count != 0) {
} else {
}
}
}
static void
{
int *table;
union {
} u;
int i;
if (!keep)
return;
for (i = 1; i <= keep; i++) {
char *tmp;
continue; /* unused slot in table */
}
for (i = 1; i <= keep; i++) {
char *tmp;
}
}
static void
{
int *table;
union {
} u;
int i;
if (!keep)
return;
for (i = 1; i <= keep; i++) {
int tmp;
continue; /* unused slot in table */
}
}
/*
* This routine marks all entries as invalid
*
*/
void
gethost_invalidate(void)
{
}
static void
{
}
void
{
int out_of_date;
char **bucket;
return;
}
/*EMPTY*/;
} else if (lastmod == 0) {
}
}
logit("gethost_lookup: looking for address %s\n",
} else {
logit("gethost_lookup: looking for hostname %s\n",
}
}
for (;;) {
} else { /* bounce excessively long requests */
if (door_ucred(&uc) != 0) {
logit("gethost_lookup: Name too long, "
"but no user credential: %s\n",
} else {
logit("gethost_lookup: Name too long "
"from pid %d uid %d\n",
ucred_getruid(uc));
ucred_free(uc);
}
goto getout;
}
}
/* no threads available */
/* cannot process now */
goto getout;
}
continue; /* go back and relookup hash bucket */
}
break;
}
/*
* check for no name_service mode
*/
/* time has expired */
int saved_errno;
int saved_hits = 0;
struct hostent *p;
/* no threads available */
/* cannot process now */
goto getout;
}
}
/*
* block any threads accessing this bucket if data is
* non-existent or out of date
*/
(nsc_bucket_t *)-1,
in->nsc_callnumber);
} else {
/*
* if still not -1 bucket we are doing update... mark
* to prevent pileups of threads if the name service
* is hanging....
*/
/* cleared by deletion of old data */
}
&saved_errno);
} else {
&saved_errno);
}
if (p == NULL) { /* data not found */
logit("gethost_lookup: nscd COULDN'T FIND address %s\n",
} else {
logit("gethost_lookup: nscd COULDN'T FIND host name %s\n",
}
}
sizeof (nsc_return_t);
in->nsc_callnumber);
goto getout;
} else {
logit("gethost_lookup: nscd FOUND addr %s\n",
} else {
logit("gethost_lookup: nscd FOUND host name %s\n",
}
}
in->nsc_callnumber);
if (saved_hits)
}
} else { /* found entry in cache */
logit("gethost_lookup: found address %s in cache\n",
} else {
logit("gethost_lookup: found host name %s in cache\n",
}
}
} else {
logit("gethost_lookup: %s marked as NOT FOUND in cache.\n",
} else {
logit("gethost_lookup: %s marked as NOT FOUND in cache.\n",
}
}
}
/* cleared by deletion of old data */
}
}
}
/*ARGSUSED*/
static void
{
/* old data exists */
}
/*
* we can do this before reseting *old since we're holding the lock
*/
}
/* real data, not just update pending or invalidate */
new->nsc_status = 0;
} else {
}
}
}
/*ARGSUSED*/
static nsc_bucket_t *
{
char *dest;
char **aliaseslist;
char **addrlist;
int offset;
int strs;
int i;
int numaliases;
int numaddrs;
/*
* find out the size of the data block we're going to need
*/
/*
* allocate it and copy it in
* code doesn't assume packing order in original buffer
*/
return (NULL);
}
/*
* allocat the h_aliases list and the h_addr_list first to align 'em.
*/
aliaseslist = (char **)dest;
/*
* fill out the h_aliases list
*/
for (i = 0; i < numaliases; i++) {
}
aliaseslist[i] = 0; /* null term ptr chain */
/*
* fill out the h_addr list
*/
for (i = 0; i < numaddrs; i++) {
}
addrlist[i] = 0; /* null term ptr chain */
return (retb);
}
void
{
}
void
{
}