gethostent6.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"
#include <netdb.h>
#include <syslog.h>
#include <sys/systeminfo.h>
#include "ns_internal.h"
#include "ldap_common.h"
/* host attributes filters */
/* probably some change in the ipHostNumber field */
#define _H_DN "dn"
#define _H_NAME "cn"
#define _H_ADDR "iphostnumber"
#define _F_GETHOSTS6BYNAME "(&(objectClass=ipHost)(cn=%s))"
#define _F_GETHOSTS6BYNAME_SSD "(&(%%s)(cn=%s))"
#define _F_GETHOSTS6DOTTEDBYNAME \
"(&(objectClass=ipHost)(|(cn=%s)(cn=%s)))"
#define _F_GETHOSTS6DOTTEDBYNAME_SSD \
"(&(%%s)(|(cn=%s)(cn=%s)))"
#define _F_GETHOSTS6BYADDR "(&(objectClass=ipHost)(ipHostNumber=%s))"
#define _F_GETHOSTS6BYADDR_SSD "(&(%%s)(ipHostNumber=%s))"
static const char *ipnodes_attrs[] = {
(char *)NULL
};
extern int inet_pton(int, const char *, void *);
/*
* _nss_ldap_hosts2ent is the data marshaling method for the ipnodes getXbyY
* system call gethostbyname() and gethostbyaddr. The format of this call
* is a cononical name and alias (alias is cononical name too) and one or
* more IP addresses in support of multihomed hosts. This method is called
* after a successful synchronous search has been performed. This method
* will parse the search results into struct hostent = argp->buf.buffer
* which gets returned to the frontend process. One of three error
* conditions is also returned to nsswitch.
*/
static int
{
int i, j;
int nss_result;
int buflen = (int)0;
int firstimename = (int)1;
int firstimedn = (int)1;
int firstimeaddr = (int)1;
unsigned long len = 0L;
char *val;
int namecount = 0;
int addrcount = 0;
int aliascount = 0;
int gluelen = 0;
nss_result = (int)NSS_STR_PARSE_ERANGE;
goto result_hosts2ent;
}
nss_result = (int)NSS_STR_PARSE_SUCCESS;
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_hosts2ent;
}
i < entry->attr_count; i++) {
}
}
for (i = 0; i < entry->attr_count; i++) {
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_hosts2ent;
}
for (j = 0; j < attrptr->value_count; j++) {
if (firstimedn) {
/* get domain name associated with this dn */
firstimedn = (int)0;
}
}
}
for (j = 0; j < attrptr->value_count; j++) {
if (firstimename) {
/* canonical name */
attrptr, 1);
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_hosts2ent;
}
else
gluelen = 0;
nss_result = (int)NSS_STR_PARSE_ERANGE;
goto result_hosts2ent;
}
if (gluelen > 0) {
}
/* alias name */
sizeof (char *) * (aliascount + 1);
nss_result = (int)NSS_STR_PARSE_ERANGE;
goto result_hosts2ent;
}
firstimename = (int)0;
}
/* alias list */
if (aliascount > 0) {
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_hosts2ent;
}
/* skip canonical name */
continue;
/* check for duplicates */
goto next_alias;
}
else
gluelen = 0;
nss_result = (int)NSS_STR_PARSE_ERANGE;
goto result_hosts2ent;
}
if (gluelen > 0) {
}
hn++;
}
continue;
}
}
}
}
for (i = 0; i < entry->attr_count; i++) {
nss_result = (int)NSS_STR_PARSE_PARSE;
goto result_hosts2ent;
}
for (j = 0; j < attrptr->value_count; j++) {
if (firstimeaddr) {
/* allocate 1 address per entry */
sizeof (char **));
sizeof (char *) * (addrcount + 1);
nss_result = (int)NSS_STR_PARSE_ERANGE;
goto result_hosts2ent;
}
firstimeaddr = (int)0;
}
goto next_addr;
} else {
}
}
/* check for duplicates */
== 0)
goto next_addr;
}
nss_result = (int)NSS_STR_PARSE_ERANGE;
goto result_hosts2ent;
}
continue;
}
}
}
}
#ifdef DEBUG
}
}
#endif /* DEBUG */
return ((int)nss_result);
}
/*
* getbyname gets a struct hostent by hostname. This function constructs
* an ldap search filter using the name invocation parameter and the
* gethostbyname search filter defined. Once the filter is constructed,
* we search for a matching entry and marshal the data results into
* struct hostent for the frontend process. Host name searches will be
* on fully qualified host names (foo.bar.sun.com)
*/
static nss_status_t
{
char realdomain[BUFSIZ];
char searchfilter[SEARCHFILTERLEN];
char userdata[SEARCHFILTERLEN];
int rc;
#ifdef DEBUG
#endif /* DEBUG */
sizeof (hostname)) != 0)
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
/* get the domain we are in */
if (rc <= 0)
return ((nss_status_t)NSS_NOTFOUND);
/* Is this a request for a host.domain */
if (DOTTEDSUBDOMAIN(hostname)) {
char host[MAXHOSTNAMELEN];
char domain[MAXHOSTNAMELEN];
/* separate host and domain. this function */
/* will munge hname, so use argp->keyname */
/* from here on for original string */
return ((nss_status_t)NSS_NOTFOUND);
}
/* if domain is a proper subset of realdomain */
/* ie. domain = "foo" and realdomain */
/* = "foor.bar.sun.com", we try to lookup both" */
/* host.domain and host */
/* yes, it is a proper domain */
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
} else {
/* it is not a proper domain, so only try to look up */
/* host.domain */
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
}
} else {
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
}
return ((nss_status_t)NSS_SUCCESS);
return ((nss_status_t)lstat);
}
/*
* getbyaddr gets a struct hostent by host address. This function
* constructs an ldap search filter using the host address invocation
* parameter and the gethostbyaddr search filter defined. Once the
* filter is constructed, we search for a matching entry and marshal
* the data results into struct hostent for the frontend process.
*/
static nss_status_t
{
char searchfilter[SEARCHFILTERLEN];
char userdata[SEARCHFILTERLEN];
int ret;
#ifdef DEBUG
#endif /* DEBUG */
return (NSS_NOTFOUND);
if (IN6_IS_ADDR_V4MAPPED(&addr)) {
return (NSS_NOTFOUND);
}
} else {
INET6_ADDRSTRLEN) == NULL)
return (NSS_NOTFOUND);
}
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_SUCCESS);
return ((nss_status_t)lstat);
}
static ldap_backend_op_t ipnodes_ops[] = {
0,
0,
0,
};
/*
* _nss_ldap_hosts_constr is where life begins. This function calls the generic
* ldap constructor function to define and build the abstract data types
* required to support ldap operations.
*/
/*ARGSUSED0*/
const char *dummy3)
{
#ifdef DEBUG
#endif /* DEBUG */
}