/*
* 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
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <ctype.h>
#include <netdb.h>
#include "ns_internal.h"
#include "ldap_common.h"
/* services attributes filters */
#define _F_GETSERVBYNAMEPROTO \
"(&(objectClass=ipService)(cn=%s)(ipServiceProtocol=%s))"
#define _F_GETSERVBYNAMEPROTO_SSD \
"(&(%%s)(cn=%s)(ipServiceProtocol=%s))"
#define _F_GETSERVBYPORTPROTO \
"(&(objectClass=ipService)(ipServicePort=%ld)(ipServiceProtocol=%s))"
#define _F_GETSERVBYPORTPROTO_SSD \
"(&(%%s)(ipServicePort=%ld)(ipServiceProtocol=%s))"
typedef struct _nss_services_cookie {
static const char *services_attrs[] = {
(char *)NULL
};
void
}
}
static _nss_services_cookie_t *
return (NULL);
/*
* result has been allocated either by __ns_ldap_firstEntry
* or __ns_ldap_nextEntry.
*/
return (cookie);
}
/*
* _nss_ldap_services2str is the data marshaling method for the services
* getXbyY * (e.g., getbyname(), getbyport(), getent()) backend processes.
* This method is called after a successful ldap search has been performed.
* This method will parse the ldap search values into the file format.
* e.g.
*
* nfsd 2049/udp nfs
* nfsd 2049/tcp nfs
*
* In section 5.5 of RFC 2307, it specifies that a "services" LDAP entry
* containing multiple ipserviceprotocol values should be able to be mapped
* to multiple "services" entities. Code has been added to support
* this one to many mapping feature.
*/
static int
{
uint_t i, k;
int nss_result;
if (cookie) {
/*
* getservent_r with multiple protocol values and the entry
* is enumerated 2nd time or beyond
*/
} else {
/*
* getservbyname_r, getservbyport_r or
* getservent_r with single protocol value or multiple values
* and the entry is enumerated 1st time
*/
}
goto result_srvs2str;
}
goto result_srvs2str;
}
} else
/* Get services names */
goto result_srvs2str;
}
/* Get canonical services name */
goto result_srvs2str;
}
}
/* Get port */
goto result_srvs2str;
}
/* Set services name and port and '/' */
/* Get protocol */
goto result_srvs2str;
}
if (cookie) {
/*
* getservent_r
* Get current value then increment index
*/
/*
* getserverbyname_r and getservbyport_r
*
* If there are more than one value and
* it needs to match protocol too,
* iterate each value to find matching one.
*/
for (k = 0; k < protocol->value_count; k++) {
goto result_srvs2str;
}
break;
}
}
} else {
/*
* 1. getserverbyname_r and getservbyport_r
*
* It does not need to match protocol or
* ipserviceprotocol has single value,
* return the first one.
*
* 2. getservent_r with single ipserviceprotocol value
* or multiple values and the entry is
* enumerated 1st time, return the first one.
*
*/
}
goto result_srvs2str;
}
/* Set protocol */
/* Append aliases */
for (i = 0; i < names->value_count; i++) {
goto result_srvs2str;
}
/* Skip the canonical name */
}
}
/*
* getservent_r with multiple ipserviceprotocol values
* and the entry is enumerated 1st time
*
* Create cookie and save result in the cookie
* "attrvalue[0]" of ipserviceprotocol is returned,
* so it starts with index 1. Also save the canonical name.
*/
goto result_srvs2str;
}
/* reset be->result so it won't get freed later */
}
/* The front end marshaller doesn't need to copy trailing nulls */
if (cookie) {
/*
* getservent_r with multiple ipserviceprotocol values and
* the entry is enumerated 2nd time or beyond
*/
if (nss_result != NSS_STR_PARSE_SUCCESS ||
/*
* If it's an error case or it has iterated all
* ipservicesprotocol value(s) then free cookie and
* set it to NULL
*
*/
(void **)&be->services_cookie);
}
} else {
/*
* getservbyname_r, getservbyport_r, or
* getservent_r with single value or can't create cookie
*/
}
return (nss_result);
}
/*
* getbyname gets struct servent values by service name. This
* function constructs an ldap search filter using the service
* name invocation parameter and the getservbyname search filter
* defined. Once the filter is constructed, we search for a matching
* entry and marshal the data results into *serv = (struct servent *)
* argp->buf.result. The function _nss_ldap_services2ent performs
* the data marshaling.
*/
static nss_status_t
{
int ret;
!= 0)
return ((nss_status_t)NSS_NOTFOUND);
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_NOTFOUND);
}
}
/*
* getbyport gets struct servent values by service port. This
* function constructs an ldap search filter using the service
* name invocation parameter and the getservbyport search filter
* defined. Once the filter is constructed, we search for a matching
* entry and marshal the data results into *serv = (struct servent *)
* argp->buf.result. The function _nss_ldap_services2ent performs
* the data marshaling.
*/
static nss_status_t
{
int ret;
return ((nss_status_t)NSS_NOTFOUND);
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_NOTFOUND);
}
}
};
/*
* _nss_ldap_services_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)
{
}