/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
*/
#include <netdb.h>
#include <syslog.h>
#include <sys/systeminfo.h>
#include <nss.h>
#include "ns_internal.h"
#include "ldap_common.h"
/* host attributes filters */
static const char *hosts_attrs[] = {
(char *)NULL
};
/*
* _nss_ldap_hosts2str is the data marshaling method for the hosts getXbyY
* system call gethostbyname() and gethostbyaddr.
* This method is called after a successful search has been performed.
* This method will parse the search results into the file format.
* e.g.
*
* 9.9.9.9 jurassic jurassic1 jurassic2
* 10.10.10.10 puppy
*
*/
int
{
uint_t i;
int nss_result;
char *name;
return (NSS_STR_PARSE_PARSE);
goto result_host2str;
}
} else
goto result_host2str;
}
goto result_host2str;
}
/*
* Multiple lines return will be sepereated by newlines
* Single line return or last line does not have newline
* e.g.
*
* 8.8.8.8 hostname
*
* or the search for hostname h1 returns 3 entries
*
* 9.9.9.9 h1
* 10.10.10.10 h1 xx
* 20.20.20.20 h1 yyy
*
* so the string is organized as
*
* "9.9.9.9 h1 xx yy\n10.10.10.10 \n20.20.20.20 "
*
* Use first_host to hold "9.9.9.9 h1 xx yy" and other_hosts to hold
* "\n10.10.10.10 \n20.20.20.20 "
*
*/
buf1 = first_host;
buf2 = other_hosts;
first_entry = 1;
if (firstimedn) {
< 1) {
goto result_host2str;
}
/* get domain name associated with this dn */
firstimedn = 0;
}
/* Get IP */
goto result_host2str;
}
/* Skip IPV6 address in AF_INET mode */
continue;
/* A valid address for either af mode */
validaddress++;
if (first_entry) {
} else {
}
/* Get host names */
goto result_host2str;
}
/* Get canonical name of each entry */
goto result_host2str;
}
/* Filter cname that's identical to h_name */
if (first_entry) {
first_entry = 0;
copy_cname = 1;
copy_cname = 1;
} else
copy_cname = 0;
if (copy_cname) {
/* Use the canonical name as the host name */
else
/* append domain name */
}
/* Append aliases */
for (i = 0; i < names->value_count; i++) {
goto result_host2str;
}
/* Skip the canonical name and h_name */
name);
else
/* append domain name */
}
}
}
if (validaddress == 0) {
/*
* For AF_INET mode, it found an IPv6 address and skipped it.
*/
goto result_host2str;
}
/* Combine 2 strings */
/* The front end marshaller doesn't need to copy trailing nulls */
if (first_host)
if (other_hosts)
}
return (nss_result);
}
static int
}
/*
* 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
{
int rc;
return ((nss_status_t)NSS_NOTFOUND);
hostname);
return ((nss_status_t)NSS_NOTFOUND);
hostname);
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)) {
/* 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 = "eng" and realdomain */
/* = "eng.wiz.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.
*
* extern char *inet_ntoa_r() not an advertised function from libnsl.
* There is no man page and no prototype.
*/
static nss_status_t
{
extern char *inet_ntoa_r();
int ret;
return (NSS_NOTFOUND);
buf);
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_SUCCESS);
return ((nss_status_t)lstat);
}
};
/*
* _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)
{
}