summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2006-10-12 11:01:56 +0000
committerArthur de Jong <arthur@arthurdejong.org>2006-10-12 11:01:56 +0000
commitdba09bb1389491f82beb862323a5ccab428a7f2d (patch)
treee617b84715ab650b6cd162876f7ff6d0b897a05a
parent54845e6fb6d0fa0f7f77b4a7d8520897e0e98496 (diff)
first round of cleanups, all non-glibc NSS stuff has been removed, because we are going to do some major restructuring it will not likely remain valid anyway and we can always re-add it later
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/libnss_ldapd@10 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--Makefile.am32
-rw-r--r--aix_authmeth.c1023
-rw-r--r--dnsconfig.c22
-rw-r--r--dnsconfig.h13
-rw-r--r--irs-grp.c125
-rw-r--r--irs-hosts.c201
-rw-r--r--irs-netgrp.c191
-rw-r--r--irs-network.c213
-rw-r--r--irs-nss.c90
-rw-r--r--irs-nss.h60
-rw-r--r--irs-proto.c120
-rw-r--r--irs-pwd.c120
-rw-r--r--irs-service.c161
-rw-r--r--irs.h330
-rw-r--r--ldap-alias.c23
-rw-r--r--ldap-alias.h24
-rw-r--r--ldap-automount.c38
-rw-r--r--ldap-automount.h20
-rw-r--r--ldap-bp.c84
-rw-r--r--ldap-bp.h25
-rw-r--r--ldap-ethers.c228
-rw-r--r--ldap-ethers.h29
-rw-r--r--ldap-grp.c254
-rw-r--r--ldap-grp.h19
-rw-r--r--ldap-hosts.c172
-rw-r--r--ldap-hosts.h32
-rw-r--r--ldap-netgrp.c665
-rw-r--r--ldap-netgrp.h21
-rw-r--r--ldap-network.c186
-rw-r--r--ldap-network.h22
-rw-r--r--ldap-nss.c317
-rw-r--r--ldap-nss.h130
-rw-r--r--ldap-parse.h143
-rw-r--r--ldap-proto.c106
-rw-r--r--ldap-proto.h24
-rw-r--r--ldap-pwd.c126
-rw-r--r--ldap-pwd.h22
-rw-r--r--ldap-rpc.c105
-rw-r--r--ldap-rpc.h23
-rw-r--r--ldap-schema.c11
-rw-r--r--ldap-schema.h5
-rw-r--r--ldap-service.c148
-rw-r--r--ldap-service.h21
-rw-r--r--ldap-sldap.c1320
-rw-r--r--ldap-sldap.h172
-rw-r--r--ldap-spwd.c92
-rw-r--r--ldap-spwd.h18
-rw-r--r--ltf.c29
-rw-r--r--ltf.h9
-rw-r--r--nss_common.h6
-rw-r--r--nss_dbdefs.h134
-rw-r--r--nss_ldap.52
-rw-r--r--pagectrl.c7
-rw-r--r--pagectrl.h7
-rw-r--r--resolve.c2
-rw-r--r--resolve.h4
-rw-r--r--snprintf.c374
-rw-r--r--snprintf.h52
-rw-r--r--util.c73
-rw-r--r--util.h29
60 files changed, 427 insertions, 7627 deletions
diff --git a/Makefile.am b/Makefile.am
index a319d08..9f63ba5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,16 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-# TODO: move AIX hacks to configure
-
-if AIX
-authmod = NSS_LDAP
-else
-authmod =
-endif
-
-noinst_PROGRAMS = nss_ldap.so $(authmod)
+noinst_PROGRAMS = nss_ldap.so
INST_UID=root
if AIX
INST_GID=system
@@ -43,18 +34,14 @@ man_MANS = nss_ldap.5
nss_ldap_so_SOURCES = ldap-nss.c ldap-pwd.c ldap-grp.c ldap-netgrp.c ldap-rpc.c \
ldap-hosts.c ldap-network.c ldap-proto.c ldap-spwd.c \
ldap-alias.c ldap-service.c ldap-schema.c ldap-ethers.c \
- ldap-bp.c ldap-automount.c util.c ltf.c snprintf.c resolve.c \
- dnsconfig.c irs-nss.c pagectrl.c ldap-sldap.c
+ ldap-bp.c ldap-automount.c util.c ltf.c resolve.c \
+ dnsconfig.c pagectrl.c
nss_ldap_so_LDFLAGS = @nss_ldap_so_LDFLAGS@
NSS_LDAP_PATH_CONF = @NSS_LDAP_PATH_CONF@
NSS_LDAP_PATH_ROOTPASSWD = @NSS_LDAP_PATH_ROOTPASSWD@
-NSS_LDAP_SOURCES = ldap-nss.c ldap-grp.c ldap-pwd.c ldap-netgrp.c ldap-schema.c \
- util.c ltf.c snprintf.c resolve.c dnsconfig.c \
- irs-nss.c pagectrl.c aix_authmeth.c
-
NSS_LDAP_LDFLAGS = @NSS_LDAP_LDFLAGS@
DEFS = @DEFS@
#INCLUDES = -I$(top_builddir) -I$(srcdir)
@@ -78,15 +65,6 @@ endif
LINK = $(NATIVE_LINK) $(GNU_LINK)
if AIX
-
-# AIX install instructions per doc/README.AIX
-
-install-exec-local: nss_ldap.so NSS_LDAP
- $(mkinstalldirs) $(DESTDIR)$(libdir)/netsvc/dynload
- $(INSTALL_PROGRAM) -o $(INST_UID) -g $(INST_GID) nss_ldap.so $(DESTDIR)$(libdir)/netsvc/dynload/nss_ldap.so
- $(mkinstalldirs) $(DESTDIR)$(libdir)/security
- $(INSTALL_PROGRAM) -o $(INST_UID) -g $(INST_GID) NSS_LDAP $(DESTDIR)$(libdir)/security/NSS_LDAP
-
else
# Linux, Solaris, other platform install instructions
@@ -102,13 +80,9 @@ if GLIBC
(cd $(DESTDIR)/usr$(libdir); ln -sf ../..$(libdir)/$(NSS_LDAP_NSS_VERSIONED) .)
else
$(mkinstalldirs) $(DESTDIR)$(libdir)
-if HPUX
- $(INSTALL_PROGRAM) -o $(INST_UID) -g $(INST_GID) nss_ldap.so $(DESTDIR)$(libdir)/libnss_ldap.1
-else
$(INSTALL_PROGRAM) -o $(INST_UID) -g $(INST_GID) nss_ldap.so $(DESTDIR)$(libdir)/nss_ldap.so.1
(cd $(DESTDIR)$(libdir); rm -f nss_ldap.so; ln -s nss_ldap.so.1 nss_ldap.so)
endif
-endif
endif
diff --git a/aix_authmeth.c b/aix_authmeth.c
deleted file mode 100644
index d8d8e59..0000000
--- a/aix_authmeth.c
+++ /dev/null
@@ -1,1023 +0,0 @@
-/* Copyright (C) 2002-2005 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 2002.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-/*
- * Shim to support AIX loadable authentication modules
- */
-
-#include "config.h"
-
-static char rcsId[] =
- "$Id$";
-
-#ifdef HAVE_USERSEC_H
-
-#include <stdlib.h>
-#include <string.h>
-#include <usersec.h>
-
-#ifdef HAVE_LBER_H
-#include <lber.h>
-#endif
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
-#include "ldap-nss.h"
-#include "util.h"
-
-#define TABLE_KEY_ALL "ALL"
-#define TABLE_USER "user"
-#define TABLE_GROUP "group"
-
-#define S_LDAPDN "ldapdn"
-
-static struct irs_gr *uess_gr_be = NULL;
-static struct irs_pw *uess_pw_be = NULL;
-
-extern void *gr_pvtinit (void); /* irs-grp.c */
-extern void *pw_pvtinit (void); /* irs-pwd.c */
-
-/* from ldap-grp.c */
-extern char *_nss_ldap_getgrset (char *user);
-
-/* search arguments for getentry method */
-typedef struct ldap_uess_args
-{
- /* argument block */
- const char *lua_key;
- const char *lua_table;
- char **lua_attributes;
- attrval_t *lua_results;
- int lua_size;
-
- /* private */
- ldap_map_selector_t lua_map;
- size_t lua__bufsiz;
- size_t lua__buflen;
- char *lua__buffer;
- const char *lua_naming_attribute;
-}
-ldap_uess_args_t;
-
-static NSS_STATUS uess_get_char (LDAPMessage * e, ldap_uess_args_t * arg, int index);
-static NSS_STATUS uess_get_char_ex (LDAPMessage * e, ldap_uess_args_t * arg, int index, const char *attribute);
-static NSS_STATUS uess_get_int (LDAPMessage * e, ldap_uess_args_t * arg, int index);
-static NSS_STATUS uess_get_pgrp (LDAPMessage * e, ldap_uess_args_t * arg, int index);
-static NSS_STATUS uess_get_groupsids (LDAPMessage * e, ldap_uess_args_t * arg, int index);
-static NSS_STATUS uess_get_gecos (LDAPMessage * e, ldap_uess_args_t * arg, int index);
-static NSS_STATUS uess_get_pwd (LDAPMessage * e, ldap_uess_args_t * arg, int index);
-static NSS_STATUS uess_get_dn (LDAPMessage * e, ldap_uess_args_t * arg, int index);
-
-/* dispatch table for retrieving UESS attribute from an LDAP entry */
-struct ldap_uess_fn
-{
- const char *luf_attribute;
- NSS_STATUS (*luf_translator) (LDAPMessage * e,
- ldap_uess_args_t *, int);
-}
-ldap_uess_fn_t;
-
-static struct ldap_uess_fn __uess_fns[] = {
- {S_GECOS, uess_get_gecos},
- {S_GROUPSIDS, uess_get_groupsids},
- {S_HOME, uess_get_char},
- {S_ID, uess_get_int},
- {S_PWD, uess_get_pwd},
- {S_SHELL, uess_get_char},
- {S_PGRP, uess_get_pgrp},
- {SEC_PASSWD, uess_get_char},
- {SEC_LASTUP, uess_get_int},
- {S_MAXAGE, uess_get_int},
- {S_MINAGE, uess_get_int},
- {S_MAXEXPIRED, uess_get_int},
- {S_PWDWARNTIME, uess_get_int},
- /* add additional attributes we know about here */
- {S_LDAPDN, uess_get_dn},
- {NULL, NULL}
-};
-
-#define GR_PVTINIT() do { \
- if (uess_gr_be == NULL) { \
- uess_gr_be = (struct irs_gr *) gr_pvtinit (); \
- if (uess_gr_be == NULL) \
- return NULL; \
- } \
- } while (0)
-
-#define PW_PVTINIT() do { \
- if (uess_pw_be == NULL) { \
- uess_pw_be = (struct irs_pw *) pw_pvtinit (); \
- if (uess_pw_be == NULL) \
- return NULL; \
- } \
- } while (0)
-
-static void *
-_nss_ldap_uess_open (const char *name, const char *domain,
- const int mode, char *options)
-{
- /* Currently we do not use the above parameters */
- GR_PVTINIT();
- PW_PVTINIT();
-
- return NULL;
-}
-
-static void
-_nss_ldap_uess_close (void *token)
-{
- if (uess_gr_be != NULL)
- {
- (uess_gr_be->close) (uess_gr_be);
- uess_gr_be = NULL;
- }
-
- if (uess_pw_be != NULL)
- {
- (uess_pw_be->close) (uess_pw_be);
- uess_pw_be = NULL;
- }
-}
-
-static struct group *
-_nss_ldap_getgrgid (gid_t gid)
-{
- GR_PVTINIT ();
-
- return (uess_gr_be->bygid) (uess_gr_be, gid);
-}
-
-static struct group *
-_nss_ldap_getgrnam (const char *name)
-{
- GR_PVTINIT ();
-
- return (uess_gr_be->byname) (uess_gr_be, name);
-}
-
-static struct passwd *
-_nss_ldap_getpwuid (uid_t uid)
-{
- PW_PVTINIT ();
-
- return (uess_pw_be->byuid) (uess_pw_be, uid);
-}
-
-static struct passwd *
-_nss_ldap_getpwnam (const char *name)
-{
- PW_PVTINIT ();
-
- return (uess_pw_be->byname) (uess_pw_be, name);
-}
-
-static struct group *
-_nss_ldap_getgracct (void *id, int type)
-{
- GR_PVTINIT ();
-
- if (type == SEC_INT)
- return (uess_gr_be->bygid) (uess_gr_be, *(gid_t *) id);
- else
- return (uess_gr_be->byname) (uess_gr_be, (char *) id);
-}
-
-static int
-_nss_ldap_authenticate (char *user, char *response, int *reenter,
- char **message)
-{
- NSS_STATUS stat;
- int rc;
-
- debug ("==> _nss_ldap_authenticate");
-
- *reenter = FALSE;
- *message = NULL;
-
- stat = _nss_ldap_proxy_bind (user, response);
-
- switch (stat)
- {
- case NSS_TRYAGAIN:
- rc = AUTH_FAILURE;
- break;
- case NSS_NOTFOUND:
- rc = AUTH_NOTFOUND;
- break;
- case NSS_SUCCESS:
- rc = AUTH_SUCCESS;
- break;
- default:
- case NSS_UNAVAIL:
- rc = AUTH_UNAVAIL;
- break;
- }
-
- debug ("<== _nss_ldap_authenticate");
-
- return rc;
-}
-
-/*
- * Support this for when proxy authentication is disabled.
- * There may be some re-entrancy issues here; not sure
- * if we are supposed to return allocated memory or not,
- * this is not documented. I am assuming not in line with
- * the other APIs.
- */
-static char *
-_nss_ldap_getpasswd (char *user)
-{
- struct passwd *pw;
- static char pwdbuf[32];
- char *p = NULL;
-
- debug ("==> _nss_ldap_getpasswd");
-
- pw = _nss_ldap_getpwnam (user);
- if (pw != NULL)
- {
- if (strlen (pw->pw_passwd) > sizeof (pwdbuf) - 1)
- {
- errno = ERANGE;
- }
- else
- {
- strcpy (pwdbuf, pw->pw_passwd);
- p = pwdbuf;
- }
- }
- else
- {
- errno = ENOENT; /* user does not exist */
- }
-
- debug ("<== _nss_ldap_getpasswd");
-
- return p;
-}
-
-/*
- * Convert a UESS table string to an nss_ldap map type
- */
-static ldap_map_selector_t
-table2map (const char *table)
-{
- if (strcmp (table, TABLE_USER) == 0)
- return LM_PASSWD;
- else if (strcmp (table, TABLE_GROUP) == 0)
- return LM_GROUP;
-
- return LM_NONE;
-}
-
-/*
- * Convert a UESS key to an nss_ldap internal search query
- */
-static ldap_args_t *
-key2filter (char *key, ldap_map_selector_t map,
- ldap_args_t * a, const char **filter)
-{
- if (strcmp (key, TABLE_KEY_ALL) == 0)
- {
- if (map == LM_PASSWD)
- *filter = _nss_ldap_filt_getpwent;
- else
- *filter = _nss_ldap_filt_getgrent;
-
- return NULL; /* indicates enumeration */
- }
-
- LA_INIT (*a);
- LA_TYPE (*a) = LA_TYPE_STRING;
- LA_STRING (*a) = key;
-
- if (map == LM_PASSWD)
- *filter = _nss_ldap_filt_getpwnam;
- else
- *filter = _nss_ldap_filt_getgrnam;
-
- return a;
-}
-
-/*
- * Map a UESS attribute to an LDAP attribute
- */
-static const char *
-uess2ldapattr (ldap_map_selector_t map, const char *attribute)
-{
- if (strcmp (attribute, "username") == 0)
- return ATM (LM_PASSWD, uid);
- else if (strcmp (attribute, "groupname") == 0)
- return ATM (LM_GROUP, cn);
- else if (strcmp (attribute, S_ID) == 0)
- {
- if (map == LM_PASSWD)
- return ATM (LM_PASSWD, uidNumber);
- else
- return ATM (LM_GROUP, gidNumber);
- }
- else if (strcmp (attribute, S_PWD) == 0)
- return ATM (LM_PASSWD, userPassword);
- else if (strcmp (attribute, S_HOME) == 0)
- return ATM (LM_PASSWD, homeDirectory);
- else if (strcmp (attribute, S_SHELL) == 0)
- return ATM (LM_PASSWD, loginShell);
- else if (strcmp (attribute, S_GECOS) == 0)
- return ATM (LM_PASSWD, gecos);
- else if (strcmp (attribute, SEC_PASSWD) == 0)
- return ATM (LM_SHADOW, userPassword);
- else if (strcmp (attribute, SEC_LASTUP) == 0)
- return ATM (LM_SHADOW, shadowLastChange);
- else if (strcmp (attribute, S_MAXAGE) == 0)
- return ATM (LM_SHADOW, shadowMax);
- else if (strcmp (attribute, S_MINAGE) == 0)
- return ATM (LM_SHADOW, shadowMin);
- else if (strcmp (attribute, S_MAXEXPIRED) == 0)
- return ATM (LM_SHADOW, shadowExpire);
- else if (strcmp (attribute, S_PWDWARNTIME) == 0)
- return ATM (LM_SHADOW, shadowWarning);
- else if (strcmp (attribute, S_PGRP) == 0)
- return ATM (LM_GROUP, cn);
- else if (strcmp (attribute, S_USERS) == 0)
- return ATM (LM_GROUP, memberUid);
-
- return NULL;
-}
-
-/*
- * Get primary group name for a user
- */
-static NSS_STATUS
-uess_get_pgrp (LDAPMessage * e, ldap_uess_args_t * lua, int i)
-{
- char **vals;
- LDAPMessage *res;
- const char *attrs[2];
- NSS_STATUS stat;
- ldap_args_t a;
-
- vals = _nss_ldap_get_values (e, ATM (LM_PASSWD, gidNumber));
- if (vals == NULL)
- return NSS_NOTFOUND;
-
- LA_INIT (a);
- LA_TYPE (a) = LA_TYPE_NUMBER;
- LA_NUMBER (a) = atol(vals[0]);
-
- attrs[0] = ATM (LM_GROUP, cn);
- attrs[1] = NULL;
-
- stat = _nss_ldap_search_s (&a, _nss_ldap_filt_getgrgid, LM_GROUP,
- attrs, 1, &res);
- if (stat != NSS_SUCCESS)
- {
- ldap_value_free (vals);
- return NSS_NOTFOUND;
- }
-
- ldap_value_free (vals);
-
- e = _nss_ldap_first_entry (res);
- if (e == NULL)
- {
- ldap_msgfree (res);
- return NSS_NOTFOUND;
- }
-
- stat = uess_get_char_ex (e, lua, i, attrs[0]);
-
- ldap_msgfree (res);
-
- return stat;
-}
-
-/*
- * Get groups to which a user belongs
- */
-static NSS_STATUS
-uess_get_groupsids (LDAPMessage * e, ldap_uess_args_t * lua, int i)
-{
- char *p, *q;
- size_t len;
-
- p = _nss_ldap_getgrset ((char *) lua->lua_key);
- if (p == NULL)
- return NSS_NOTFOUND;
-
- len = strlen (p);
- q = malloc (len + 2);
- if (q == NULL)
- {
- errno = ENOMEM;
- return NSS_NOTFOUND;
- }
-
- memcpy (q, p, len + 1);
- q[len + 1] = '\0';
-
- free (p);
- p = NULL;
-
- for (p = q; *p != '\0'; p++)
- {
- if (*p == ',')
- *p++ = '\0';
- }
-
- lua->lua_results[i].attr_un.au_char = q;
-
- return NSS_SUCCESS;
-}
-
-/*
- * Get a mapped UESS string attribute
- */
-static NSS_STATUS
-uess_get_char (LDAPMessage * e, ldap_uess_args_t * lua, int i)
-{
- const char *attribute;
-
- attribute = uess2ldapattr (lua->lua_map, lua->lua_attributes[i]);
- if (attribute == NULL)
- return NSS_NOTFOUND;
-
- return uess_get_char_ex (e, lua, i, attribute);
-}
-
-/*
- * Get a specific LDAP attribute
- */
-static NSS_STATUS
-uess_get_char_ex (LDAPMessage * e,
- ldap_uess_args_t * lua, int i, const char *attribute)
-{
- char **vals;
- attrval_t *av = &lua->lua_results[i];
-
- vals = _nss_ldap_get_values (e, attribute);
- if (vals == NULL)
- return NSS_NOTFOUND;
-
- if (vals[0] == NULL)
- {
- ldap_value_free (vals);
- return NSS_NOTFOUND;
- }
-
- av->attr_un.au_char = strdup (vals[0]);
- if (av->attr_un.au_char == NULL)
- {
- ldap_value_free (vals);
- return NSS_TRYAGAIN;
- }
-
- ldap_value_free (vals);
- return NSS_SUCCESS;
-}
-
-/*
- * Get an encoded crypt password
- */
-static NSS_STATUS
-uess_get_pwd (LDAPMessage * e, ldap_uess_args_t * lua, int i)
-{
- char **vals;
- attrval_t *av = &lua->lua_results[i];
- const char *pwd;
- const char *attribute;
-
- attribute = uess2ldapattr (lua->lua_map, lua->lua_attributes[i]);
- if (attribute == NULL)
- return NSS_NOTFOUND;
-
- vals = _nss_ldap_get_values (e, attribute);
- pwd = _nss_ldap_locate_userpassword (vals);
-
- av->attr_un.au_char = strdup (pwd);
- if (vals != NULL)
- ldap_value_free (vals);
-
- return (av->attr_un.au_char == NULL) ? NSS_TRYAGAIN : NSS_SUCCESS;
-}
-
-/*
- * Get a UESS integer attribute
- */
-static NSS_STATUS
-uess_get_int (LDAPMessage * e, ldap_uess_args_t * lua, int i)
-{
- const char *attribute;
- char **vals;
- attrval_t *av = &lua->lua_results[i];
-
- attribute = uess2ldapattr (lua->lua_map, lua->lua_attributes[i]);
- if (attribute == NULL)
- return NSS_NOTFOUND;
-
- vals = _nss_ldap_get_values (e, attribute);
- if (vals == NULL)
- return NSS_NOTFOUND;
-
- if (vals[0] == NULL)
- {
- ldap_value_free (vals);
- return NSS_NOTFOUND;
- }
-
- av->attr_un.au_int = atoi (vals[0]);
- ldap_value_free (vals);
- return NSS_SUCCESS;
-}
-
-/*
- * Get the GECOS/cn attribute
- */
-static NSS_STATUS
-uess_get_gecos (LDAPMessage * e, ldap_uess_args_t * lua, int i)
-{
- NSS_STATUS stat;
-
- stat = uess_get_char (e, lua, i);
- if (stat == NSS_NOTFOUND)
- {
- stat = uess_get_char_ex (e, lua, i, ATM (LM_PASSWD, cn));
- }
-
- return stat;
-}
-
-/*
- * Get the DN
- */
-static NSS_STATUS
-uess_get_dn (LDAPMessage * e, ldap_uess_args_t * lua, int i)
-{
- lua->lua_results[i].attr_un.au_char = _nss_ldap_get_dn (e);
- if (lua->lua_results[i].attr_un.au_char == NULL)
- return NSS_NOTFOUND;
-
- return NSS_SUCCESS;
-}
-
-static NSS_STATUS
-do_parse_uess_getentry (LDAPMessage * e,
- ldap_state_t * pvt, void *result,
- char *buffer, size_t buflen)
-{
- ldap_uess_args_t *lua = (ldap_uess_args_t *) result;
- int i;
- char **vals;
- size_t len;
- NSS_STATUS stat;
-
- /* If a buffer is supplied, then we are enumerating. */
- if (lua->lua__buffer != NULL)
- {
- attrval_t *av = lua->lua_results;
-
- vals = _nss_ldap_get_values (e, lua->lua_naming_attribute);
- if (vals == NULL)
- return NSS_NOTFOUND;
-
- if (vals[0] == NULL)
- {
- ldap_value_free (vals);
- return NSS_NOTFOUND;
- }
-
- len = strlen (vals[0]) + 1; /* for string terminator */
-
- if (lua->lua__buflen < len + 1) /* for list terminator */
- {
- size_t grow = len + 1;
- size_t offset = (lua->lua__buffer - av->attr_un.au_char);
-
- grow += NSS_BUFSIZ - 1;
- grow -= (grow % NSS_BUFSIZ);
-
- av->attr_un.au_char =
- realloc (lua->lua__buffer, lua->lua__bufsiz + grow);
- if (av->attr_un.au_char == NULL)
- {
- ldap_value_free (vals);
- return NSS_TRYAGAIN;
- }
- /* reset buffer pointer in case realloc() returned a new region */
- lua->lua__buffer = &av->attr_un.au_char[offset];
- lua->lua__buflen += grow;
- lua->lua__bufsiz += grow;
- }
-
- memcpy (lua->lua__buffer, vals[0], len);
- lua->lua__buflen -= len;
- lua->lua__buffer += len;
- ldap_value_free (vals);
-
- lua->lua__buffer[0] = '\0'; /* ensure _list_ is always terminated */
-
- if (av->attr_flag != 0)
- av->attr_flag = 0;
-
- return NSS_NOTFOUND; /* trick caller into calling us again */
- }
- else
- {
- for (i = 0; i < lua->lua_size; i++)
- {
- int j;
- attrval_t *av = &lua->lua_results[i];
-
- av->attr_flag = -1;
- av->attr_un.au_char = NULL;
-
- for (j = 0; __uess_fns[j].luf_attribute != NULL; j++)
- {
- if (strcmp (__uess_fns[j].luf_attribute, lua->lua_attributes[i])
- == 0)
- {
- stat = (__uess_fns[j].luf_translator) (e, lua, i);
- switch (stat)
- {
- case NSS_SUCCESS:
- av->attr_flag = 0;
- break;
- case NSS_TRYAGAIN:
- return NSS_TRYAGAIN;
- break;
- default:
- break;
- }
- }
- }
- }
- }
-
- return NSS_SUCCESS;
-}
-
-static int
-_nss_ldap_getentry (char *key, char *table, char *attributes[],
- attrval_t results[], int size)
-{
- NSS_STATUS stat;
- ent_context_t *ctx = NULL;
- ldap_args_t a, *ap;
- const char *filter;
- int erange = 0;
- ldap_uess_args_t lua;
- const char *namingAttributes[2];
-
- debug ("==> _nss_ldap_getentry (key=%s table=%s attributes[0]=%s size=%d)",
- (key != NULL) ? key : "(null)",
- (table != NULL) ? table : "(null)",
- (size >= 1) ? attributes[0] : "(null)",
- size);
-
- lua.lua_key = key;
- lua.lua_table = table;
- lua.lua_attributes = attributes;
- lua.lua_results = results;
- lua.lua_size = size;
- lua.lua_naming_attribute = NULL;
-
- lua.lua_map = table2map (table);
- if (lua.lua_map == LM_NONE)
- {
- errno = ENOSYS;
- debug ("<== _nss_ldap_getentry (no such map)");
- return -1;
- }
-
- lua.lua__buffer = NULL;
- lua.lua__bufsiz = 0;
- lua.lua__buflen = 0;
-
- ap = key2filter (key, lua.lua_map, &a, &filter);
- if (ap == NULL) /* enumeration */
- {
- const char **attrs;
-
- if (size != 1)
- {
- errno = EINVAL;
- debug ("<== _nss_ldap_getentry (size != 1)");
- return -1;
- }
-
- debug (":== _nss_ldap_getentry filter=%s attribute=%s",
- filter, lua.lua_attributes[0]);
-
- lua.lua__bufsiz = NSS_BUFSIZ;
- lua.lua__buflen = lua.lua__bufsiz;
- lua.lua__buffer = results[0].attr_un.au_char = malloc (lua.lua__bufsiz);
- if (lua.lua__buffer == NULL)
- {
- errno = ENOMEM;
- debug ("<== _nss_ldap_getentry (no memory)");
- return -1;
- }
- results[0].attr_flag = -1;
-
- /* just request the naming attributes */
- attrs = _nss_ldap_get_attributes (lua.lua_map);
- if (attrs == NULL || attrs[0] == NULL)
- {
- errno = ENOENT;
- debug ("<== _nss_ldap_getentry (could not read schema)");
- return -1;
- }
-
- lua.lua_naming_attribute = attrs[0];
- namingAttributes[0] = lua.lua_naming_attribute;
- namingAttributes[1] = NULL;
- }
- else
- {
- /* Check at least one attribute is mapped before searching */
- int i, found = 0;
-
- for (i = 0; i < size; i++)
- {
- if (uess2ldapattr (lua.lua_map, lua.lua_attributes[i]) != NULL)
- {
- found++;
- break;
- }
- }
-
- if (!found)
- {
- errno = ENOENT;
- debug ("<== _nss_ldap_getentry (no mappable attribute requested)");
- return -1;
- }
- }
-
- _nss_ldap_enter ();
- if (_nss_ldap_ent_context_init_locked (&ctx) == NULL)
- {
- _nss_ldap_leave ();
- if (results[0].attr_un.au_char != NULL)
- free (results[0].attr_un.au_char);
- errno = ENOMEM;
- debug ("<== _nss_ldap_getentry (ent_context_init failed)");
- return -1;
- }
-
- stat = _nss_ldap_getent_ex (ap, &ctx, (void *) &lua, NULL, 0,
- &erange, filter, lua.lua_map,
- (ap == NULL) ? namingAttributes : NULL,
- do_parse_uess_getentry);
-
- _nss_ldap_ent_context_release (ctx);
- free (ctx);
- _nss_ldap_leave ();
-
- /*
- * Whilst enumerating, we have the parser always return
- * NSS_NOTFOUND so that it will be called for each entry.
- *
- * Although this is probably bogus overloading of the
- * _nss_ldap_getent_ex() API, it does allow us to share
- * the same code for matches and enumerations. However,
- * for the enumeration case we need to treat NSS_NOTFOUND
- * as a success code; hence, we use the attr_flag to
- * indicate failure.
- */
- if (ap == NULL)
- {
- if (stat == NSS_NOTFOUND && results[0].attr_flag == 0)
- stat = NSS_SUCCESS;
- }
-
- if (stat != NSS_SUCCESS)
- {
- if (stat == NSS_TRYAGAIN)
- errno = ERANGE;
- else
- errno = ENOENT;
-
- debug ("<== _nss_ldap_getentry (failed with stat=%d)", stat);
- return -1;
- }
-
- debug ("<== _nss_ldap_getentry (success)");
- return AUTH_SUCCESS;
-}
-
-/*
- *
- */
-static NSS_STATUS
-uess_get_pwuid(const char *user, uid_t *uid)
-{
- char **vals;
- LDAPMessage *res, *e;
- const char *attrs[2];
- NSS_STATUS stat;
- ldap_args_t a;
-
- LA_INIT (a);
- LA_TYPE (a) = LA_TYPE_STRING;
- LA_STRING (a) = user;
-
- attrs[0] = ATM (LM_PASSWD, uidNumber);
- attrs[1] = NULL;
-
- stat = _nss_ldap_search_s (&a, _nss_ldap_filt_getpwuid, LM_PASSWD,
- attrs, 1, &res);
- if (stat != NSS_SUCCESS)
- return stat;
-
- e = _nss_ldap_first_entry (res);
- if (e == NULL)
- {
- ldap_msgfree (res);
- return NSS_NOTFOUND;
- }
-
- vals = _nss_ldap_get_values (e, attrs[0]);
- if (vals == NULL)
- {
- ldap_msgfree (res);
- return NSS_NOTFOUND;
- }
-
- if (vals[0] == NULL || (vals[0])[0] == '\0')
- {
- ldap_value_free (vals);
- ldap_msgfree (res);
- return NSS_NOTFOUND;
- }
-
- *uid = atoi(vals[0]);
-
- ldap_value_free (vals);
- ldap_msgfree (res);
-
- return NSS_SUCCESS;
-}
-
-/*
- * Get membership for a group
- */
-static int
-_nss_ldap_getgrusers (char *group, void *result, int type, int *size)
-{
- struct group *gr;
- struct irs_gr *be;
- char **memp;
- size_t i;
-
- be = (struct irs_gr *) gr_pvtinit ();
- if (be == NULL)
- {
- errno = ENOSYS;
- return -1;
- }
-
- gr = (be->byname) (be, group);
- if (gr == NULL)
- {
- (be->close) (be);
- errno = ENOENT;
- return -1;
- }
-
- if (gr->gr_mem == NULL)
- {
- (be->close) (be);
- *size = 0;
- return 0;
- }
-
- for (i = 0; gr->gr_mem[i] != NULL; i++)
- ;
-
- if (i > *size)
- {
- (be->close) (be);
- *size = i;
- errno = ERANGE;
- return -1;
- }
-
- _nss_ldap_enter ();
-
- for (i = 0, memp = gr->gr_mem; *memp != NULL; memp++)
- {
- if (type == SEC_INT)
- {
- if (uess_get_pwuid(*memp, &(((uid_t *)result)[i])) != NSS_SUCCESS)
- continue;
- }
- else
- {
- ((char **)result)[i] = strdup(*memp);
- if (((char **)result)[i] == NULL)
- {
- _nss_ldap_leave ();
- (be->close) (be);
- errno = ENOMEM;
- return -1;
- }
- }
- i++;
- }
-
- _nss_ldap_leave ();
-
- *size = i;
-
- (be->close) (be);
-
- return AUTH_SUCCESS;
-}
-
-#if 0
-/*
- * Additional attributes supported
- */
-static attrlist_t **
-_nss_ldap_attrlist(void)
-{
- attrlist_t **a;
-
- a = malloc(2 * sizeof(attrlist_t *) + sizeof(attrlist_t));
- if (a == NULL)
- {
- errno = ENOMEM;
- return NULL;
- }
-
- a[0] = (attrlist_t *)(a + 2);
-
- a[0]->al_name = strdup(S_LDAPDN);
- a[0]->al_flags = AL_USERATTR;
- a[0]->al_type = SEC_CHAR;
-
- a[1] = NULL;
-
- return a;
-}
-#endif /* notdef */
-
-#if 0
-/* not implemented yet */
-static int
-_nss_ldap_normalize (char *longname, char *shortname)
-{
-}
-#endif
-
-int
-nss_ldap_initialize (struct secmethod_table *meths)
-{
- memset (meths, 0, sizeof (*meths));
-
- /* Initialize schema */
- (void) _nss_ldap_init();
-
- /* Identification methods */
- meths->method_getpwnam = _nss_ldap_getpwnam;
- meths->method_getpwuid = _nss_ldap_getpwuid;
- meths->method_getgrnam = _nss_ldap_getgrnam;
- meths->method_getgrgid = _nss_ldap_getgrgid;
- meths->method_getgrset = _nss_ldap_getgrset;
- meths->method_getentry = _nss_ldap_getentry;
-/* meths->method_attrlist = _nss_ldap_attrlist; */
- meths->method_getgrusers = _nss_ldap_getgrusers;
-/* meths->method_normalize = _nss_ldap_normalize; */
- meths->method_getgracct = _nss_ldap_getgracct;
- meths->method_getpasswd = _nss_ldap_getpasswd;
-
- /* Support methods */
- meths->method_open = _nss_ldap_uess_open;
- meths->method_close = _nss_ldap_uess_close;
-
- /* Authentication methods */
- meths->method_authenticate = _nss_ldap_authenticate;
-
- return AUTH_SUCCESS;
-}
-
-#endif /* HAVE_USERSEC_H */
diff --git a/dnsconfig.c b/dnsconfig.c
index c40ac6f..59adc4b 100644
--- a/dnsconfig.c
+++ b/dnsconfig.c
@@ -1,8 +1,7 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
- (The author maintains a non-exclusive licence to distribute this file
- under their own conditions.)
The nss_ldap library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -18,7 +17,9 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
+
+ $Id$
+*/
/*
* Support DNS SRV records. I look up the SRV record for
@@ -27,9 +28,6 @@
* Thanks to Assar & co for resolve.[ch].
*/
-static char rcsId[] =
- "$Id$";
-
#include "config.h"
#include <stdio.h>
@@ -50,10 +48,6 @@ static char rcsId[] =
#include <ldap.h>
#endif
-#ifndef HAVE_SNPRINTF
-#include "snprintf.h"
-#endif
-
#include "ldap-nss.h"
#include "util.h"
#include "resolve.h"
@@ -61,7 +55,7 @@ static char rcsId[] =
/* map gnu.org into DC=gnu,DC=org */
-NSS_STATUS
+enum nss_status
_nss_ldap_getdnsdn (char *src_domain,
char **rval, char **buffer, size_t * buflen)
{
@@ -130,11 +124,11 @@ _nss_ldap_getdnsdn (char *src_domain,
return NSS_SUCCESS;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_mergeconfigfromdns (ldap_config_t * result,
char **buffer, size_t *buflen)
{
- NSS_STATUS stat = NSS_SUCCESS;
+ enum nss_status stat = NSS_SUCCESS;
struct dns_reply *r;
struct resource_record *rr;
char domain[MAXHOSTNAMELEN + 1];
diff --git a/dnsconfig.h b/dnsconfig.h
index e2a5404..956ec20 100644
--- a/dnsconfig.h
+++ b/dnsconfig.h
@@ -1,8 +1,7 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
- (The author maintains a non-exclusive licence to distribute this file
- under their own conditions.)
The nss_ldap library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -18,16 +17,18 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
+
+ $Id$
+*/
#ifndef _LDAP_NSS_LDAP_DNSCONFIG_H
#define _LDAP_NSS_LDAP_DNSCONFIG_H
/* utility routines. */
-NSS_STATUS _nss_ldap_getdnsdn (char *domain,
+enum nss_status _nss_ldap_getdnsdn (char *domain,
char **rval, char **buffer, size_t * buflen);
-NSS_STATUS _nss_ldap_mergeconfigfromdns (ldap_config_t * result, char **buffer, size_t *buflen);
+enum nss_status _nss_ldap_mergeconfigfromdns (ldap_config_t * result, char **buffer, size_t *buflen);
#endif /* _LDAP_NSS_LDAP_DNSCONFIG_H */
diff --git a/irs-grp.c b/irs-grp.c
deleted file mode 100644
index f5f57e2..0000000
--- a/irs-grp.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* Copyright (C) 1997-2005 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 1997.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_IRS_H
-
-#include <errno.h>
-#include "irs-nss.h"
-
-/* $Id$ */
-
-#ifdef HAVE_USERSEC_H
-void *gr_pvtinit (void);
-#endif
-IRS_EXPORT void gr_close (struct irs_gr *);
-IRS_EXPORT struct group *gr_next (struct irs_gr *);
-IRS_EXPORT struct group *gr_byname (struct irs_gr *, const char *);
-IRS_EXPORT struct group *gr_bygid (struct irs_gr *, gid_t);
-IRS_EXPORT void gr_rewind (struct irs_gr *);
-IRS_EXPORT void gr_minimize (struct irs_gr *);
-
-struct pvt
-{
- struct group result;
- char buffer[NSS_BUFLEN_GROUP];
- ent_context_t *state;
-};
-
-IRS_EXPORT struct group *
-gr_byname (struct irs_gr *this, const char *name)
-{
- LOOKUP_NAME (name, this, _nss_ldap_filt_getgrnam, LM_GROUP,
- _nss_ldap_parse_gr, NSS_BUFLEN_GROUP);
-}
-
-IRS_EXPORT struct group *
-gr_bygid (struct irs_gr *this, gid_t gid)
-{
- LOOKUP_NUMBER (gid, this, _nss_ldap_filt_getgrgid, LM_GROUP,
- _nss_ldap_parse_gr, NSS_BUFLEN_GROUP);
-}
-
-IRS_EXPORT void
-gr_close (struct irs_gr *this)
-{
- LOOKUP_ENDENT (this);
-#ifdef HAVE_USERSEC_H
- free (this->private);
- free (this);
-#endif
-}
-
-IRS_EXPORT struct group *
-gr_next (struct irs_gr *this)
-{
- LOOKUP_GETENT (this, _nss_ldap_filt_getgrent, LM_GROUP, _nss_ldap_parse_gr,
- NSS_BUFLEN_GROUP);
-}
-
-IRS_EXPORT void
-gr_rewind (struct irs_gr *this)
-{
- LOOKUP_SETENT (this);
-}
-
-IRS_EXPORT void
-gr_minimize (struct irs_gr *this)
-{
-}
-
-#ifdef HAVE_USERSEC_H
-void *
-gr_pvtinit (void)
-#else
-struct irs_gr *
-irs_ldap_gr (struct irs_acc *this)
-#endif
-{
- struct irs_gr *gr;
- struct pvt *pvt;
-
- gr = calloc (1, sizeof (*gr));
- if (gr == NULL)
- return NULL;
-
- pvt = calloc (1, sizeof (*pvt));
- if (pvt == NULL)
- {
- free (gr);
- return NULL;
- }
-
- pvt->state = NULL;
- gr->private = pvt;
- gr->close = gr_close;
- gr->next = gr_next;
- gr->byname = gr_byname;
- gr->bygid = gr_bygid;
-#ifndef HAVE_USERSEC_H
- gr->list = make_group_list;
-#else
- gr->list = NULL;
-#endif
- gr->rewind = gr_rewind;
- gr->minimize = gr_minimize;
- return gr;
-}
-
-#endif /* HAVE_IRS_H */
diff --git a/irs-hosts.c b/irs-hosts.c
deleted file mode 100644
index 0b5b8d6..0000000
--- a/irs-hosts.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/* Copyright (C) 1997-2005 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 1997.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_IRS_H
-
-#include <errno.h>
-#include "irs-nss.h"
-
-/* $Id$ */
-
-#ifdef HAVE_USERSEC_H
-void *ho_pvtinit (void);
-#endif
-IRS_EXPORT void ho_close (struct irs_ho *this);
-IRS_EXPORT struct hostent *ho_byname (struct irs_ho *this, const char *name);
-IRS_EXPORT struct hostent *ho_byname2 (struct irs_ho *this, const char *name,
- int af);
-IRS_EXPORT struct hostent *ho_byaddr (struct irs_ho *this, const void *addr,
- int len, int af);
-IRS_EXPORT struct hostent *ho_next (struct irs_ho *this);
-IRS_EXPORT void ho_rewind (struct irs_ho *this);
-IRS_EXPORT void ho_minimize (struct irs_ho *this);
-
-
-static const u_char mapped[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
-static const u_char tunnelled[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
-struct pvt
-{
- struct hostent result;
- char buffer[NSS_BUFLEN_HOSTS];
- ent_context_t *state;
-};
-
-IRS_EXPORT struct hostent *
-ho_byname (struct irs_ho *this, const char *name)
-{
- NSS_STATUS s;
- struct pvt *pvt = (struct pvt *) this->private;
- ldap_args_t a;
-
- LA_INIT (a);
- LA_STRING (a) = name;
- LA_TYPE (a) = LA_TYPE_STRING;
-
- s = _nss_ldap_getbyname (&a,
- &pvt->result,
- pvt->buffer,
- sizeof (pvt->buffer),
- &errno,
- _nss_ldap_filt_gethostbyname,
- LM_HOSTS, _nss_ldap_parse_hostv4);
-
- if (s != NSS_SUCCESS)
- {
- MAP_H_ERRNO (s, h_errno);
- return NULL;
- }
- return &pvt->result;
-}
-
-IRS_EXPORT struct hostent *
-ho_byaddr (struct irs_ho *this, const void *addr, int len, int af)
-{
- struct pvt *pvt = (struct pvt *) this->private;
- char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
- const u_char *uaddr = addr;
- NSS_STATUS s;
- ldap_args_t a;
-
- if (af == AF_INET6 && len == IN6ADDRSZ
- && (!memcmp (uaddr, mapped, sizeof mapped) ||
- !memcmp (uaddr, tunnelled, sizeof tunnelled)))
- {
- /* Unmap. */
- addr = (u_char *) addr + sizeof mapped;
- uaddr += sizeof mapped;
- af = AF_INET;
- len = INADDRSZ;
- }
- if (inet_ntop (af, uaddr, tmp, sizeof tmp) == NULL)
- {
- h_errno = NETDB_INTERNAL;
- return (NULL);
- }
-
- LA_INIT (a);
- LA_STRING (a) = tmp;
- LA_TYPE (a) = LA_TYPE_STRING;
-
- s = _nss_ldap_getbyname (&a,
- &pvt->result,
- pvt->buffer,
- sizeof (pvt->buffer),
- &errno,
- _nss_ldap_filt_gethostbyaddr,
- LM_HOSTS, _nss_ldap_parse_hostv4);
-
- if (s != NSS_SUCCESS)
- {
- MAP_H_ERRNO (s, h_errno);
- return NULL;
- }
- return &pvt->result;
-}
-
-IRS_EXPORT void
-ho_close (struct irs_ho *this)
-{
- LOOKUP_ENDENT (this);
-#ifdef HAVE_USERSEC_H
- free (this->private);
- free (this);
-#endif
-}
-
-IRS_EXPORT struct hostent *
-ho_next (struct irs_ho *this)
-{
- struct pvt *pvt = (struct pvt *) this->private;
- NSS_STATUS s;
-
- s = _nss_ldap_getent (&pvt->state,
- &pvt->result,
- pvt->buffer,
- sizeof (pvt->buffer),
- &errno,
- _nss_ldap_filt_gethostent,
- LM_HOSTS, _nss_ldap_parse_hostv4);
-
- if (s != NSS_SUCCESS)
- {
- MAP_H_ERRNO (s, h_errno);
- return NULL;
- }
- return &pvt->result;
-}
-
-IRS_EXPORT void
-ho_rewind (struct irs_ho *this)
-{
- LOOKUP_SETENT (this);
-}
-
-IRS_EXPORT void
-ho_minimize (struct irs_ho *this)
-{
-}
-
-#ifdef HAVE_USERSEC_H
-void *
-ho_pvtinit (void)
-#else
-struct irs_ho *
-irs_ldap_ho (struct irs_acc *this)
-#endif
-{
- struct irs_ho *ho;
- struct pvt *pvt;
-
- ho = calloc (1, sizeof (*ho));
- if (ho == NULL)
- return NULL;
-
- pvt = calloc (1, sizeof (*pvt));
- if (pvt == NULL)
- {
- free (ho);
- return NULL;
- }
-
- pvt->state = NULL;
- ho->private = pvt;
- ho->close = ho_close;
- ho->next = ho_next;
- ho->byname = ho_byname;
-/* ho->byname2 = ho_byname2; */
- ho->byaddr = ho_byaddr;
- ho->rewind = ho_rewind;
- ho->minimize = ho_minimize;
- return ho;
-}
-
-#endif /*HAVE_IRS_H */
diff --git a/irs-netgrp.c b/irs-netgrp.c
deleted file mode 100644
index 351c3f7..0000000
--- a/irs-netgrp.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/* Copyright (C) 2004 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 2004.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_IRS_H
-
-#include <errno.h>
-#include "irs-nss.h"
-
-/* $Id$ */
-
-#ifdef HAVE_USERSEC_H
-void *ng_pvtinit (void);
-#endif
-IRS_EXPORT void ng_close (struct irs_ng *);
-IRS_EXPORT int ng_next (struct irs_ng *, char **, char **, char **);
-IRS_EXPORT int ng_test (struct irs_ng *, const char *, const char *,
- const char *, const char *);
-IRS_EXPORT void ng_rewind (struct irs_ng *, const char *);
-IRS_EXPORT void ng_minimize (struct irs_ng *);
-
-IRS_EXPORT int
-ng_test (struct irs_ng *this,
- const char *name, const char *host,
- const char *user, const char *domain)
-{
- NSS_STATUS parseStat;
- ldap_innetgr_args_t li_args;
-
- li_args.lia_netgroup = name;
- li_args.lia_netgr_status = NSS_NETGR_NO;
- li_args.lia_depth = 0;
- li_args.lia_erange = 0;
-
- _nss_ldap_enter ();
-
- /* fall through to NSS implementation */
- parseStat = do_innetgr (&li_args, host, user, domain);
- if (parseStat != NSS_SUCCESS && parseStat != NSS_NOTFOUND)
- {
- if (li_args.lia_erange)
- errno = ERANGE;
- _nss_ldap_leave ();
-
- return 0;
- }
-
- _nss_ldap_leave ();
-
- return (li_args.lia_netgr_status == NSS_NETGR_FOUND);
-}
-
-IRS_EXPORT void
-ng_rewind (struct irs_ng *this, const char *group)
-{
- nss_ldap_netgr_backend_t *ngbe;
- ldap_args_t a;
- NSS_STATUS stat;
-
- ngbe = (nss_ldap_netgr_backend_t *) this->private;
-
- /* clear out old state */
- _nss_ldap_namelist_destroy (&ngbe->known_groups);
- _nss_ldap_namelist_destroy (&ngbe->needed_groups);
-
- LA_INIT (a);
- LA_TYPE (a) = LA_TYPE_STRING;
- LA_STRING (a) = group;
-
- if (_nss_ldap_ent_context_init (&ngbe->state) == NULL)
- return;
-
- _nss_ldap_enter ();
- stat = _nss_ldap_search_s (&a, _nss_ldap_filt_getgrent,
- LM_NETGROUP, NULL, 1, &ngbe->state->ec_res);
-
- if (stat == NSS_SUCCESS)
- _nss_ldap_namelist_push (&ngbe->known_groups, group);
-
- if (stat != NSS_SUCCESS)
- _nss_ldap_ent_context_release (ngbe->state);
-
- _nss_ldap_leave ();
-}
-
-IRS_EXPORT int
-ng_next (struct irs_ng *this, char **machine, char **user, char **domain)
-{
- nss_ldap_netgr_backend_t *ngbe = (nss_ldap_netgr_backend_t *) this->private;
- enum nss_netgr_status netgr_stat;
- NSS_STATUS stat;
-
- if (ngbe->state == NULL)
- return 0;
-
- _nss_ldap_enter ();
-
- stat = do_getnetgrent (ngbe,
- ngbe->buffer,
- NSS_BUFLEN_NETGROUP,
- &netgr_stat,
- machine,
- user,
- domain);
-
- _nss_ldap_leave ();
-
- return (stat == NSS_SUCCESS);
-}
-
-IRS_EXPORT void
-ng_minimize (struct irs_ng *this)
-{
-}
-
-IRS_EXPORT void
-ng_close (struct irs_ng *this)
-{
-#ifdef HAVE_USERSEC_H
- nss_ldap_netgr_backend_t *ngbe;
-
- ngbe = (nss_ldap_netgr_backend_t *) this->private;
- if (ngbe != NULL)
- {
- if (ngbe->state != NULL)
- {
- _nss_ldap_enter ();
- _nss_ldap_ent_context_release (ngbe->state);
- free (ngbe->state);
- _nss_ldap_leave ();
- }
-
- _nss_ldap_namelist_destroy (&ngbe->known_groups);
- _nss_ldap_namelist_destroy (&ngbe->needed_groups);
-
- free (ngbe);
- }
-
- free (this);
-#endif /* HAVE_USERSEC_H */
-}
-
-#ifdef HAVE_USERSEC_H
-void *
-ng_pvtinit (void)
-#else
-struct irs_ng *
-irs_ldap_ng (struct irs_acc *this)
-#endif
-{
- struct irs_ng *ng;
- nss_ldap_netgr_backend_t *pvt;
-
- ng = calloc (1, sizeof (*ng));
- if (ng == NULL)
- return NULL;
-
- pvt = calloc (1, sizeof (*pvt));
- if (pvt == NULL)
- {
- free (ng);
- return NULL;
- }
-
- pvt->state = NULL;
- ng->private = pvt;
- ng->close = ng_close;
- ng->next = ng_next;
- ng->test = ng_test;
- ng->rewind = ng_rewind;
- ng->minimize = ng_minimize;
- return ng;
-}
-
-#endif /*HAVE_IRS_H */
diff --git a/irs-network.c b/irs-network.c
deleted file mode 100644
index 4e5281a..0000000
--- a/irs-network.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/* Copyright (C) 1997-2005 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 1997.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_IRS_H
-
-#include <errno.h>
-#include "irs-nss.h"
-
-/* $Id$ */
-
-#ifdef HAVE_USERSEC_H
-void *nw_pvtinit (void);
-#endif
-IRS_EXPORT void nw_close (struct irs_nw *);
-IRS_EXPORT struct nwent *nw_byname (struct irs_nw *, const char *, int);
-IRS_EXPORT struct nwent *nw_byaddr (struct irs_nw *, void *, int, int);
-IRS_EXPORT struct nwent *nw_next (struct irs_nw *);
-IRS_EXPORT void nw_rewind (struct irs_nw *);
-IRS_EXPORT void nw_minimize (struct irs_nw *);
-
-struct pvt
-{
- struct nwent result;
- char buffer[NSS_BUFLEN_NETWORKS];
- ent_context_t *state;
-};
-
-IRS_EXPORT struct nwent *
-nw_byname (struct irs_nw *this, const char *name, int af)
-{
- NSS_STATUS s;
- struct pvt *pvt = (struct pvt *) this->private;
- ldap_args_t a;
-
- LA_INIT (a);
- LA_STRING (a) = name;
- LA_TYPE (a) = LA_TYPE_STRING;
-
- if (af != AF_INET)
- {
- h_errno = NETDB_INTERNAL;
- errno = EAFNOSUPPORT;
- return (NULL);
- }
-
- s = _nss_ldap_getbyname (&a,
- &pvt->result,
- pvt->buffer,
- sizeof (pvt->buffer),
- &errno,
- _nss_ldap_filt_getnetbyname,
- LM_NETWORKS, _nss_ldap_parse_net);
-
- if (s != NSS_SUCCESS)
- {
- MAP_H_ERRNO (s, h_errno);
- return NULL;
- }
- return &pvt->result;
-}
-
-IRS_EXPORT struct nwent *
-nw_byaddr (struct irs_nw *this, void *net, int length, int af)
-{
- ldap_args_t a;
- NSS_STATUS s;
- struct pvt *pvt = (struct pvt *) this->private;
- char tmp[sizeof "255.255.255.255/32"], *t;
-
- if (af != AF_INET)
- {
- h_errno = NETDB_INTERNAL;
- errno = EAFNOSUPPORT;
- return (NULL);
- }
-
- /* Try it with /CIDR first. */
- if (inet_net_ntop (AF_INET, net, length, tmp, sizeof tmp) == NULL)
- {
- h_errno = NETDB_INTERNAL;
- return (NULL);
- }
-
- LA_INIT (a);
- LA_STRING (a) = tmp;
- LA_TYPE (a) = LA_TYPE_STRING;
-
- s = _nss_ldap_getbyname (&a,
- &pvt->result,
- pvt->buffer,
- sizeof (pvt->buffer),
- &errno,
- _nss_ldap_filt_getnetbyaddr,
- LM_NETWORKS, _nss_ldap_parse_net);
-
- if (s != NSS_SUCCESS)
- {
- if ((t = strchr (tmp, '/')) != NULL)
- {
- *t = '\0';
- s = _nss_ldap_getbyname (&a,
- &pvt->result,
- pvt->buffer,
- sizeof (pvt->buffer),
- &errno,
- _nss_ldap_filt_getnetbyaddr,
- LM_NETWORKS, _nss_ldap_parse_net);
- if (s != NSS_SUCCESS)
- {
- MAP_H_ERRNO (s, h_errno);
- return (NULL);
- }
- }
- }
-
- return &pvt->result;
-}
-
-IRS_EXPORT void
-nw_close (struct irs_nw *this)
-{
- LOOKUP_ENDENT (this);
-#ifdef HAVE_USERSEC_H
- free (this->private);
- free (this);
-#endif
-}
-
-IRS_EXPORT struct nwent *
-nw_next (struct irs_nw *this)
-{
- struct pvt *pvt = (struct pvt *) this->private;
- NSS_STATUS s;
-
- s = _nss_ldap_getent (&pvt->state,
- &pvt->result,
- pvt->buffer,
- sizeof (pvt->buffer),
- &errno,
- _nss_ldap_filt_getnetent,
- LM_NETWORKS, _nss_ldap_parse_net);
-
- if (s != NSS_SUCCESS)
- {
- MAP_H_ERRNO (s, h_errno);
- return NULL;
- }
- return &pvt->result;
-}
-
-IRS_EXPORT void
-nw_rewind (struct irs_nw *this)
-{
- LOOKUP_SETENT (this);
-}
-
-IRS_EXPORT void
-nw_minimize (struct irs_nw *this)
-{
-}
-
-#ifdef HAVE_USERSEC_H
-void *
-nw_pvtinit (void)
-#else
-struct irs_nw *
-irs_ldap_nw (struct irs_acc *this)
-#endif
-{
- struct irs_nw *nw;
- struct pvt *pvt;
-
- nw = calloc (1, sizeof (*nw));
- if (nw == NULL)
- return NULL;
-
- pvt = calloc (1, sizeof (*pvt));
- if (pvt == NULL)
- {
- free (nw);
- return NULL;
- }
-
- pvt->state = NULL;
- nw->private = pvt;
- nw->close = nw_close;
- nw->next = nw_next;
- nw->byname = nw_byname;
-/* nw->byname2 = nw_byname2; */
- nw->byaddr = nw_byaddr;
- nw->rewind = nw_rewind;
- nw->minimize = nw_minimize;
- return nw;
-}
-
-#endif /*HAVE_IRS_H */
diff --git a/irs-nss.c b/irs-nss.c
deleted file mode 100644
index 2e79e1e..0000000
--- a/irs-nss.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright (C) 1997-2005 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 1997.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-static char rcsId[] = "$Id$";
-
-#include "config.h"
-
-#ifdef HAVE_IRS_H
-
-#ifndef HAVE_USERSEC_H
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-
-#ifdef HAVE_LBER_H
-#include <lber.h>
-#endif
-
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
-#include "irs-nss.h"
-#include "ldap-nss.h"
-#include "ltf.h"
-#include "util.h"
-
-static void irs_ldap_close (struct irs_acc *this);
-
-/* Dispatch table for IRS LDAP module */
-
-struct irs_acc *
-irs_ldap_acc (const char *options)
-{
- struct irs_acc *acc;
-
- if (!(acc = malloc (sizeof (*acc))))
- {
- errno = ENOMEM;
- return NULL;
- }
-
- memset (acc, 0x5e, sizeof *acc);
-
- /* private stuff gets kept as static in ldap-nss.c. */
- acc->private = NULL;
-
- acc->gr_map = irs_ldap_gr;
-#ifdef WANT_IRS_PW
- acc->pw_map = irs_ldap_pw;
-#endif
- acc->sv_map = irs_ldap_sv;
- acc->pr_map = irs_ldap_pr;
- acc->ho_map = irs_ldap_ho;
- acc->nw_map = irs_ldap_nw;
- acc->ng_map = irs_ldap_ng;
-
- acc->close = irs_ldap_close;
-
- return (acc);
-}
-
-/* Methods */
-
-static void
-irs_ldap_close (struct irs_acc *this)
-{
- free (this);
-}
-#endif /* HAVE_USERSEC_H */
-#endif /* HAVE_IRS_H */
diff --git a/irs-nss.h b/irs-nss.h
deleted file mode 100644
index f16124d..0000000
--- a/irs-nss.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (C) 1997-2005 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 1997.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- $Id$
- */
-
-#ifndef _LDAP_NSS_LDAP_IRS_H
-#define _LDAP_NSS_LDAP_IRS_H
-
-#ifdef HAVE_IRS_H
-/*
- * This header is only needed when using the BSD Information
- * Retrieval Service. It is not necessary for the Solaris or
- * GNU nameservice switch modules.
- */
-#include <irs.h>
-#endif
-
-struct irs_gr *irs_ldap_gr __P ((struct irs_acc *));
-struct irs_pw *irs_ldap_pw __P ((struct irs_acc *));
-struct irs_sv *irs_ldap_sv __P ((struct irs_acc *));
-struct irs_pr *irs_ldap_pr __P ((struct irs_acc *));
-struct irs_ho *irs_ldap_ho __P ((struct irs_acc *));
-struct irs_nw *irs_ldap_nw __P ((struct irs_acc *));
-/* not done yet */
-struct irs_ng *irs_ldap_ng __P ((struct irs_acc *));
-
-/* Keep namespace clean. */
-#define irs_ldap_acc __irs_ldap_acc
-
-struct irs_acc *irs_ldap_acc __P ((const char *));
-
-#define make_group_list __make_group_list
-
-extern int make_group_list (struct irs_gr *, const char *,
- gid_t, gid_t *, int *);
-
-#ifdef HAVE_USERSEC_H /* aka AIX */
-#define IRS_EXPORT
-#else
-#define IRS_EXPORT static
-#endif
-
-#endif /* _LDAP_NSS_LDAP_IRS_H */
diff --git a/irs-proto.c b/irs-proto.c
deleted file mode 100644
index ce1ccca..0000000
--- a/irs-proto.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* Copyright (C) 1997-2005 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 1997.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_IRS_H
-
-#include <errno.h>
-#include "irs-nss.h"
-
-/* $Id$ */
-
-#ifdef HAVE_USERSEC_H
-void *pr_pvtinit (void);
-#endif
-IRS_EXPORT void pr_close (struct irs_pr *);
-IRS_EXPORT struct protoent *pr_byname (struct irs_pr *, const char *);
-IRS_EXPORT struct protoent *pr_bynumber (struct irs_pr *, int);
-IRS_EXPORT struct protoent *pr_next (struct irs_pr *);
-IRS_EXPORT void pr_rewind (struct irs_pr *);
-IRS_EXPORT void pr_minimize (struct irs_pr *);
-
-struct pvt
-{
- struct protoent result;
- char buffer[NSS_BUFLEN_PROTOCOLS];
- ent_context_t *state;
-};
-
-IRS_EXPORT struct protoent *
-pr_byname (struct irs_pr *this, const char *name)
-{
- LOOKUP_NAME (name, this, _nss_ldap_filt_getprotobyname, LM_PROTOCOLS,
- _nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
-}
-
-IRS_EXPORT struct protoent *
-pr_bynumber (struct irs_pr *this, int num)
-{
- LOOKUP_NUMBER (num, this, _nss_ldap_filt_getprotobynumber, LM_PROTOCOLS,
- _nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
-}
-
-IRS_EXPORT void
-pr_close (struct irs_pr *this)
-{
- LOOKUP_ENDENT (this);
-#ifdef HAVE_USERSEC_H
- free (this->private);
- free (this);
-#endif
-}
-
-IRS_EXPORT struct protoent *
-pr_next (struct irs_pr *this)
-{
- LOOKUP_GETENT (this, _nss_ldap_filt_getprotoent, LM_PROTOCOLS,
- _nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
-}
-
-IRS_EXPORT void
-pr_rewind (struct irs_pr *this)
-{
- LOOKUP_SETENT (this);
-}
-
-IRS_EXPORT void
-pr_minimize (struct irs_pr *this)
-{
-}
-
-#ifdef HAVE_USERSEC_H
-void *
-pr_pvtinit (void)
-#else
-struct irs_pr *
-irs_ldap_pr (struct irs_acc *this)
-#endif
-{
- struct irs_pr *pr;
- struct pvt *pvt;
-
- pr = calloc (1, sizeof (*pr));
- if (pr == NULL)
- return NULL;
-
- pvt = calloc (1, sizeof (*pvt));
- if (pvt == NULL)
- {
- free (pr);
- return NULL;
- }
-
- pvt->state = NULL;
- pr->private = pvt;
- pr->close = pr_close;
- pr->next = pr_next;
- pr->byname = pr_byname;
- pr->bynumber = pr_bynumber;
- pr->rewind = pr_rewind;
- pr->minimize = pr_minimize;
- return pr;
-}
-
-#endif /*HAVE_IRS_H */
diff --git a/irs-pwd.c b/irs-pwd.c
deleted file mode 100644
index a8ea043..0000000
--- a/irs-pwd.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* Copyright (C) 1997-2005 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 1997.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_IRS_H
-
-#include <errno.h>
-#include "irs-nss.h"
-
-/* $Id$ */
-
-#ifdef HAVE_USERSEC_H
-void *pw_pvtinit (void);
-#endif
-IRS_EXPORT void pw_close (struct irs_pw *);
-IRS_EXPORT struct passwd *pw_next (struct irs_pw *);
-IRS_EXPORT struct passwd *pw_byname (struct irs_pw *, const char *);
-IRS_EXPORT struct passwd *pw_byuid (struct irs_pw *, uid_t);
-IRS_EXPORT void pw_rewind (struct irs_pw *);
-IRS_EXPORT void pw_minimize (struct irs_pw *);
-
-struct pvt
-{
- struct passwd result;
- char buffer[NSS_BUFLEN_PASSWD];
- ent_context_t *state;
-};
-
-IRS_EXPORT struct passwd *
-pw_byname (struct irs_pw *this, const char *name)
-{
- LOOKUP_NAME (name, this, _nss_ldap_filt_getpwnam, LM_PASSWD,
- _nss_ldap_parse_pw, LDAP_NSS_BUFLEN_DEFAULT);
-}
-
-IRS_EXPORT struct passwd *
-pw_byuid (struct irs_pw *this, uid_t uid)
-{
- LOOKUP_NUMBER (uid, this, _nss_ldap_filt_getpwuid, LM_PASSWD,
- _nss_ldap_parse_pw, LDAP_NSS_BUFLEN_DEFAULT);
-}
-
-IRS_EXPORT void
-pw_close (struct irs_pw *this)
-{
- LOOKUP_ENDENT (this);
-#ifdef HAVE_USERSEC_H
- free (this->private);
- free (this);
-#endif
-}
-
-IRS_EXPORT struct passwd *
-pw_next (struct irs_pw *this)
-{
- LOOKUP_GETENT (this, _nss_ldap_filt_getpwent, LM_PASSWD,
- _nss_ldap_parse_pw, LDAP_NSS_BUFLEN_DEFAULT);
-}
-
-IRS_EXPORT void
-pw_rewind (struct irs_pw *this)
-{
- LOOKUP_SETENT (this);
-}
-
-IRS_EXPORT void
-pw_minimize (struct irs_pw *this)
-{
-}
-
-#ifdef HAVE_USERSEC_H
-void *
-pw_pvtinit (void)
-#else
-struct irs_pw *
-irs_ldap_pw (struct irs_acc *this)
-#endif
-{
- struct irs_pw *pw;
- struct pvt *pvt;
-
- pw = calloc (1, sizeof (*pw));
- if (pw == NULL)
- return NULL;
-
- pvt = calloc (1, sizeof (*pvt));
- if (pvt == NULL)
- {
- free (pw);
- return NULL;
- }
-
- pvt->state = NULL;
- pw->private = pvt;
- pw->close = pw_close;
- pw->next = pw_next;
- pw->byname = pw_byname;
- pw->byuid = pw_byuid;
- pw->rewind = pw_rewind;
- pw->minimize = pw_minimize;
- return pw;
-}
-
-#endif /*HAVE_IRS_H */
diff --git a/irs-service.c b/irs-service.c
deleted file mode 100644
index bddb8c0..0000000
--- a/irs-service.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* Copyright (C) 1997-2005 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 1997.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_IRS_H
-
-#include <errno.h>
-#include "irs-nss.h"
-
-/* $Id$ */
-
-#ifdef HAVE_USERSEC_H
-void *sv_pvtinit (void);
-#endif
-IRS_EXPORT void sv_close (struct irs_sv *);
-IRS_EXPORT struct servent *sv_next (struct irs_sv *);
-IRS_EXPORT struct servent *sv_byname (struct irs_sv *, const char *,
- const char *);
-IRS_EXPORT struct servent *sv_byport (struct irs_sv *, int, const char *);
-IRS_EXPORT void sv_rewind (struct irs_sv *);
-IRS_EXPORT void sv_minimize (struct irs_sv *);
-
-struct pvt
-{
- struct servent result;
- char buffer[NSS_BUFLEN_SERVICES];
- ent_context_t *state;
-};
-
-IRS_EXPORT struct servent *
-sv_byname (struct irs_sv *this, const char *name, const char *proto)
-{
- ldap_args_t a;
- struct pvt *pvt = (struct pvt *) this->private;
- NSS_STATUS s;
-
- LA_INIT (a);
- LA_STRING (a) = name;
- LA_TYPE (a) = (proto == NULL) ? LA_TYPE_STRING : LA_TYPE_STRING_AND_STRING;
- LA_STRING2 (a) = proto;
- s =
- _nss_ldap_getbyname (&a, &pvt->result, pvt->buffer, sizeof (pvt->buffer),
- &errno,
- (proto ==
- NULL) ? _nss_ldap_filt_getservbyname :
- _nss_ldap_filt_getservbynameproto,
- LM_SERVICES, _nss_ldap_parse_serv);
-
- if (s != NSS_SUCCESS)
- {
- MAP_ERRNO (s, errno);
- return NULL;
- }
- return &pvt->result;
-}
-
-IRS_EXPORT struct servent *
-sv_byport (struct irs_sv *this, int port, const char *proto)
-{
- ldap_args_t a;
- struct pvt *pvt = (struct pvt *) this->private;
- NSS_STATUS s;
-
- LA_INIT (a);
- LA_NUMBER (a) = port;
- LA_TYPE (a) = (proto == NULL) ? LA_TYPE_NUMBER : LA_TYPE_NUMBER_AND_STRING;
- LA_STRING2 (a) = proto;
- s =
- _nss_ldap_getbyname (&a, &pvt->result, pvt->buffer, sizeof (pvt->buffer),
- &errno,
- (proto ==
- NULL) ? _nss_ldap_filt_getservbyport :
- _nss_ldap_filt_getservbyportproto,
- LM_SERVICES, _nss_ldap_parse_serv);
-
- if (s != NSS_SUCCESS)
- {
- MAP_ERRNO (s, errno);
- return NULL;
- }
- return &pvt->result;
-}
-
-IRS_EXPORT void
-sv_close (struct irs_sv *this)
-{
- LOOKUP_ENDENT (this);
-#ifdef HAVE_USERSEC_H
- free (this->private);
- free (this);
-#endif
-}
-
-IRS_EXPORT struct servent *
-sv_next (struct irs_sv *this)
-{
- LOOKUP_GETENT (this, _nss_ldap_filt_getservent, LM_SERVICES,
- _nss_ldap_parse_serv, LDAP_NSS_BUFLEN_DEFAULT);
-}
-
-IRS_EXPORT void
-sv_rewind (struct irs_sv *this)
-{
- LOOKUP_SETENT (this);
-}
-
-IRS_EXPORT void
-sv_minimize (struct irs_sv *this)
-{
-}
-
-#ifdef HAVE_USERSEC_H
-void *
-sv_pvtinit (void)
-#else
-struct irs_sv *
-irs_ldap_sv (struct irs_acc *this)
-#endif
-{
- struct irs_sv *sv;
- struct pvt *pvt;
-
- sv = calloc (1, sizeof (*sv));
- if (sv == NULL)
- return NULL;
-
- pvt = calloc (1, sizeof (*pvt));
- if (pvt == NULL)
- {
- free (sv);
- return NULL;
- }
-
- pvt->state = NULL;
- sv->private = pvt;
- sv->close = sv_close;
- sv->next = sv_next;
- sv->byname = sv_byname;
- sv->byport = sv_byport;
- sv->rewind = sv_rewind;
- sv->minimize = sv_minimize;
- return sv;
-}
-
-#endif /*HAVE_IRS_H */
diff --git a/irs.h b/irs.h
deleted file mode 100644
index 3fc8c80..0000000
--- a/irs.h
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (c) 1996,1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-/*
- * $Id$
- */
-
-#ifndef _IRS_H_INCLUDED
-#define _IRS_H_INCLUDED
-
-#include <sys/types.h>
-
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/nameser.h>
-
-#include <grp.h>
-#include <netdb.h>
-
-#include <resolv.h>
-#include <pwd.h>
-
-#ifndef __P
-# if defined(__STDC__) || defined(__GNUC__)
-# define __P(x) x
-# else
-# define __P(x) ()
-# endif
-#endif
-
-/*
- * This is the group map class.
- */
-struct irs_gr {
- void * private;
- void (*close) __P((struct irs_gr *));
- struct group * (*next) __P((struct irs_gr *));
- struct group * (*byname) __P((struct irs_gr *, const char *));
- struct group * (*bygid) __P((struct irs_gr *, gid_t));
- int (*list) __P((struct irs_gr *, const char *,
- gid_t, gid_t *, int *));
- void (*rewind) __P((struct irs_gr *));
- void (*minimize) __P((struct irs_gr *));
- struct __res_state * (*res_get) __P((struct irs_gr *));
- void (*res_set) __P((struct irs_gr *, struct __res_state *,
- void (*)(void *)));
-};
-
-/*
- * This is the password map class.
- */
-struct irs_pw {
- void * private;
- void (*close) __P((struct irs_pw *));
- struct passwd * (*next) __P((struct irs_pw *));
- struct passwd * (*byname) __P((struct irs_pw *, const char *));
- struct passwd * (*byuid) __P((struct irs_pw *, uid_t));
- void (*rewind) __P((struct irs_pw *));
- void (*minimize) __P((struct irs_pw *));
- struct __res_state * (*res_get) __P((struct irs_pw *));
- void (*res_set) __P((struct irs_pw *, struct __res_state *,
- void (*)(void *)));
-};
-
-/*
- * This is the service map class.
- */
-struct irs_sv {
- void * private;
- void (*close) __P((struct irs_sv *));
- struct servent *(*byname) __P((struct irs_sv *,
- const char *, const char *));
- struct servent *(*byport) __P((struct irs_sv *, int, const char *));
- struct servent *(*next) __P((struct irs_sv *));
- void (*rewind) __P((struct irs_sv *));
- void (*minimize) __P((struct irs_sv *));
- struct __res_state * (*res_get) __P((struct irs_sv *));
- void (*res_set) __P((struct irs_sv *, struct __res_state *,
- void (*)(void *)));
-};
-
-/*
- * This is the protocols map class.
- */
-struct irs_pr {
- void * private;
- void (*close) __P((struct irs_pr *));
- struct protoent *(*byname) __P((struct irs_pr *, const char *));
- struct protoent *(*bynumber) __P((struct irs_pr *, int));
- struct protoent *(*next) __P((struct irs_pr *));
- void (*rewind) __P((struct irs_pr *));
- void (*minimize) __P((struct irs_pr *));
- struct __res_state * (*res_get) __P((struct irs_pr *));
- void (*res_set) __P((struct irs_pr *, struct __res_state *,
- void (*)(void *)));
-};
-
-/*
- * This is the hosts map class.
- */
-struct irs_ho {
- void * private;
- void (*close) __P((struct irs_ho *));
- struct hostent *(*byname) __P((struct irs_ho *, const char *));
- struct hostent *(*byname2) __P((struct irs_ho *, const char *, int));
- struct hostent *(*byaddr) __P((struct irs_ho *,
- const void *, int, int));
- struct hostent *(*next) __P((struct irs_ho *));
- void (*rewind) __P((struct irs_ho *));
- void (*minimize) __P((struct irs_ho *));
- struct __res_state * (*res_get) __P((struct irs_ho *));
- void (*res_set) __P((struct irs_ho *, struct __res_state *,
- void (*)(void *)));
-};
-
-/*
- * This is the networks map class.
- */
-struct irs_nw {
- void * private;
- void (*close) __P((struct irs_nw *));
- struct nwent * (*byname) __P((struct irs_nw *, const char *, int));
- struct nwent * (*byaddr) __P((struct irs_nw *, void *, int, int));
- struct nwent * (*next) __P((struct irs_nw *));
- void (*rewind) __P((struct irs_nw *));
- void (*minimize) __P((struct irs_nw *));
- struct __res_state * (*res_get) __P((struct irs_nw *));
- void (*res_set) __P((struct irs_nw *, struct __res_state *,
- void (*)(void *)));
-};
-
-/*
- * This is the netgroups map class.
- */
-struct irs_ng {
- void * private;
- void (*close) __P((struct irs_ng *));
- int (*next) __P((struct irs_ng *, char **, char **,
- char **));
- int (*test) __P((struct irs_ng *, const char *,
- const char *, const char *,
- const char *));
- void (*rewind) __P((struct irs_ng *, const char *));
- void (*minimize) __P((struct irs_ng *));
-};
-
-/*
- * This is the generic map class, which copies the front of all others.
- */
-struct irs_map {
- void * private;
- void (*close) __P((void *));
-};
-
-/*
- * This is the accessor class. It contains pointers to all of the
- * initializers for the map classes for a particular accessor.
- */
-struct irs_acc {
- void * private;
- void (*close) __P((struct irs_acc *));
- struct irs_gr * (*gr_map) __P((struct irs_acc *));
- struct irs_pw * (*pw_map) __P((struct irs_acc *));
- struct irs_sv * (*sv_map) __P((struct irs_acc *));
- struct irs_pr * (*pr_map) __P((struct irs_acc *));
- struct irs_ho * (*ho_map) __P((struct irs_acc *));
- struct irs_nw * (*nw_map) __P((struct irs_acc *));
- struct irs_ng * (*ng_map) __P((struct irs_acc *));
- struct __res_state * (*res_get) __P((struct irs_acc *));
- void (*res_set) __P((struct irs_acc *, struct __res_state *,
- void (*)(void *)));
-};
-
-/*
- * This is because the official definition of "struct netent" has no
- * concept of CIDR even though it allows variant address families (on
- * output but not input). The compatibility stubs convert the structs
- * below into "struct netent"'s.
- */
-struct nwent {
- char *n_name; /* official name of net */
- char **n_aliases; /* alias list */
- int n_addrtype; /* net address type */
- void *n_addr; /* network address */
- int n_length; /* address length, in bits */
-};
-
-/*
- * Hide external function names from POSIX.
- */
-#define irs_gen_acc __irs_gen_acc
-#define irs_lcl_acc __irs_lcl_acc
-#define irs_dns_acc __irs_dns_acc
-#define irs_nis_acc __irs_nis_acc
-#define irs_irp_acc __irs_irp_acc
-
-/*
- * Externs.
- */
-extern struct irs_acc * irs_gen_acc __P((const char *options,
- const char *conf_file));
-extern struct irs_acc * irs_lcl_acc __P((const char *options));
-extern struct irs_acc * irs_dns_acc __P((const char *options));
-extern struct irs_acc * irs_nis_acc __P((const char *options));
-extern struct irs_acc * irs_irp_acc __P((const char *options));
-
-/*
- * These forward declarations are for the semi-private functions in
- * the get*.c files. Each of these funcs implements the real get*
- * functionality and the standard versions are just wrappers that
- * call these. Apart from the wrappers, only irpd is expected to
- * call these directly, hence these decls are put here and not in
- * the /usr/include replacements.
- */
-
-struct net_data; /* forward */
-
-/*
- * net_data_create gets a singleton net_data object. net_data_init
- * creates as many net_data objects as times it is called. Clients using
- * the default interface will use net_data_create by default. Servers will
- * probably want net_data_init (one call per client)
- */
-struct net_data *net_data_create(const char *conf_file);
-struct net_data *net_data_init(const char *conf_file);
-void net_data_destroy(void *p);
-
-extern struct group *getgrent_p __P((struct net_data *net_data));
-extern struct group *getgrnam_p __P((const char *name,
- struct net_data *net_data));
-extern struct group *getgrgid_p __P((gid_t gid,
- struct net_data *net_data));
-extern int setgroupent_p __P((int stayopen,
- struct net_data *net_data));
-extern void endgrent_p __P((struct net_data *net_data));
-extern int getgrouplist_p __P((const char *name,
- gid_t basegid,
- gid_t *groups,
- int *ngroups,
- struct net_data *net_data));
-
-#ifdef SETGRENT_VOID
-extern void setgrent_p __P((struct net_data *net_data));
-#else
-extern int setgrent_p __P((struct net_data *net_data));
-#endif
-
-extern struct hostent *gethostbyname_p __P((const char *name,
- struct net_data *net_data));
-extern struct hostent *gethostbyname2_p __P((const char *name, int af,
- struct net_data *net_data));
-extern struct hostent *gethostbyaddr_p __P((const char *addr, int len,
- int af,
- struct net_data *net_data));
-extern struct hostent *gethostent_p __P((struct net_data *net_data));
-extern void sethostent_p __P((int stayopen,
- struct net_data *net_data));
-extern void endhostent_p __P((struct net_data *net_data));
-
-extern struct netent *getnetent_p __P((struct net_data *net_data));
-extern struct netent *getnetbyname_p __P((const char *name,
- struct net_data *net_data));
-extern struct netent *getnetbyaddr_p __P((unsigned long net, int type,
- struct net_data *net_data));
-extern void setnetent_p __P((int stayopen,
- struct net_data *net_data));
-extern void endnetent_p __P((struct net_data *net_data));
-
-extern void setnetgrent_p __P((const char *netgroup,
- struct net_data *net_data));
-extern void endnetgrent_p __P((struct net_data *net_data));
-extern int innetgr_p __P((const char *netgroup,
- const char *host,
- const char *user,
- const char *domain,
- struct net_data *net_data));
-extern int getnetgrent_p __P((char **host, char **user,
- char **domain,
- struct net_data *net_data));
-
-extern struct protoent *getprotoent_p __P((struct net_data *net_data));
-extern struct protoent *getprotobyname_p __P((const char *name,
- struct net_data *net_data));
-extern struct protoent *getprotobynumber_p __P((int proto,
- struct net_data *net_data));
-extern void setprotoent_p __P((int stayopen,
- struct net_data *net_data));
-extern void endprotoent_p __P((struct net_data *net_data));
-
-
-extern struct passwd *getpwent_p __P((struct net_data *net_data));
-extern struct passwd *getpwnam_p __P((const char *name,
- struct net_data *net_data));
-extern struct passwd *getpwuid_p __P((uid_t uid,
- struct net_data *net_data));
-extern int setpassent_p __P((int stayopen,
- struct net_data *net_data));
-extern void endpwent_p __P((struct net_data *net_data));
-
-#ifdef SETPWENT_VOID
-extern void setpwent_p __P((struct net_data *net_data));
-#else
-extern int setpwent_p __P((struct net_data *net_data));
-#endif
-
-extern struct servent *getservent_p __P((struct net_data *net_data));
-extern struct servent *getservbyname_p __P((const char *name,
- const char *proto,
- struct net_data *net_data));
-extern struct servent *getservbyport_p __P((int port, const char *proto,
- struct net_data *net_data));
-extern void setservent_p __P((int stayopen,
- struct net_data *net_data));
-extern void endservent_p __P((struct net_data *net_data));
-
-#endif /*_IRS_H_INCLUDED*/
diff --git a/ldap-alias.c b/ldap-alias.c
index 6de3fd4..a57d6c2 100644
--- a/ldap-alias.c
+++ b/ldap-alias.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,11 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
-
-
-static char rcsId[] =
- "$Id$";
+*/
#include "config.h"
@@ -53,17 +50,16 @@ static char rcsId[] =
#include <port_after.h>
#endif
-#ifdef HAVE_NSS_H
static ent_context_t *alias_context = NULL;
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_alias (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
{
struct aliasent *alias = (struct aliasent *) result;
- NSS_STATUS stat;
+ enum nss_status stat;
stat =
_nss_ldap_getrdnvalue (e, ATM (LM_ALIASES, cn), &alias->alias_name,
@@ -81,7 +77,7 @@ _nss_ldap_parse_alias (LDAPMessage * e,
return stat;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_getaliasbyname_r (const char *name, struct aliasent * result,
char *buffer, size_t buflen, int *errnop)
{
@@ -90,17 +86,17 @@ _nss_ldap_getaliasbyname_r (const char *name, struct aliasent * result,
_nss_ldap_parse_alias, LDAP_NSS_BUFLEN_DEFAULT);
}
-NSS_STATUS _nss_ldap_setaliasent (void)
+enum nss_status _nss_ldap_setaliasent (void)
{
LOOKUP_SETENT (alias_context);
}
-NSS_STATUS _nss_ldap_endaliasent (void)
+enum nss_status _nss_ldap_endaliasent (void)
{
LOOKUP_ENDENT (alias_context);
}
-NSS_STATUS
+enum nss_status
_nss_ldap_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen,
int *errnop)
{
@@ -109,5 +105,4 @@ _nss_ldap_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen,
_nss_ldap_parse_alias, LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif /* HAVE_NSS_H */
#endif /* HAVE_ALIASES_H */
diff --git a/ldap-alias.h b/ldap-alias.h
index 6bdedb5..991b46f 100644
--- a/ldap-alias.h
+++ b/ldap-alias.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,31 +19,14 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_ALIAS_H
#define _LDAP_NSS_LDAP_LDAP_ALIAS_H
-static NSS_STATUS _nss_ldap_parse_alias (LDAPMessage * e,
+static enum nss_status _nss_ldap_parse_alias (LDAPMessage * e,
ldap_state_t *,
void *result,
char *buffer, size_t buflen);
-#if 0
-/* no support in Sun NSS for aliases */
-
-static NSS_STATUS _nss_ldap_getaliasbyname_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_getaliasent_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_setaliasent (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_endaliasent (nss_backend_t * be,
- void *fakeargs);
-
-nss_backend_t *_nss_ldap_alias_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-#endif
-
#endif /* _LDAP_NSS_LDAP_LDAP_ALIAS_H */
diff --git a/ldap-automount.c b/ldap-automount.c
index ea462d7..5889d19 100644
--- a/ldap-automount.c
+++ b/ldap-automount.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2005 Luke Howard.
+/*
+ Copyright (C) 2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 2005.
@@ -18,10 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
-
-
-static char rcsId[] = "$Id$";
+*/
#include "config.h"
@@ -59,12 +57,12 @@ static char rcsId[] = "$Id$";
#include <port_after.h>
#endif
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_automount (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
{
- NSS_STATUS stat;
+ enum nss_status stat;
char ***keyval = result;
stat =
@@ -82,7 +80,7 @@ _nss_ldap_parse_automount (LDAPMessage * e,
return NSS_SUCCESS;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_am_context_alloc(ldap_automount_context_t **pContext)
{
ldap_automount_context_t *context;
@@ -158,7 +156,7 @@ _nss_ldap_am_context_free(ldap_automount_context_t **pContext)
return;
}
-static NSS_STATUS
+static enum nss_status
am_context_add_dn (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
@@ -197,10 +195,10 @@ am_context_add_dn (LDAPMessage * e,
return NSS_SUCCESS;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_am_context_init(const char *mapname, ldap_automount_context_t **pContext)
{
- NSS_STATUS stat;
+ enum nss_status stat;
ldap_automount_context_t *context = NULL;
const char *no_attrs[] = { NULL };
ldap_args_t a;
@@ -251,11 +249,10 @@ _nss_ldap_am_context_init(const char *mapname, ldap_automount_context_t **pConte
return NSS_SUCCESS;
}
-#ifdef HAVE_NSS_H
-NSS_STATUS _nss_ldap_setautomntent(const char *mapname, void **private)
+enum nss_status _nss_ldap_setautomntent(const char *mapname, void **private)
{
ldap_automount_context_t *context = NULL;
- NSS_STATUS stat;
+ enum nss_status stat;
debug ("==> _nss_ldap_setautomntent");
@@ -285,10 +282,10 @@ NSS_STATUS _nss_ldap_setautomntent(const char *mapname, void **private)
return stat;
}
-NSS_STATUS _nss_ldap_getautomntent_r(void *private, const char **key, const char **value,
+enum nss_status _nss_ldap_getautomntent_r(void *private, const char **key, const char **value,
char *buffer, size_t buflen, int *errnop)
{
- NSS_STATUS stat;
+ enum nss_status stat;
ldap_automount_context_t *context = (ldap_automount_context_t *)private;
ldap_args_t a;
char **keyval[2];
@@ -335,7 +332,7 @@ NSS_STATUS _nss_ldap_getautomntent_r(void *private, const char **key, const char
return stat;
}
-NSS_STATUS _nss_ldap_endautomntent(void **private)
+enum nss_status _nss_ldap_endautomntent(void **private)
{
ldap_automount_context_t **pContext = (ldap_automount_context_t **)private;
@@ -352,11 +349,11 @@ NSS_STATUS _nss_ldap_endautomntent(void **private)
return NSS_SUCCESS;
}
-NSS_STATUS _nss_ldap_getautomntbyname_r(void *private, const char *key,
+enum nss_status _nss_ldap_getautomntbyname_r(void *private, const char *key,
const char **canon_key, const char **value,
char *buffer, size_t buflen, int *errnop)
{
- NSS_STATUS stat = NSS_NOTFOUND;
+ enum nss_status stat = NSS_NOTFOUND;
ldap_automount_context_t *context = (ldap_automount_context_t *)private;
ldap_args_t a;
char **keyval[2];
@@ -395,6 +392,3 @@ NSS_STATUS _nss_ldap_getautomntbyname_r(void *private, const char *key,
return stat;
}
-
-#endif /* HAVE_NSS_H */
-
diff --git a/ldap-automount.h b/ldap-automount.h
index df27c57..8a791a8 100644
--- a/ldap-automount.h
+++ b/ldap-automount.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2005 Luke Howard.
+/*
+ Copyright (C) 2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 2005.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_AUTOMOUNT_H
#define _LDAP_NSS_LDAP_LDAP_AUTOMOUNT_H
@@ -37,18 +38,15 @@ struct ldap_automount_context {
typedef struct ldap_automount_context ldap_automount_context_t;
-NSS_STATUS _nss_ldap_am_context_alloc(ldap_automount_context_t **pContext);
+enum nss_status _nss_ldap_am_context_alloc(ldap_automount_context_t **pContext);
void _nss_ldap_am_context_free(ldap_automount_context_t **pContext);
-NSS_STATUS _nss_ldap_am_context_init(const char *mapname, ldap_automount_context_t **pContext);
-
-#ifdef HAVE_NSS_H
-NSS_STATUS _nss_ldap_setautomntent(const char *mapname, void **context);
-NSS_STATUS _nss_ldap_getautomntent(void *context, const char **key, const char **value,
+enum nss_status _nss_ldap_am_context_init(const char *mapname, ldap_automount_context_t **pContext);
+enum nss_status _nss_ldap_setautomntent(const char *mapname, void **context);
+enum nss_status _nss_ldap_getautomntent(void *context, const char **key, const char **value,
char *buffer, size_t buflen, int *errnop);
-NSS_STATUS _nss_ldap_endautomntent(void **context);
-NSS_STATUS _nss_ldap_getautomntbyname_r(void *private, const char *key,
+enum nss_status _nss_ldap_endautomntent(void **context);
+enum nss_status _nss_ldap_getautomntbyname_r(void *private, const char *key,
const char **canon_key, const char **value,
char *buffer, size_t buflen, int *errnop);
-#endif /* HAVE_NSS_H */
#endif /* _LDAP_NSS_LDAP_LDAP_AUTOMOUNT_H */
diff --git a/ldap-bp.c b/ldap-bp.c
index e37b44d..49c73b0 100644
--- a/ldap-bp.c
+++ b/ldap-bp.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,10 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
-
-
-static char rcsId[] = "$Id$";
+*/
#include "config.h"
@@ -58,79 +56,3 @@ static char rcsId[] = "$Id$";
#include <port_after.h>
#endif
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
-
-#ifdef HAVE_NSS_H
-static ent_context_t *bp_context = NULL;
-#endif
-
-static NSS_STATUS
-_nss_ldap_parse_bp (LDAPMessage * e,
- ldap_state_t * pvt,
- void *result, char *buffer, size_t buflen)
-{
- struct bootparams *bp = (struct bootparams *) result;
- NSS_STATUS stat;
-
- stat =
- _nss_ldap_assign_attrval (e, ATM (LM_BOOTPARAMS, cn), &bp->bp_name,
- &buffer, &buflen);
- if (stat != NSS_SUCCESS)
- return stat;
-
- stat =
- _nss_ldap_assign_attrvals (e, AT (bootParameter), NULL,
- &bp->bp_params, &buffer, &buflen, NULL);
- if (stat != NSS_SUCCESS)
- return stat;
-
- return NSS_SUCCESS;
-}
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getbootparamsbyname_r (nss_backend_t * be, void *args)
-{
- LOOKUP_NAME (args, _nss_ldap_filt_getbootparamsbyname, LM_BOOTPARAMS,
- _nss_ldap_parse_bp, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_bootparams_destr (nss_backend_t * bp_context, void *args)
-{
- return _nss_ldap_default_destr (bp_context, args);
-}
-
-static nss_backend_op_t bp_ops[] = {
- _nss_ldap_bootparams_destr,
- _nss_ldap_getbootparamsbyname_r
-};
-
-nss_backend_t *
-_nss_ldap_bootparams_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_backend_t *be;
-
-/*
- if (!(be = (nss_ldap_backend_t *)malloc(sizeof(*be))))
- return NULL;
-
- be->ops = bp_ops;
- be->n_ops = sizeof(bp_ops) / sizeof(nss_backend_op_t);
-
- if (_nss_ldap_default_constr(be) != NSS_SUCCESS)
- return NULL;
-
- return (nss_backend_t *)be;
- */
-
- /* this is a noop until we figure it out properly */
- return NULL;
-}
-
-#endif /* HAVE_NSSWITCH_H */
-
-#endif /* !HAVE_IRS_H */
diff --git a/ldap-bp.h b/ldap-bp.h
index 2cb79e1..d7dcedc 100644
--- a/ldap-bp.h
+++ b/ldap-bp.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_BP_H
#define _LDAP_NSS_LDAP_LDAP_BP_H
@@ -31,27 +32,9 @@ struct bootparams
};
-static NSS_STATUS _nss_ldap_parse_bp (LDAPMessage * e,
+static enum nss_status _nss_ldap_parse_bp (LDAPMessage * e,
ldap_state_t * pvt,
void *result,
char *buffer, size_t buflen);
-#ifdef HAVE_NSSWITCH_H
-
-/*
- int parse_bootparams_entry(const char *bp_entry,
- char **bp_uniquehostname, char **bp_sharedhostname,
- char **bp_rootpath, char **bp_swappath, char **bp_dumppath,
- char **bp_execpath, char **bp_kvmpath);
- */
-
-static NSS_STATUS _nss_ldap_getbootparamsbyname_r (nss_backend_t * be,
- void *fakeargs);
-
-nss_backend_t *_nss_ldap_bootparams_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-
-#endif
-
#endif /* _LDAP_NSS_LDAP_LDAP_BP_H */
diff --git a/ldap-ethers.c b/ldap-ethers.c
index c91b814..ef97233 100644
--- a/ldap-ethers.c
+++ b/ldap-ethers.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,11 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
-
-
-static char rcsId[] =
- "$Id$";
+*/
#include "config.h"
@@ -77,33 +74,17 @@ static char rcsId[] =
#define NSS_BUFLEN_ETHERS 1024
#endif /* NSS_BUFLEN_ETHERS */
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
-#ifdef HAVE_NSSWITCH_H
-#ifdef HAVE_ETHER_ATON
-extern struct ether_addr *ether_aton (const char *s);
-#else
-static struct ether_addr *ether_aton (const char *s);
-#endif /* HAVE_ETHER_ATON */
-#ifdef HAVE_ETHER_NTOA
-extern char *ether_ntoa (const struct ether_addr *e);
-#else
-static char *ether_ntoa (const struct ether_addr *e);
-#endif /* HAVE_ETHER_NTOA */
-#endif /* HAVE_NSSWITCH_H */
-
-#ifdef HAVE_NSS_H
static ent_context_t *ether_context = NULL;
-#endif
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_ether (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
{
struct ether *ether = (struct ether *) result;
char *saddr;
- NSS_STATUS stat;
+ enum nss_status stat;
struct ether_addr *addr;
stat = _nss_ldap_assign_attrval (e, ATM (LM_ETHERS, cn),
@@ -122,38 +103,7 @@ _nss_ldap_parse_ether (LDAPMessage * e,
return NSS_SUCCESS;
}
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_gethostton_r (nss_backend_t * be, void *args)
-{
- struct ether result;
- ldap_args_t a;
- char buffer[NSS_BUFLEN_ETHERS];
- NSS_STATUS status;
-
- LA_INIT (a);
- LA_STRING (a) = NSS_ARGS (args)->key.name;
- LA_TYPE (a) = LA_TYPE_STRING;
-
- status = _nss_ldap_getbyname (&a,
- &result,
- buffer,
- sizeof (buffer),
- &NSS_ARGS (args)->erange,
- _nss_ldap_filt_gethostton,
- LM_ETHERS, _nss_ldap_parse_ether);
-
- if (status == NSS_SUCCESS)
- {
- memcpy (NSS_ARGS (args)->buf.result, &result.e_addr,
- sizeof (result.e_addr));
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result;
- }
-
- return status;
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_gethostton_r (const char *name, struct ether * result,
char *buffer, size_t buflen, int *errnop)
{
@@ -161,49 +111,8 @@ _nss_ldap_gethostton_r (const char *name, struct ether * result,
_nss_ldap_filt_gethostton, LM_ETHERS, _nss_ldap_parse_ether,
LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getntohost_r (nss_backend_t * be, void *args)
-{
- struct ether result;
- char *addr;
- ldap_args_t a;
- char buffer[NSS_BUFLEN_ETHERS];
- NSS_STATUS status;
-
- addr = ether_ntoa ((struct ether_addr *) (NSS_ARGS (args)->key.ether));
- LA_INIT (a);
- LA_STRING (a) = addr;
- LA_TYPE (a) = LA_TYPE_STRING;
-
- status = _nss_ldap_getbyname (&a,
- &result,
- buffer,
- sizeof (buffer),
- &NSS_ARGS (args)->erange,
- _nss_ldap_filt_getntohost,
- LM_ETHERS, _nss_ldap_parse_ether);
-
- if (status == NSS_SUCCESS)
- {
- memcpy (NSS_ARGS (args)->buf.buffer, result.e_name,
- strlen (result.e_name) + 1);
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result =
- NSS_ARGS (args)->buf.buffer;
- NSS_ARGS (args)->buf.buflen = strlen (result.e_name);
- }
- else
- {
- NSS_ARGS (args)->returnval = NULL;
- }
-
- return status;
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getntohost_r (struct ether_addr * addr, struct ether * result,
char *buffer, size_t buflen, int *errnop)
{
@@ -214,62 +123,18 @@ _nss_ldap_getntohost_r (struct ether_addr * addr, struct ether * result,
buffer, buflen, errnop, _nss_ldap_filt_getntohost, LM_ETHERS,
_nss_ldap_parse_ether, LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_setetherent_r (nss_backend_t * ether_context, void *fakeargs)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_setetherent (void)
-#endif
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
+ enum nss_status _nss_ldap_setetherent (void)
{
LOOKUP_SETENT (ether_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_endetherent_r (nss_backend_t * ether_context, void *fakeargs)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_endetherent (void)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+ enum nss_status _nss_ldap_endetherent (void)
{
LOOKUP_ENDENT (ether_context);
}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getetherent_r (nss_backend_t * ether_context, void *args)
-{
- struct ether result;
- NSS_STATUS status;
-
- status = _nss_ldap_getent (&((nss_ldap_backend_t *) ether_context)->state,
- &result,
- NSS_ARGS (args)->buf.buffer,
- NSS_ARGS (args)->buf.buflen,
- &NSS_ARGS (args)->erange,
- _nss_ldap_filt_getetherent,
- LM_ETHERS, _nss_ldap_parse_ether);
-
- if (status == NSS_SUCCESS)
- {
- memcpy (NSS_ARGS (args)->buf.result, &result.e_addr,
- sizeof (result.e_addr));
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result;
- }
- else
- {
- NSS_ARGS (args)->returnval = NULL;
- }
- return status;
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getetherent_r (struct ether * result, char *buffer, size_t buflen,
int *errnop)
{
@@ -277,76 +142,3 @@ _nss_ldap_getetherent_r (struct ether * result, char *buffer, size_t buflen,
_nss_ldap_filt_getetherent, LM_ETHERS,
_nss_ldap_parse_ether, LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_ethers_destr (nss_backend_t * ether_context, void *args)
-{
- return _nss_ldap_default_destr (ether_context, args);
-}
-
-static nss_backend_op_t ethers_ops[] = {
- _nss_ldap_ethers_destr,
- _nss_ldap_gethostton_r,
- _nss_ldap_getntohost_r
-};
-
-nss_backend_t *
-_nss_ldap_ethers_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_backend_t *be;
-
- if (!(be = (nss_ldap_backend_t *) malloc (sizeof (*be))))
- return NULL;
-
- be->ops = ethers_ops;
- be->n_ops = sizeof (ethers_ops) / sizeof (nss_backend_op_t);
-
- if (_nss_ldap_default_constr (be) != NSS_SUCCESS)
- return NULL;
-
- return (nss_backend_t *) be;
-
-}
-
-#endif /* !HAVE_NSS_H */
-
-#ifdef HAVE_NSSWITCH_H
-
-#ifndef HAVE_ETHER_ATON
-static struct ether_addr *ether_aton (const char *s)
-{
- static struct ether_addr ep;
- register int i;
- unsigned int t[6];
-
- i = sscanf(s, " %x:%x:%x:%x:%x:%x",
- &t[0], &t[1], &t[2], &t[3], &t[4], &t[5]);
- if (i != 6)
- return NULL;
- for (i = 0; i < 6; i++)
- ep.ether_addr_octet[i] = t[i];
-
- return &ep;
-}
-#endif /* !HAVE_ETHER_ATON */
-
-#ifndef HAVE_ETHER_NTOA
-#define EI(i) (unsigned int)(e->ether_addr_octet[(i)])
-static char *ether_ntoa (const struct ether_addr *e)
-{
- static char s[18];
-
- s[0] = 0;
- sprintf(s, "%x:%x:%x:%x:%x:%x",
- EI(0), EI(1), EI(2), EI(3), EI(4), EI(5));
-
- return s;
-}
-#endif /* !HAVE_ETHER_NTOA */
-
-#endif /* HAVE_NSSWITCH_H */
-
-#endif /* !HAVE_IRS_H */
diff --git a/ldap-ethers.h b/ldap-ethers.h
index 150ac9f..329209d 100644
--- a/ldap-ethers.h
+++ b/ldap-ethers.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_ETHERS_H
#define _LDAP_NSS_LDAP_LDAP_ETHERS_H
@@ -42,32 +43,20 @@ struct ether
struct ether_addr e_addr;
};
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
-static NSS_STATUS _nss_ldap_parse_ether (LDAPMessage * e,
+static enum nss_status _nss_ldap_parse_ether (LDAPMessage * e,
ldap_state_t * pvt,
void *result,
char *buffer, size_t buflen);
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS _nss_ldap_gethostton_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_getntohost_r (nss_backend_t * be, void *fakeargs);
-nss_backend_t *_nss_ldap_ethers_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-
-#elif defined(HAVE_NSS_H)
/* for the record */
-NSS_STATUS _nss_ldap_gethostton_r (const char *name, struct ether *eth,
+enum nss_status _nss_ldap_gethostton_r (const char *name, struct ether *eth,
char *buffer, size_t buflen, int *errnop);
-NSS_STATUS _nss_ldap_getntohost_r (struct ether_addr *addr, struct ether *eth,
+enum nss_status _nss_ldap_getntohost_r (struct ether_addr *addr, struct ether *eth,
char *buffer, size_t buflen, int *errnop);
-NSS_STATUS _nss_ldap_endetherent (void);
-NSS_STATUS _nss_ldap_setetherent (void);
-NSS_STATUS _nss_ldap_getetherent_r (struct ether *result, char *buffer,
+enum nss_status _nss_ldap_endetherent (void);
+enum nss_status _nss_ldap_setetherent (void);
+enum nss_status _nss_ldap_getetherent_r (struct ether *result, char *buffer,
size_t buflen, int *errnop);
-#endif
#endif /* _LDAP_NSS_LDAP_LDAP_ETHERS_H */
diff --git a/ldap-grp.c b/ldap-grp.c
index 0f9ea71..646109b 100644
--- a/ldap-grp.c
+++ b/ldap-grp.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2006 Luke Howard.
+/*
+ Copyright (C) 1997-2006 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -16,10 +17,9 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
-static char rcsId[] =
- "$Id$";
+ $Id$
+*/
#include "config.h"
@@ -47,10 +47,6 @@ static char rcsId[] =
#include <ldap.h>
#endif
-#ifndef HAVE_SNPRINTF
-#include "snprintf.h"
-#endif
-
#include "ldap-nss.h"
#include "ldap-grp.h"
#include "util.h"
@@ -59,9 +55,7 @@ static char rcsId[] =
#include <port_after.h>
#endif
-#ifdef HAVE_NSS_H
static ent_context_t *gr_context = NULL;
-#endif
#ifdef HAVE_USERSEC_H
typedef struct ldap_initgroups_args
@@ -74,16 +68,6 @@ typedef struct ldap_initgroups_args
}
ldap_initgroups_args_t;
#else
-# ifdef HAVE_NSSWITCH_H
-typedef struct ldap_initgroups_args
-{
- struct nss_groupsbymem *gbm;
- int depth;
- struct name_list *known_groups;
- int backlink;
-}
-ldap_initgroups_args_t;
-# else
typedef struct ldap_initgroups_args
{
gid_t group;
@@ -96,13 +80,12 @@ typedef struct ldap_initgroups_args
int backlink;
}
ldap_initgroups_args_t;
-# endif
#endif /* HAVE_USERSEC_H */
-static NSS_STATUS
+static enum nss_status
ng_chase (const char *dn, ldap_initgroups_args_t * lia);
-static NSS_STATUS
+static enum nss_status
ng_chase_backlink (const char ** membersOf, ldap_initgroups_args_t * lia);
/*
@@ -110,11 +93,11 @@ ng_chase_backlink (const char ** membersOf, ldap_initgroups_args_t * lia);
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/searching_using_range_retrieval.asp
*/
-static NSS_STATUS
+static enum nss_status
do_parse_range (const char *attributeType,
const char *attributeDescription, int *start, int *end)
{
- NSS_STATUS stat = NSS_NOTFOUND;
+ enum nss_status stat = NSS_NOTFOUND;
char *attribute;
size_t attributeTypeLength;
size_t attributeDescriptionLength;
@@ -192,12 +175,12 @@ do_parse_range (const char *attributeType,
return stat;
}
-static NSS_STATUS
+static enum nss_status
do_get_range_values (LDAPMessage * e,
const char *attributeType,
int *start, int *end, char ***pGroupMembers)
{
- NSS_STATUS stat = NSS_NOTFOUND;
+ enum nss_status stat = NSS_NOTFOUND;
BerElement *ber = NULL;
char *attribute;
@@ -240,7 +223,7 @@ do_get_range_values (LDAPMessage * e,
* Format an attribute with description as:
* attribute;range=START-END
*/
-static NSS_STATUS
+static enum nss_status
do_construct_range_attribute (const char *attribute,
int start,
int end,
@@ -278,7 +261,7 @@ do_construct_range_attribute (const char *attribute,
/*
* Expand group members, including nested groups
*/
-static NSS_STATUS
+static enum nss_status
do_parse_group_members (LDAPMessage * e,
char ***pGroupMembers,
size_t * pGroupMembersCount,
@@ -288,7 +271,7 @@ do_parse_group_members (LDAPMessage * e,
int *depth,
struct name_list **pKnownGroups) /* traversed groups */
{
- NSS_STATUS stat = NSS_SUCCESS;
+ enum nss_status stat = NSS_SUCCESS;
char **dnValues = NULL;
char **uidValues = NULL;
char **groupMembers;
@@ -403,7 +386,7 @@ do_parse_group_members (LDAPMessage * e,
for (valiter = dnValues; *valiter != NULL; valiter++)
{
LDAPMessage *res;
- NSS_STATUS parseStat;
+ enum nss_status parseStat;
int isNestedGroup = 0;
char *uid;
@@ -531,7 +514,7 @@ out:
* "Fix" group membership list into caller provided buffer,
* and NULL terminate.
*/
-static NSS_STATUS
+static enum nss_status
do_fix_group_members_buffer (char **mallocedGroupMembers,
size_t groupMembersCount,
char ***pGroupMembers,
@@ -558,14 +541,14 @@ do_fix_group_members_buffer (char **mallocedGroupMembers,
return NSS_SUCCESS;
}
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_gr (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
{
struct group *gr = (struct group *) result;
char *gid;
- NSS_STATUS stat;
+ enum nss_status stat;
char **groupMembers;
size_t groupMembersCount;
size_t groupMembersBufferSize;
@@ -639,7 +622,7 @@ _nss_ldap_parse_gr (LDAPMessage * e,
* of any groups to which this group belongs (RFC2307bis nested
* group expansion is done by do_parse_initgroups_nested()).
*/
-static NSS_STATUS
+static enum nss_status
do_parse_initgroups (LDAPMessage * e,
ldap_state_t * pvt, void *result,
char *buffer, size_t buflen)
@@ -685,26 +668,6 @@ do_parse_initgroups (LDAPMessage * e,
return NSS_NOTFOUND;
}
-# ifdef HAVE_NSSWITCH_H
- /* weed out duplicates; is this really our resposibility? */
- for (i = 0; i < lia->gbm->numgids; i++)
- {
- if (lia->gbm->gid_array[i] == (gid_t) gid)
- return NSS_NOTFOUND;
- }
-
- if (lia->gbm->numgids == lia->gbm->maxgids)
- {
- /* can't fit any more */
- /*
- * should probably return NSS_TRYAGAIN but IIRC
- * will send Solaris into an infinite loop XXX
- */
- return NSS_SUCCESS;
- }
-
- lia->gbm->gid_array[lia->gbm->numgids++] = (gid_t) gid;
-# else
if (gid == lia->group)
{
/* primary group, so skip it */
@@ -743,18 +706,17 @@ do_parse_initgroups (LDAPMessage * e,
/* add to group list */
(*(lia->groups))[*(lia->start)] = gid;
(*(lia->start)) += 1;
-# endif /* HAVE_NSSWITCH_H */
#endif /* HAVE_USERSEC_H */
return NSS_NOTFOUND;
}
-static NSS_STATUS
+static enum nss_status
do_parse_initgroups_nested (LDAPMessage * e,
ldap_state_t * pvt, void *result,
char *buffer, size_t buflen)
{
- NSS_STATUS stat;
+ enum nss_status stat;
ldap_initgroups_args_t *lia = (ldap_initgroups_args_t *) result;
char **values;
char *groupdn;
@@ -779,7 +741,7 @@ do_parse_initgroups_nested (LDAPMessage * e,
values = _nss_ldap_get_values (e, ATM (LM_GROUP, memberOf));
if (values != NULL)
{
- NSS_STATUS stat;
+ enum nss_status stat;
lia->depth++;
stat = ng_chase_backlink ((const char **)values, lia);
@@ -798,7 +760,7 @@ do_parse_initgroups_nested (LDAPMessage * e,
groupdn = _nss_ldap_get_dn (e);
if (groupdn != NULL)
{
- NSS_STATUS stat;
+ enum nss_status stat;
lia->depth++;
stat = ng_chase (groupdn, lia);
@@ -814,11 +776,11 @@ do_parse_initgroups_nested (LDAPMessage * e,
return stat;
}
-static NSS_STATUS
+static enum nss_status
ng_chase (const char *dn, ldap_initgroups_args_t * lia)
{
ldap_args_t a;
- NSS_STATUS stat;
+ enum nss_status stat;
ent_context_t *ctx = NULL;
const char *gidnumber_attrs[2];
int erange;
@@ -857,11 +819,11 @@ ng_chase (const char *dn, ldap_initgroups_args_t * lia)
return stat;
}
-static NSS_STATUS
+static enum nss_status
ng_chase_backlink (const char ** membersOf, ldap_initgroups_args_t * lia)
{
ldap_args_t a;
- NSS_STATUS stat;
+ enum nss_status stat;
ent_context_t *ctx = NULL;
const char *gidnumber_attrs[3];
const char **memberP;
@@ -922,7 +884,7 @@ ng_chase_backlink (const char ** membersOf, ldap_initgroups_args_t * lia)
if (stat == NSS_SUCCESS)
{
- NSS_STATUS stat2;
+ enum nss_status stat2;
for (memberP = filteredMembersOf; *memberP != NULL; memberP++)
{
@@ -943,14 +905,12 @@ ng_chase_backlink (const char ** membersOf, ldap_initgroups_args_t * lia)
return stat;
}
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H) || defined(HAVE_USERSEC_H)
-#ifdef HAVE_NSS_H
-NSS_STATUS _nss_ldap_initgroups_dyn (const char *user, gid_t group,
+enum nss_status _nss_ldap_initgroups_dyn (const char *user, gid_t group,
long int *start, long int *size,
gid_t ** groupsp, long int limit,
int *errnop);
-NSS_STATUS
+enum nss_status
_nss_ldap_initgroups (const char *user, gid_t group, long int *start,
long int *size, gid_t * groups, long int limit,
int *errnop)
@@ -958,48 +918,28 @@ _nss_ldap_initgroups (const char *user, gid_t group, long int *start,
return (_nss_ldap_initgroups_dyn (user, group, start, size, &groups, limit,
errnop));
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-#define NSS_LDAP_INITGROUPS_FUNCTION "_nss_ldap_getgroupsbymember_r"
-#elif defined(HAVE_NSS_H)
#define NSS_LDAP_INITGROUPS_FUNCTION "_nss_ldap_initgroups_dyn"
-#elif defined(HAVE_USERSEC_H)
-#define NSS_LDAP_INITGROUPS_FUNCTION "_nss_ldap_getgrset"
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getgroupsbymember_r (nss_backend_t * be, void *args)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS
+ enum nss_status
_nss_ldap_initgroups_dyn (const char *user, gid_t group, long int *start,
long int *size, gid_t ** groupsp, long int limit,
int *errnop)
-#elif defined(HAVE_USERSEC_H)
-char *_nss_ldap_getgrset (char *user)
-#endif
{
ldap_initgroups_args_t lia;
-#ifndef HAVE_NSS_H
int erange = 0;
-#endif /* HAVE_NSS_H */
char *userdn = NULL;
LDAPMessage *res, *e;
static const char *no_attrs[] = { NULL };
const char *filter;
ldap_args_t a;
- NSS_STATUS stat;
+ enum nss_status stat;
ent_context_t *ctx = NULL;
const char *gidnumber_attrs[3];
ldap_map_selector_t map = LM_GROUP;
LA_INIT (a);
-#if defined(HAVE_NSS_H) || defined(HAVE_USERSEC_H)
LA_STRING (a) = user;
-#else
- LA_STRING (a) = ((struct nss_groupsbymem *) args)->username;
-#endif /* HAVE_NSS_H || HAVE_USERSEC_H */
LA_TYPE (a) = LA_TYPE_STRING;
debug ("==> " NSS_LDAP_INITGROUPS_FUNCTION " (user=%s)", LA_STRING (a) );
@@ -1013,9 +953,6 @@ char *_nss_ldap_getgrset (char *user)
#ifdef HAVE_USERSEC_H
lia.grplist = NULL;
lia.listlen = 0;
-#elif defined(HAVE_NSSWITCH_H)
- lia.gbm = (struct nss_groupsbymem *) args;
-#else
lia.group = group;
lia.start = start;
lia.size = size;
@@ -1033,11 +970,11 @@ char *_nss_ldap_getgrset (char *user)
{
debug ("<== " NSS_LDAP_INITGROUPS_FUNCTION " (init failed)");
_nss_ldap_leave ();
-# ifdef HAVE_USERSEC_H
+#ifdef HAVE_USERSEC_H
return NULL;
-# else
+#else
return stat;
-# endif /* !HAVE_USERSEC_H */
+#endif /* !HAVE_USERSEC_H */
}
if (_nss_ldap_test_initgroups_ignoreuser (LA_STRING (a)))
@@ -1102,19 +1039,15 @@ char *_nss_ldap_getgrset (char *user)
{
debug ("<== " NSS_LDAP_INITGROUPS_FUNCTION " (ent_context_init failed)");
_nss_ldap_leave ();
-# ifdef HAVE_USERSEC_H
+#ifdef HAVE_USERSEC_H
return NULL;
-# else
+#else
return NSS_UNAVAIL;
-# endif /* HAVE_USERSEC_H */
+#endif /* HAVE_USERSEC_H */
}
stat = _nss_ldap_getent_ex (&a, &ctx, (void *) &lia, NULL, 0,
-#ifdef HAVE_NSS_H
errnop,
-#else
- &erange,
-#endif /* HAVE_NSS_H */
filter,
map,
gidnumber_attrs,
@@ -1142,10 +1075,8 @@ char *_nss_ldap_getgrset (char *user)
if (stat != NSS_SUCCESS && stat != NSS_NOTFOUND)
{
debug ("<== " NSS_LDAP_INITGROUPS_FUNCTION " (not found)");
-#ifndef HAVE_NSS_H
if (erange)
errno = ERANGE;
-#endif /* HAVE_NSS_H */
#ifndef HAVE_USERSEC_H
return stat;
#else
@@ -1155,26 +1086,10 @@ char *_nss_ldap_getgrset (char *user)
debug ("<== " NSS_LDAP_INITGROUPS_FUNCTION " (success)");
-#ifdef HAVE_NSS_H
return NSS_SUCCESS;
-#elif defined(HAVE_USERSEC_H)
- /* Strip last comma and terminate the string */
- if (lia.grplist == NULL)
- lia.grplist = strdup("");
- else if (lia.listlen != 0)
- lia.grplist[lia.listlen - 1] = '\0';
-
- return lia.grplist;
-#else
- /* yes, NSS_NOTFOUND is the successful errno code. see nss_dbdefs.h */
- return NSS_NOTFOUND;
-#endif /* HAVE_NSS_H */
}
-#endif /* HAVE_NSSWITCH_H || HAVE_NSS_H || HAVE_USERSEC_H */
-
-#ifdef HAVE_NSS_H
-NSS_STATUS
+enum nss_status
_nss_ldap_getgrnam_r (const char *name,
struct group * result,
char *buffer, size_t buflen, int *errnop)
@@ -1182,17 +1097,8 @@ _nss_ldap_getgrnam_r (const char *name,
LOOKUP_NAME (name, result, buffer, buflen, errnop, _nss_ldap_filt_getgrnam,
LM_GROUP, _nss_ldap_parse_gr, LDAP_NSS_BUFLEN_GROUP);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_getgrnam_r (nss_backend_t * be, void *args)
-{
- LOOKUP_NAME (args, _nss_ldap_filt_getgrnam, LM_GROUP, _nss_ldap_parse_gr,
- LDAP_NSS_BUFLEN_GROUP);
-}
-#endif
-#ifdef HAVE_NSS_H
-NSS_STATUS
+enum nss_status
_nss_ldap_getgrgid_r (gid_t gid,
struct group *result,
char *buffer, size_t buflen, int *errnop)
@@ -1200,43 +1106,18 @@ _nss_ldap_getgrgid_r (gid_t gid,
LOOKUP_NUMBER (gid, result, buffer, buflen, errnop, _nss_ldap_filt_getgrgid,
LM_GROUP, _nss_ldap_parse_gr, LDAP_NSS_BUFLEN_GROUP);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_getgrgid_r (nss_backend_t * be, void *args)
-{
- LOOKUP_NUMBER (args, key.gid, _nss_ldap_filt_getgrgid, LM_GROUP,
- _nss_ldap_parse_gr, LDAP_NSS_BUFLEN_GROUP);
-}
-#endif
-#if defined(HAVE_NSS_H)
-NSS_STATUS _nss_ldap_setgrent (void)
+enum nss_status _nss_ldap_setgrent (void)
{
LOOKUP_SETENT (gr_context);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_setgrent_r (nss_backend_t * gr_context, void *args)
-{
- LOOKUP_SETENT (gr_context);
-}
-#endif
-#if defined(HAVE_NSS_H)
-NSS_STATUS _nss_ldap_endgrent (void)
-{
- LOOKUP_ENDENT (gr_context);
-}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_endgrent_r (nss_backend_t * gr_context, void *args)
+enum nss_status _nss_ldap_endgrent (void)
{
LOOKUP_ENDENT (gr_context);
}
-#endif
-#ifdef HAVE_NSS_H
-NSS_STATUS
+enum nss_status
_nss_ldap_getgrent_r (struct group *result,
char *buffer, size_t buflen, int *errnop)
{
@@ -1244,54 +1125,3 @@ _nss_ldap_getgrent_r (struct group *result,
_nss_ldap_filt_getgrent, LM_GROUP, _nss_ldap_parse_gr,
LDAP_NSS_BUFLEN_GROUP);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_getgrent_r (nss_backend_t * gr_context, void *args)
-{
- LOOKUP_GETENT (args, gr_context, _nss_ldap_filt_getgrent, LM_GROUP,
- _nss_ldap_parse_gr, LDAP_NSS_BUFLEN_GROUP);
-}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_group_destr (nss_backend_t * gr_context, void *args)
-{
- return _nss_ldap_default_destr (gr_context, args);
-}
-
-static nss_backend_op_t group_ops[] = {
- _nss_ldap_group_destr,
- _nss_ldap_endgrent_r,
- _nss_ldap_setgrent_r,
- _nss_ldap_getgrent_r,
- _nss_ldap_getgrnam_r,
- _nss_ldap_getgrgid_r,
- _nss_ldap_getgroupsbymember_r
-};
-
-nss_backend_t *
-_nss_ldap_group_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_backend_t *be;
-
- if (!(be = (nss_ldap_backend_t *) malloc (sizeof (*be))))
- return NULL;
-
- be->ops = group_ops;
- be->n_ops = sizeof (group_ops) / sizeof (nss_backend_op_t);
-
- /* a NOOP at the moment */
- if (_nss_ldap_default_constr (be) != NSS_SUCCESS)
- return NULL;
-
- return (nss_backend_t *) be;
-}
-
-
-#endif /* !HAVE_NSS_H */
-
-#ifdef HAVE_IRS_H
-#include "irs-grp.c"
-#endif
diff --git a/ldap-grp.h b/ldap-grp.h
index f50eb7c..437e4f1 100644
--- a/ldap-grp.h
+++ b/ldap-grp.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,26 +19,14 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_GRP_H
#define _LDAP_NSS_LDAP_LDAP_GRP_H
-static NSS_STATUS _nss_ldap_parse_gr (LDAPMessage * e,
+static enum nss_status _nss_ldap_parse_gr (LDAPMessage * e,
ldap_state_t * pvt,
void *result,
char *buffer, size_t buflen);
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS _nss_ldap_endgrent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_setgrent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_getgrent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_getgrnam_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_getgrgid_r (nss_backend_t * be, void *fakeargs);
-
-nss_backend_t *_nss_ldap_group_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-#endif
-
#endif /* _LDAP_NSS_LDAP_LDAP_GRP_H */
diff --git a/ldap-hosts.c b/ldap-hosts.c
index 98b10ad..66aaa10 100644
--- a/ldap-hosts.c
+++ b/ldap-hosts.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,10 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
-
-static char rcsId[] =
- "$Id$";
+*/
#include "config.h"
@@ -68,11 +66,9 @@ static char rcsId[] =
#include <port_after.h>
#endif
-#ifdef HAVE_NSS_H
static ent_context_t *hosts_context = NULL;
-#endif
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_hostv4 (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
@@ -82,7 +78,7 @@ _nss_ldap_parse_hostv4 (LDAPMessage * e,
}
#ifdef INET6
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_hostv6 (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
@@ -92,7 +88,7 @@ _nss_ldap_parse_hostv6 (LDAPMessage * e,
}
#endif
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_host (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen,
@@ -100,7 +96,7 @@ _nss_ldap_parse_host (LDAPMessage * e,
{
/* this code needs reviewing. XXX */
struct hostent *host = (struct hostent *) result;
- NSS_STATUS stat;
+ enum nss_status stat;
#ifdef INET6
char addressbuf[sizeof ("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") *
MAXALIASES];
@@ -235,39 +231,12 @@ _nss_ldap_parse_host (LDAPMessage * e,
return NSS_SUCCESS;
}
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_gethostbyname_r (nss_backend_t * be, void *args)
-{
- ldap_args_t a;
- NSS_STATUS status;
-
- LA_INIT (a);
- LA_STRING (a) = NSS_ARGS (args)->key.name;
- LA_TYPE (a) = LA_TYPE_STRING;
-
- status = _nss_ldap_getbyname (&a,
- NSS_ARGS (args)->buf.result,
- NSS_ARGS (args)->buf.buffer,
- NSS_ARGS (args)->buf.buflen,
- &NSS_ARGS (args)->erange,
- _nss_ldap_filt_gethostbyname,
- LM_HOSTS, _nss_ldap_parse_hostv4);
-
- if (status == NSS_SUCCESS)
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result;
-
- MAP_H_ERRNO (status, NSS_ARGS (args)->h_errno);
-
- return status;
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_gethostbyname2_r (const char *name, int af, struct hostent * result,
char *buffer, size_t buflen, int *errnop,
int *h_errnop)
{
- NSS_STATUS status;
+ enum nss_status status;
ldap_args_t a;
LA_INIT (a);
@@ -292,7 +261,7 @@ _nss_ldap_gethostbyname2_r (const char *name, int af, struct hostent * result,
return status;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_gethostbyname_r (const char *name, struct hostent * result,
char *buffer, size_t buflen, int *errnop,
int *h_errnop)
@@ -305,44 +274,13 @@ _nss_ldap_gethostbyname_r (const char *name, struct hostent * result,
AF_INET, result, buffer, buflen,
errnop, h_errnop);
}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_gethostbyaddr_r (nss_backend_t * be, void *args)
-{
- struct in_addr iaddr;
- ldap_args_t a;
- NSS_STATUS status;
-
- memcpy (&iaddr.s_addr, NSS_ARGS (args)->key.hostaddr.addr,
- NSS_ARGS (args)->key.hostaddr.len);
- LA_INIT (a);
- LA_STRING (a) = inet_ntoa (iaddr);
- LA_TYPE (a) = LA_TYPE_STRING;
-
- status = _nss_ldap_getbyname (&a,
- NSS_ARGS (args)->buf.result,
- NSS_ARGS (args)->buf.buffer,
- NSS_ARGS (args)->buf.buflen,
- &NSS_ARGS (args)->erange,
- _nss_ldap_filt_gethostbyaddr,
- LM_HOSTS, _nss_ldap_parse_hostv4);
-
- if (status == NSS_SUCCESS)
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result;
-
- MAP_H_ERRNO (status, NSS_ARGS (args)->h_errno);
- return status;
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_gethostbyaddr_r (struct in_addr * addr, int len, int type,
struct hostent * result, char *buffer,
size_t buflen, int *errnop, int *h_errnop)
{
- NSS_STATUS status;
+ enum nss_status status;
ldap_args_t a;
/* if querying by IPv6 address, make sure the address is "normalized" --
@@ -371,59 +309,22 @@ _nss_ldap_gethostbyaddr_r (struct in_addr * addr, int len, int type,
return status;
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_sethostent_r (nss_backend_t * hosts_context, void *fakeargs)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_sethostent (void)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+ enum nss_status _nss_ldap_sethostent (void)
{
LOOKUP_SETENT (hosts_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_endhostent_r (nss_backend_t * hosts_context, void *fakeargs)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_endhostent (void)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+ enum nss_status _nss_ldap_endhostent (void)
{
LOOKUP_ENDENT (hosts_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_gethostent_r (nss_backend_t * hosts_context, void *args)
-{
- NSS_STATUS status = _nss_ldap_getent (&((nss_ldap_backend_t *)
- hosts_context)->state,
- NSS_ARGS (args)->buf.result,
- NSS_ARGS (args)->buf.buffer,
- NSS_ARGS (args)->buf.buflen,
- &NSS_ARGS (args)->erange,
- _nss_ldap_filt_gethostent,
- LM_HOSTS,
- _nss_ldap_parse_hostv4);
-
- if (status == NSS_SUCCESS)
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result;
-
- MAP_H_ERRNO (status, NSS_ARGS (args)->h_errno);
-
- return status;
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_gethostent_r (struct hostent * result, char *buffer, size_t buflen,
int *errnop, int *h_errnop)
{
- NSS_STATUS status;
+ enum nss_status status;
status = _nss_ldap_getent (&hosts_context,
result,
@@ -441,44 +342,3 @@ _nss_ldap_gethostent_r (struct hostent * result, char *buffer, size_t buflen,
return status;
}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_hosts_destr (nss_backend_t * hosts_context, void *args)
-{
- return _nss_ldap_default_destr (hosts_context, args);
-}
-
-static nss_backend_op_t host_ops[] = {
- _nss_ldap_hosts_destr,
- _nss_ldap_endhostent_r,
- _nss_ldap_sethostent_r,
- _nss_ldap_gethostent_r,
- _nss_ldap_gethostbyname_r,
- _nss_ldap_gethostbyaddr_r
-};
-
-nss_backend_t *
-_nss_ldap_hosts_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_backend_t *be;
-
- if (!(be = (nss_ldap_backend_t *) malloc (sizeof (*be))))
- return NULL;
-
- be->ops = host_ops;
- be->n_ops = sizeof (host_ops) / sizeof (nss_backend_op_t);
-
- if (_nss_ldap_default_constr (be) != NSS_SUCCESS)
- return NULL;
-
- return (nss_backend_t *) be;
-}
-
-#endif /* !HAVE_NSS_H */
-
-#ifdef HAVE_IRS_H
-#include "irs-hosts.c"
-#endif
diff --git a/ldap-hosts.h b/ldap-hosts.h
index 3e283f5..f0a2889 100644
--- a/ldap-hosts.h
+++ b/ldap-hosts.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -16,7 +17,9 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
+
+ $Id$
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_HOSTS_H
#define _LDAP_NSS_LDAP_LDAP_HOSTS_H
@@ -28,32 +31,9 @@
*
*/
-
-#if defined(HAVE_NSSWITCH_H) || defined(DL_NSS)
-/* XXX Fixme */
-#ifndef INADDRSZ
-#define INADDRSZ (sizeof(u_long))
-#endif
-#endif
-
-
-static NSS_STATUS _nss_ldap_parse_host (LDAPMessage * e,
+static enum nss_status _nss_ldap_parse_host (LDAPMessage * e,
ldap_state_t * pvt,
void *result,
char *buffer, size_t buflen, int af);
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS _nss_ldap_gethostbyname_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_gethostbyaddr_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_gethostent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_sethostent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_endhostent_r (nss_backend_t * be, void *fakeargs);
-
-nss_backend_t *_nss_ldap_hosts_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-#endif
-
#endif /* _LDAP_NSS_LDAP_LDAP_HOSTS_H */
diff --git a/ldap-netgrp.c b/ldap-netgrp.c
index 675d4e4..c17ba02 100644
--- a/ldap-netgrp.c
+++ b/ldap-netgrp.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002-2005 Luke Howard.
+/*
+ Copyright (C) 2002-2005 Luke Howard
This file is part of the nss_ldap library.
Linux support contributed by Larry Lile, <llile@dreamworks.com>, 2002.
Solaris support contributed by Luke Howard, <lukeh@padl.com>, 2004.
@@ -19,10 +20,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
-
-static char rcsId[] =
- "$Id$";
+*/
#include "config.h"
@@ -53,10 +51,6 @@ static char rcsId[] =
#include <ldap.h>
#endif
-#ifndef HAVE_SNPRINTF
-#include "snprintf.h"
-#endif
-
#include "ldap-nss.h"
#include "ldap-netgrp.h"
#include "util.h"
@@ -65,38 +59,10 @@ static char rcsId[] =
#include <port_after.h>
#endif
-#ifdef HAVE_NSS_H
static ent_context_t *_ngbe = NULL;
-#endif
-#ifdef HAVE_IRS_H
-enum nss_netgr_status {
- NSS_NETGR_FOUND,
- NSS_NETGR_NO,
- NSS_NETGR_NOMEM
-};
-struct pvt; /* forward declaration for IRS backend type */
-#endif /* HAVE_IRS_H */
-#ifdef HAVE_NSSWITCH_H
-static nss_backend_op_t netgroup_ops[];
-#endif
-
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_IRS_H)
-struct ldap_innetgr_args
-{
- const char *lia_netgroup;
- enum nss_netgr_status lia_netgr_status;
- int lia_depth;
- int lia_erange;
-};
-
-typedef struct ldap_innetgr_args ldap_innetgr_args_t;
-
-static NSS_STATUS do_innetgr_nested (ldap_innetgr_args_t * li_args,
- const char *nested);
-#endif /* HAVE_NSSWITCH_H || HAVE_IRS_H */
/*
* I pulled the following macro (EXPAND), functions (strip_whitespace and
@@ -180,7 +146,7 @@ strip_whitespace (char *str)
return *str == '\0' ? NULL : str;
}
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_netgr (void *vresultp, char *buffer, size_t buflen)
{
struct __netgrent *result = (struct __netgrent *) vresultp;
@@ -264,8 +230,7 @@ _nss_ldap_parse_netgr (void *vresultp, char *buffer, size_t buflen)
return NSS_SUCCESS;
}
-#ifdef HAVE_NSS_H
-static NSS_STATUS
+static enum nss_status
_nss_ldap_load_netgr (LDAPMessage * e,
ldap_state_t * pvt,
void *vresultp, char *buffer, size_t buflen)
@@ -276,7 +241,7 @@ _nss_ldap_load_netgr (LDAPMessage * e,
char **vals;
char **valiter;
struct __netgrent *result = vresultp;
- NSS_STATUS stat = NSS_SUCCESS;
+ enum nss_status stat = NSS_SUCCESS;
for (attr = 0; attr < 2; attr++)
{
@@ -333,7 +298,7 @@ out:
return stat;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_endnetgrent (struct __netgrent * result)
{
if (result->data != NULL)
@@ -347,13 +312,13 @@ _nss_ldap_endnetgrent (struct __netgrent * result)
LOOKUP_ENDENT (_ngbe);
}
-NSS_STATUS
+enum nss_status
_nss_ldap_setnetgrent (char *group, struct __netgrent *result)
{
int errnop = 0, buflen = 0;
char *buffer = (char *) NULL;
ldap_args_t a;
- NSS_STATUS stat = NSS_SUCCESS;
+ enum nss_status stat = NSS_SUCCESS;
if (group[0] == '\0')
return NSS_UNAVAIL;
@@ -375,619 +340,9 @@ _nss_ldap_setnetgrent (char *group, struct __netgrent *result)
LOOKUP_SETENT (_ngbe);
}
-NSS_STATUS
+enum nss_status
_nss_ldap_getnetgrent_r (struct __netgrent *result,
char *buffer, size_t buflen, int *errnop)
{
return _nss_ldap_parse_netgr (result, buffer, buflen);
}
-#endif /* HAVE_NSS_H */
-
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_IRS_H)
-/*
- * Chase nested netgroups. If we can't find a nested netgroup, we try
- * the next one - don't want to fail authoritatively because of bad
- * user data.
- */
-static NSS_STATUS
-nn_chase (nss_ldap_netgr_backend_t * ngbe, LDAPMessage ** pEntry)
-{
- ldap_args_t a;
- NSS_STATUS stat = NSS_NOTFOUND;
-
- debug ("==> nn_chase");
-
- if (ngbe->state->ec_res != NULL)
- {
- ldap_msgfree (ngbe->state->ec_res);
- ngbe->state->ec_res = NULL;
- }
-
- while (ngbe->needed_groups != NULL)
- {
- /* If this netgroup has already been seen, avoid it */
- if (_nss_ldap_namelist_find (ngbe->known_groups, ngbe->needed_groups->name))
- {
- _nss_ldap_namelist_pop (&ngbe->needed_groups);
- continue;
- }
-
- LA_INIT (a);
- LA_TYPE (a) = LA_TYPE_STRING;
- LA_STRING (a) = ngbe->needed_groups->name;
-
- debug (":== nn_chase: nested netgroup=%s", LA_STRING (a));
-
- _nss_ldap_enter ();
- stat = _nss_ldap_search_s (&a, _nss_ldap_filt_getnetgrent,
- LM_NETGROUP, NULL, 1, &ngbe->state->ec_res);
- _nss_ldap_leave ();
-
- if (stat == NSS_SUCCESS)
- {
- /* we have "seen" this netgroup; track it for loop detection */
- stat = _nss_ldap_namelist_push (&ngbe->known_groups, ngbe->needed_groups->name);
- if (stat != NSS_SUCCESS)
- {
- _nss_ldap_namelist_pop (&ngbe->needed_groups);
- break;
- }
- }
-
- _nss_ldap_namelist_pop (&ngbe->needed_groups);
-
- if (stat == NSS_SUCCESS)
- {
- /* Check we got an entry, not just a result. */
- *pEntry = _nss_ldap_first_entry (ngbe->state->ec_res);
- if (*pEntry == NULL)
- {
- ldap_msgfree (ngbe->state->ec_res);
- ngbe->state->ec_res = NULL;
- stat = NSS_NOTFOUND;
- }
- }
-
- if (stat == NSS_SUCCESS)
- {
- /* found one. */
- break;
- }
- }
-
- debug ("<== nn_chase result=%d", stat);
-
- return stat;
-}
-#endif /* HAVE_NSSWITCH_H || HAVE_IRS_H */
-
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_IRS_H)
-/*
- * getnetgrent() inner implementation, used by both Solaris NSS
- * and IRS/AIX
- */
-static NSS_STATUS
-do_getnetgrent (nss_ldap_netgr_backend_t *be,
- char *buffer, size_t buflen,
- enum nss_netgr_status *status,
- char **machine, char **user, char **domain)
-{
- ent_context_t *ctx;
- NSS_STATUS parseStat = NSS_NOTFOUND;
-
- /*
- * This function is called with the pseudo-backend that
- * we created in _nss_ldap_setnetgrent() (see below)
- */
- debug ("==> do_getnetgrent");
-
- ctx = be->state;
- assert (ctx != NULL);
-
- *status = NSS_NETGR_NO;
- *machine = NULL;
- *user = NULL;
- *domain = NULL;
-
- do
- {
- NSS_STATUS resultStat = NSS_SUCCESS;
- char **vals, **p;
- ldap_state_t *state = &ctx->ec_state;
- struct __netgrent __netgrent;
- LDAPMessage *e;
-
- if (state->ls_retry == 0 && state->ls_info.ls_index == -1)
- {
- resultStat = NSS_NOTFOUND;
-
- if (ctx->ec_res != NULL)
- {
- e = _nss_ldap_first_entry (ctx->ec_res);
- if (e != NULL)
- resultStat = NSS_SUCCESS;
- }
-
- if (resultStat != NSS_SUCCESS)
- {
- /* chase nested netgroups */
- resultStat = nn_chase (be, &e);
- }
-
- if (resultStat != NSS_SUCCESS)
- {
- parseStat = resultStat;
- break;
- }
-
- assert (e != NULL);
-
- /* Push nested netgroups onto stack for deferred chasing */
- vals = _nss_ldap_get_values (e, AT (memberNisNetgroup));
- if (vals != NULL)
- {
- for (p = vals; *p != NULL; p++)
- {
- parseStat = _nss_ldap_namelist_push (&be->needed_groups, *p);
- if (parseStat != NSS_SUCCESS)
- break;
- }
- ldap_value_free (vals);
-
- if (parseStat != NSS_SUCCESS)
- break; /* out of memory */
- }
- }
- else
- {
- assert (ctx->ec_res != NULL);
- e = _nss_ldap_first_entry (ctx->ec_res);
- if (e == NULL)
- {
- /* This should never happen, but we fail gracefully. */
- parseStat = NSS_UNAVAIL;
- break;
- }
- }
-
- /* We have an entry; now, try to parse it. */
- vals = _nss_ldap_get_values (e, AT (nisNetgroupTriple));
- if (vals == NULL)
- {
- state->ls_info.ls_index = -1;
- parseStat = NSS_NOTFOUND;
- ldap_msgfree (ctx->ec_res);
- ctx->ec_res = NULL;
- continue;
- }
-
- switch (state->ls_info.ls_index)
- {
- case 0:
- /* last time. decrementing ls_index to -1 AND returning
- * an error code will force this entry to be discared.
- */
- parseStat = NSS_NOTFOUND;
- break;
- case -1:
- /* first time */
- state->ls_info.ls_index = ldap_count_values (vals);
- /* fall off to default... */
- default:
- __netgrent.data = vals[state->ls_info.ls_index - 1];
- __netgrent.data_size = strlen (vals[state->ls_info.ls_index - 1]);
- __netgrent.cursor = __netgrent.data;
- __netgrent.first = 1;
-
- parseStat = _nss_ldap_parse_netgr (&__netgrent, buffer, buflen);
- if (parseStat != NSS_SUCCESS)
- {
- break;
- }
- if (__netgrent.type != triple_val)
- {
- parseStat = NSS_NOTFOUND;
- break;
- }
- *machine = (char *) __netgrent.val.triple.host;
- *user = (char *) __netgrent.val.triple.user;
- *domain = (char *) __netgrent.val.triple.domain;
- break;
- }
-
- ldap_value_free (vals);
- state->ls_info.ls_index--;
-
- /* hold onto the state if we're out of memory XXX */
- state->ls_retry = (parseStat == NSS_TRYAGAIN ? 1 : 0);
- *status = (parseStat == NSS_SUCCESS) ? NSS_NETGR_FOUND : NSS_NETGR_NOMEM;
-
- if (state->ls_retry == 0 && state->ls_info.ls_index == -1)
- {
- ldap_msgfree (ctx->ec_res);
- ctx->ec_res = NULL;
- }
- }
- while (parseStat == NSS_NOTFOUND);
-
- if (parseStat == NSS_TRYAGAIN)
- {
- errno = ERANGE;
- }
-
- debug ("<== do_getnetgrent");
-
- return parseStat;
-}
-
-/*
- * Test a 4-tuple
- */
-static NSS_STATUS
-do_parse_innetgr (LDAPMessage * e, ldap_state_t * pvt,
- void *result, char *buffer, size_t buflen)
-{
- ldap_innetgr_args_t *li_args = (ldap_innetgr_args_t *) result;
- int count;
- char **values = NULL;
- NSS_STATUS stat = NSS_NOTFOUND;
-
- debug ("==> do_parse_innetgr");
-
- values = _nss_ldap_get_values (e, ATM (LM_NETGROUP, cn));
- if (values == NULL)
- return NSS_NOTFOUND;
-
- count = ldap_count_values (values);
-
- while (--count >= 0)
- {
- assert (values[count] != NULL);
-
- if (strcasecmp (li_args->lia_netgroup, values[count]) == 0)
- {
- li_args->lia_netgr_status = NSS_NETGR_FOUND;
- stat = NSS_SUCCESS;
- }
- else
- {
- stat = do_innetgr_nested (li_args, values[count]);
- }
-
- if (stat == NSS_SUCCESS)
- break;
- }
-
- ldap_value_free (values);
-
- debug ("<== do_parse_innetgr");
-
- return stat;
-}
-
-/*
- * NB: caller has acquired the global lock
- */
-static NSS_STATUS
-do_innetgr_nested (ldap_innetgr_args_t * li_args, const char *nested)
-{
- NSS_STATUS stat;
- ldap_args_t a;
- ent_context_t *ctx = NULL;
-
- debug ("==> do_innetgr_nested netgroup=%s assertion=%s",
- li_args->lia_netgroup, nested);
-
- if (li_args->lia_depth >= LDAP_NSS_MAXNETGR_DEPTH)
- {
- debug ("<== do_innetgr_nested: maximum depth exceeded");
- return NSS_NOTFOUND;
- }
-
- LA_INIT (a);
- LA_TYPE (a) = LA_TYPE_STRING;
- LA_STRING (a) = nested; /* memberNisNetgroup */
-
- if (_nss_ldap_ent_context_init_locked (&ctx) == NULL)
- {
- debug ("<== do_innetgr_nested: failed to initialize context");
- return NSS_UNAVAIL;
- }
-
- li_args->lia_depth++;
-
- stat = _nss_ldap_getent_ex (&a, &ctx, (void *) li_args, NULL, 0,
- &li_args->lia_erange, _nss_ldap_filt_innetgr,
- LM_NETGROUP, NULL, do_parse_innetgr);
-
- li_args->lia_depth--;
-
- _nss_ldap_ent_context_release (ctx);
- free (ctx);
-
- debug ("<== do_innetgr_nested status=%d netgr_status=%d",
- stat, li_args->lia_netgr_status);
-
- return stat;
-}
-
-/*
- * NB: caller has acquired the global lock
- */
-static NSS_STATUS
-do_innetgr (ldap_innetgr_args_t * li_args,
- const char *machine, const char *user, const char *domain)
-{
- NSS_STATUS stat;
- ldap_args_t a;
- ent_context_t *ctx = NULL;
-
- debug ("==> do_innetgr netgroup=%s", li_args->lia_netgroup);
-
- /*
- * First, find which netgroup the 3-tuple belongs to.
- */
- LA_INIT (a);
- LA_TYPE (a) = LA_TYPE_TRIPLE;
- LA_TRIPLE (a).user = user;
- LA_TRIPLE (a).host = machine;
- LA_TRIPLE (a).domain = domain;
-
- if (_nss_ldap_ent_context_init_locked (&ctx) == NULL)
- {
- debug ("<== do_innetgr: failed to initialize context");
- return NSS_UNAVAIL;
- }
-
- stat = _nss_ldap_getent_ex (&a, &ctx, (void *) li_args, NULL, 0,
- &li_args->lia_erange, NULL, LM_NETGROUP,
- NULL, do_parse_innetgr);
-
- _nss_ldap_ent_context_release (ctx);
- free (ctx);
-
- debug ("<== do_innetgr status=%d netgr_status=%d",
- stat, li_args->lia_netgr_status);
-
- return stat;
-}
-#endif /* HAVE_NSSWITCH_H || HAVE_IRS_H */
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getnetgroup_endent (nss_backend_t * be, void *_args)
-{
- LOOKUP_ENDENT (be);
-}
-
-static NSS_STATUS
-_nss_ldap_getnetgroup_setent (nss_backend_t * be, void *_args)
-{
- return NSS_SUCCESS;
-}
-
-static NSS_STATUS
-_nss_ldap_getnetgroup_getent (nss_backend_t * _be, void *_args)
-{
- nss_ldap_netgr_backend_t *be = (nss_ldap_netgr_backend_t *) _be;
- struct nss_getnetgrent_args *args = (struct nss_getnetgrent_args *) _args;
- NSS_STATUS stat;
-
- _nss_ldap_enter ();
-
- stat = do_getnetgrent (be,
- args->buffer,
- args->buflen,
- &args->status,
- &args->retp[NSS_NETGR_MACHINE],
- &args->retp[NSS_NETGR_USER],
- &args->retp[NSS_NETGR_DOMAIN]);
-
- _nss_ldap_leave ();
-
- return stat;
-}
-
-static NSS_STATUS
-_nss_ldap_innetgr (nss_backend_t * be, void *_args)
-{
- NSS_STATUS stat = NSS_NOTFOUND;
- struct nss_innetgr_args *args = (struct nss_innetgr_args *) _args;
- int i;
-
- /*
- * Enumerate the groups in args structure and see whether
- * any 4-tuple was satisfied. This really needs LDAP
- * component matching to be done efficiently.
- */
-
- debug
- ("==> _nss_ldap_innetgr MACHINE.argc=%d USER.argc=%d DOMAIN.argc=%d groups.argc=%d",
- args->arg[NSS_NETGR_MACHINE].argc, args->arg[NSS_NETGR_USER].argc,
- args->arg[NSS_NETGR_DOMAIN].argc, args->groups.argc);
-
- /* Presume these are harmonized -- this is a strange interface */
- assert (args->arg[NSS_NETGR_MACHINE].argc == 0 ||
- args->arg[NSS_NETGR_MACHINE].argc == args->groups.argc);
- assert (args->arg[NSS_NETGR_USER].argc == 0 ||
- args->arg[NSS_NETGR_USER].argc == args->groups.argc);
- assert (args->arg[NSS_NETGR_DOMAIN].argc == 0 ||
- args->arg[NSS_NETGR_DOMAIN].argc == args->groups.argc);
-
- _nss_ldap_enter ();
-
- for (i = 0; i < args->groups.argc; i++)
- {
- NSS_STATUS parseStat;
- ldap_innetgr_args_t li_args;
-
- const char *machine = (args->arg[NSS_NETGR_MACHINE].argc != 0) ?
- args->arg[NSS_NETGR_MACHINE].argv[i] : NULL;
- const char *user = (args->arg[NSS_NETGR_USER].argc != 0) ?
- args->arg[NSS_NETGR_USER].argv[i] : NULL;
- const char *domain = (args->arg[NSS_NETGR_DOMAIN].argc != 0) ?
- args->arg[NSS_NETGR_DOMAIN].argv[i] : NULL;
-
- li_args.lia_netgroup = args->groups.argv[i];
- li_args.lia_netgr_status = NSS_NETGR_NO;
- li_args.lia_depth = 0;
- li_args.lia_erange = 0;
-
- parseStat = do_innetgr (&li_args, machine, user, domain);
- if (parseStat != NSS_SUCCESS && parseStat != NSS_NOTFOUND)
- {
- /* fatal error */
- if (li_args.lia_erange != 0)
- errno = ERANGE;
- break;
- }
-
- args->status = li_args.lia_netgr_status;
-
- if (args->status == NSS_NETGR_FOUND)
- {
- stat = NSS_SUCCESS;
- }
- }
-
- _nss_ldap_leave ();
-
- debug ("<== _nss_ldap_innetgr");
-
- return stat;
-}
-
-/*
- * According to the "documentation", setnetgrent() is really
- * a getXXXbyYYY() operation that returns a pseudo-backend
- * through which one may enumerate the netgroup's members.
- *
- * ie. this is the constructor for the pseudo-backend.
- */
-static NSS_STATUS
-_nss_ldap_setnetgrent (nss_backend_t * be, void *_args)
-{
- NSS_STATUS stat;
- struct nss_setnetgrent_args *args;
- nss_ldap_netgr_backend_t *ngbe;
- ldap_args_t a;
-
- debug ("==> _nss_ldap_setnetgrent");
-
- args = (struct nss_setnetgrent_args *) _args;
- args->iterator = NULL; /* initialize */
-
- /*
- * This retrieves the top-level netgroup; nested netgroups
- * are chased inside the pseudo-backend.
- */
-
- LA_INIT (a);
- LA_TYPE (a) = LA_TYPE_STRING;
- LA_STRING (a) = args->netgroup; /* cn */
-
- ngbe = (nss_ldap_netgr_backend_t *) malloc (sizeof (*ngbe));
- if (ngbe == NULL)
- {
- debug ("<== _nss_ldap_setnetgrent");
- return NSS_UNAVAIL;
- }
-
- ngbe->ops = netgroup_ops;
- ngbe->n_ops = 6;
- ngbe->state = NULL;
- ngbe->known_groups = NULL;
- ngbe->needed_groups = NULL;
-
- stat = _nss_ldap_default_constr ((nss_ldap_backend_t *) ngbe);
- if (stat != NSS_SUCCESS)
- {
- free (ngbe);
- debug ("<== _nss_ldap_setnetgrent");
- return stat;
- }
-
- if (_nss_ldap_ent_context_init (&ngbe->state) == NULL)
- {
- _nss_ldap_default_destr ((nss_backend_t *) ngbe, NULL);
- debug ("<== _nss_ldap_setnetgrent");
- return NSS_UNAVAIL;
- }
-
- assert (ngbe->state != NULL);
- assert (ngbe->state->ec_res == NULL);
-
- _nss_ldap_enter ();
- stat = _nss_ldap_search_s (&a, _nss_ldap_filt_getnetgrent,
- LM_NETGROUP, NULL, 1, &ngbe->state->ec_res);
- _nss_ldap_leave ();
-
- if (stat == NSS_SUCCESS)
- {
- /* we have "seen" this netgroup; track it for loop detection */
- stat = _nss_ldap_namelist_push (&ngbe->known_groups, args->netgroup);
- }
-
- if (stat == NSS_SUCCESS)
- {
- args->iterator = (nss_backend_t *) ngbe;
- }
- else
- {
- _nss_ldap_default_destr ((nss_backend_t *) ngbe, NULL);
- }
-
- debug ("<== _nss_ldap_setnetgrent");
-
- return stat;
-}
-
-static NSS_STATUS
-_nss_ldap_netgroup_destr (nss_backend_t * _ngbe, void *args)
-{
- nss_ldap_netgr_backend_t *ngbe = (nss_ldap_netgr_backend_t *) _ngbe;
-
- /* free list of nested netgroups */
- _nss_ldap_namelist_destroy (&ngbe->known_groups);
- _nss_ldap_namelist_destroy (&ngbe->needed_groups);
-
- return _nss_ldap_default_destr (_ngbe, args);
-}
-
-static nss_backend_op_t netgroup_ops[] = {
- _nss_ldap_netgroup_destr, /* NSS_DBOP_DESTRUCTOR */
- _nss_ldap_getnetgroup_endent, /* NSS_DBOP_ENDENT */
- _nss_ldap_getnetgroup_setent, /* NSS_DBOP_SETENT */
- _nss_ldap_getnetgroup_getent, /* NSS_DBOP_GETENT */
- _nss_ldap_innetgr, /* NSS_DBOP_NETGROUP_IN */
- _nss_ldap_setnetgrent /* NSS_DBOP_NETGROUP_SET */
-};
-
-nss_backend_t *
-_nss_ldap_netgroup_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_netgr_backend_t *be;
-
- if (!(be = (nss_ldap_netgr_backend_t *) malloc (sizeof (*be))))
- return NULL;
-
- be->ops = netgroup_ops;
- be->n_ops = sizeof (netgroup_ops) / sizeof (nss_backend_op_t);
- be->known_groups = NULL;
- be->needed_groups = NULL;
-
- if (_nss_ldap_default_constr ((nss_ldap_backend_t *) be) != NSS_SUCCESS)
- {
- free (be);
- return NULL;
- }
-
- return (nss_backend_t *) be;
-}
-
-#endif /* !HAVE_NSS_H */
-
-#ifdef HAVE_IRS_H
-#include "irs-netgrp.c"
-#endif /* HAVE_IRS_H */
diff --git a/ldap-netgrp.h b/ldap-netgrp.h
index cefe65b..0f89492 100644
--- a/ldap-netgrp.h
+++ b/ldap-netgrp.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,28 +19,14 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_NETGRP_H
#define _LDAP_NSS_LDAP_LDAP_NETGRP_H
-static NSS_STATUS _nss_ldap_parse_netgr (void *result,
+static enum nss_status _nss_ldap_parse_netgr (void *result,
char *buffer, size_t buflen);
-#ifdef HAVE_NSSWITCH_H
-#if 0
-static NSS_STATUS _nss_ldap_setnetgrent_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_endnetgrent_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_getnetgrent_r (nss_backend_t * be,
- void *fakeargs);
-
-nss_backend_t *_nss_ldap_netgroup_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-#endif
-#endif /* !HAVE_NSS_H */
#endif /* _LDAP_NSS_LDAP_LDAP_NETGRP_H */
diff --git a/ldap-network.c b/ldap-network.c
index ffbe514..bb94cb1 100644
--- a/ldap-network.c
+++ b/ldap-network.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,13 +19,10 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
/* parts based on nss_nis */
-static char rcsId[] =
- "$Id$";
-
#include "config.h"
#ifdef HAVE_PORT_BEFORE_H
@@ -58,33 +56,26 @@ static char rcsId[] =
#include "ldap-network.h"
#include "util.h"
-#if defined(HAVE_IRS_H) || defined(HAVE_USERSEC_H)
+#if defined(HAVE_USERSEC_H)
#define MAXALIASES 35
#define MAXADDRSIZE 4
-#endif /* HAVE_IRS_H || HAVE_USERSEC_H */
+#endif /* HAVE_USERSEC_H */
#ifdef HAVE_PORT_AFTER_H
#include <port_after.h>
#endif
-#ifdef HAVE_NSS_H
static ent_context_t *net_context = NULL;
-#endif
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_net (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
{
char *tmp;
-#ifdef HAVE_IRS_H
- struct nwent *network = (struct nwent *) result;
- unsigned char *addr;
-#else
struct netent *network = (struct netent *) result;
-#endif
- NSS_STATUS stat;
+ enum nss_status stat;
/* IPv6 support ? XXX */
network->n_addrtype = AF_INET;
@@ -100,17 +91,7 @@ _nss_ldap_parse_net (LDAPMessage * e,
if (stat != NSS_SUCCESS)
return stat;
-#ifdef HAVE_IRS_H
- if (buflen < MAXADDRSIZE)
- return NSS_TRYAGAIN;
- addr = buffer;
- buffer += MAXADDRSIZE;
- buffer -= MAXADDRSIZE;
- network->n_length = inet_net_pton (AF_INET, tmp, &addr, MAXADDRSIZE);
- network->n_addr = addr;
-#else
network->n_net = inet_network (tmp);
-#endif
stat =
_nss_ldap_assign_attrvals (e, ATM (LM_NETWORKS, cn), network->n_name,
@@ -121,39 +102,12 @@ _nss_ldap_parse_net (LDAPMessage * e,
return NSS_SUCCESS;
}
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getnetbyname_r (nss_backend_t * be, void *args)
-{
- ldap_args_t a;
- NSS_STATUS status;
-
- LA_INIT (a);
- LA_STRING (a) = NSS_ARGS (args)->key.name;
- LA_TYPE (a) = LA_TYPE_STRING;
-
- status = _nss_ldap_getbyname (&a,
- NSS_ARGS (args)->buf.result,
- NSS_ARGS (args)->buf.buffer,
- NSS_ARGS (args)->buf.buflen,
- &NSS_ARGS (args)->erange,
- _nss_ldap_filt_getnetbyname,
- LM_NETWORKS, _nss_ldap_parse_net);
-
- if (status == NSS_SUCCESS)
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result;
-
- MAP_H_ERRNO (status, NSS_ARGS (args)->h_errno);
-
- return status;
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getnetbyname_r (const char *name, struct netent * result,
char *buffer, size_t buflen, int *errnop,
int *herrnop)
{
- NSS_STATUS status;
+ enum nss_status status;
ldap_args_t a;
LA_INIT (a);
@@ -172,48 +126,29 @@ _nss_ldap_getnetbyname_r (const char *name, struct netent * result,
return status;
}
-#endif
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getnetbyaddr_r (nss_backend_t * be, void *args)
-#else
-NSS_STATUS
+enum nss_status
_nss_ldap_getnetbyaddr_r (unsigned long addr, int type,
struct netent * result, char *buffer, size_t buflen,
int *errnop, int *herrnop)
-#endif
{
struct in_addr in;
char buf[256];
int blen;
ldap_args_t a;
- NSS_STATUS retval = NSS_NOTFOUND;
+ enum nss_status retval = NSS_NOTFOUND;
LA_INIT (a);
LA_TYPE (a) = LA_TYPE_STRING;
-#ifdef HAVE_NSSWITCH_H
- in = inet_makeaddr (NSS_ARGS (args)->key.netaddr.net, 0);
-#else
in = inet_makeaddr (addr, 0);
-#endif
strcpy (buf, inet_ntoa (in));
blen = strlen (buf);
LA_STRING (a) = buf;
while (1)
{
-#ifdef HAVE_NSSWITCH_H
- retval =
- _nss_ldap_getbyname (&a, NSS_ARGS (args)->buf.result,
- NSS_ARGS (args)->buf.buffer,
- NSS_ARGS (args)->buf.buflen,
- &NSS_ARGS (args)->erange,
-#else
retval = _nss_ldap_getbyname (&a, result, buffer, buflen, errnop,
-#endif
_nss_ldap_filt_getnetbyaddr,
LM_NETWORKS, _nss_ldap_parse_net);
@@ -229,23 +164,13 @@ _nss_ldap_getnetbyaddr_r (unsigned long addr, int type,
}
else
{
-#ifdef HAVE_NSSWITCH_H
- NSS_ARGS (args)->returnval = NULL;
- MAP_H_ERRNO (retval, NSS_ARGS (args)->h_errno);
-#else
MAP_H_ERRNO (retval, *herrnop);
-#endif
return NSS_NOTFOUND;
}
}
else
{
-#ifdef HAVE_NSSWITCH_H
- NSS_ARGS (args)->returnval = NULL;
- MAP_H_ERRNO (retval, NSS_ARGS (args)->h_errno);
-#else
MAP_H_ERRNO (retval, *herrnop);
-#endif
return retval;
}
}
@@ -256,66 +181,26 @@ _nss_ldap_getnetbyaddr_r (unsigned long addr, int type,
}
}
-#ifdef HAVE_NSSWITCH_H
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result;
- MAP_H_ERRNO (retval, NSS_ARGS (args)->h_errno);
-#else
MAP_H_ERRNO (NSS_SUCCESS, *herrnop);
-#endif
return retval;
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_setnetent_r (nss_backend_t * net_context, void *fakeargs)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_setnetent (void)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+ enum nss_status _nss_ldap_setnetent (void)
{
LOOKUP_SETENT (net_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_endnetent_r (nss_backend_t * net_context, void *fakeargs)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_endnetent (void)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+ enum nss_status _nss_ldap_endnetent (void)
{
LOOKUP_ENDENT (net_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getnetent_r (nss_backend_t * net_context, void *args)
-{
- NSS_STATUS status =
- _nss_ldap_getent (&((nss_ldap_backend_t *) net_context)->state,
- NSS_ARGS (args)->buf.result,
- NSS_ARGS (args)->buf.buffer,
- NSS_ARGS (args)->buf.buflen,
- &NSS_ARGS (args)->erange,
- _nss_ldap_filt_getnetent,
- LM_NETWORKS,
- _nss_ldap_parse_net);
-
- if (status == NSS_SUCCESS)
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result;
-
- return status;
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getnetent_r (struct netent * result, char *buffer, size_t buflen,
int *errnop, int *herrnop)
{
- NSS_STATUS status;
+ enum nss_status status;
status = _nss_ldap_getent (&net_context,
result,
@@ -329,44 +214,3 @@ _nss_ldap_getnetent_r (struct netent * result, char *buffer, size_t buflen,
return status;
}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_networks_destr (nss_backend_t * net_context, void *args)
-{
- return _nss_ldap_default_destr (net_context, args);
-}
-
-static nss_backend_op_t net_ops[] = {
- _nss_ldap_networks_destr,
- _nss_ldap_endnetent_r,
- _nss_ldap_setnetent_r,
- _nss_ldap_getnetent_r,
- _nss_ldap_getnetbyname_r,
- _nss_ldap_getnetbyaddr_r
-};
-
-nss_backend_t *
-_nss_ldap_networks_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_backend_t *be;
-
- if (!(be = (nss_ldap_backend_t *) malloc (sizeof (*be))))
- return NULL;
-
- be->ops = net_ops;
- be->n_ops = sizeof (net_ops) / sizeof (nss_backend_op_t);
-
- if (_nss_ldap_default_constr (be) != NSS_SUCCESS)
- return NULL;
-
- return (nss_backend_t *) be;
-}
-
-#endif /* !HAVE_NSS_H */
-
-#ifdef HAVE_IRS_H
-#include "irs-network.c"
-#endif
diff --git a/ldap-network.h b/ldap-network.h
index 6c6089b..97edf67 100644
--- a/ldap-network.h
+++ b/ldap-network.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,30 +19,15 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_NETWORK_H
#define _LDAP_NSS_LDAP_LDAP_NETWORK_H
-static NSS_STATUS _nss_ldap_parse_net (LDAPMessage * e,
+static enum nss_status _nss_ldap_parse_net (LDAPMessage * e,
ldap_state_t * pvt,
void *result,
char *buffer, size_t buflen);
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS _nss_ldap_getnetbyname_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_getnetbyaddr_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_setnetent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_endnetent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_getnetent_r (nss_backend_t * be, void *fakeargs);
-
-nss_backend_t *_nss_ldap_networks_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-
-#endif /* !HAVE_NSS_H */
-
#endif /* _LDAP_NSS_LDAP_LDAP_NETWORK_H */
diff --git a/ldap-nss.c b/ldap-nss.c
index 6f8d586..a06d08a 100644
--- a/ldap-nss.c
+++ b/ldap-nss.c
@@ -1,6 +1,9 @@
-/* Copyright (C) 1997-2006 Luke Howard.
+/*
+ ldap-nss.c - main file for NSS interface
This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 1997.
+
+ Copyright (C) 1997-2006 Luke Howard
+ Copyright (C) 2006 Arthur de Jong
The nss_ldap library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -16,10 +19,9 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
-
-static char rcsId[] =
- "$Id$";
+
+ $Id$
+*/
#include "config.h"
@@ -75,9 +77,6 @@ static char rcsId[] =
#include <sasl.h>
#endif
-#ifndef HAVE_SNPRINTF
-#include "snprintf.h"
-#endif
#ifdef HAVE_GSSAPI_H
#include <gssapi.h>
#elif defined(HAVE_GSSAPI_GSSAPI_KRB5_H)
@@ -207,12 +206,12 @@ static int do_start_tls (ldap_session_t * session);
/*
* Read configuration file and initialize schema
*/
-static NSS_STATUS do_init (void);
+static enum nss_status do_init (void);
/*
* Open the global session
*/
-static NSS_STATUS do_open (void);
+static enum nss_status do_open (void);
/*
* Perform an asynchronous search.
@@ -231,12 +230,12 @@ static int do_search_s (const char *base, int scope,
/*
* Fetch an LDAP result.
*/
-static NSS_STATUS do_result (ent_context_t * ctx, int all);
+static enum nss_status do_result (ent_context_t * ctx, int all);
/*
* Format a filter given a prototype.
*/
-static NSS_STATUS do_filter (const ldap_args_t * args, const char *filterprot,
+static enum nss_status do_filter (const ldap_args_t * args, const char *filterprot,
ldap_service_search_descriptor_t * sd,
char *filter, size_t filterlen,
char **dynamicFilter, const char **retFilter);
@@ -245,14 +244,14 @@ static NSS_STATUS do_filter (const ldap_args_t * args, const char *filterprot,
* Parse a result, fetching new results until a successful parse
* or exceptional condition.
*/
-static NSS_STATUS do_parse (ent_context_t * ctx, void *result, char *buffer,
+static enum nss_status do_parse (ent_context_t * ctx, void *result, char *buffer,
size_t buflen, int *errnop, parser_t parser);
/*
* Parse a result, fetching results from the result chain
* rather than the server.
*/
-static NSS_STATUS do_parse_s (ent_context_t * ctx, void *result, char *buffer,
+static enum nss_status do_parse_s (ent_context_t * ctx, void *result, char *buffer,
size_t buflen, int *errnop, parser_t parser);
/*
@@ -266,7 +265,7 @@ typedef int (*search_func_t) (const char *, int, const char *,
/*
* Do a search with a reconnect harness.
*/
-static NSS_STATUS
+static enum nss_status
do_with_reconnect (const char *base, int scope,
const char *filter, const char **attrs, int sizelimit,
void *private, search_func_t func);
@@ -274,7 +273,7 @@ do_with_reconnect (const char *base, int scope,
/*
* Map error from LDAP status code to NSS status code
*/
-static NSS_STATUS do_map_error (int rc);
+static enum nss_status do_map_error (int rc);
/*
* Do a bind with a defined timeout
@@ -296,10 +295,10 @@ do_dupfd(int oldfd, int newfd);
static void
do_drop_connection(int sd, int closeSd);
-static NSS_STATUS
+static enum nss_status
do_map_error (int rc)
{
- NSS_STATUS stat;
+ enum nss_status stat;
switch (rc)
{
@@ -463,55 +462,6 @@ do_rebind (LDAP * ld, char **whop, char **credp, int *methodp, int freeit)
}
#endif
-#ifdef HAVE_NSSWITCH_H
-/*
- * Default destructor.
- * The entry point for this function is the destructor in the dispatch
- * table for the switch. Thus, it's safe to grab the mutex from this
- * function.
- */
-NSS_STATUS
-_nss_ldap_default_destr (nss_backend_t * be, void *args)
-{
- debug ("==> _nss_ldap_default_destr");
-
- if ((((nss_ldap_backend_t *) be)->state) != NULL)
- {
- _nss_ldap_enter ();
- _nss_ldap_ent_context_release ((((nss_ldap_backend_t *) be)->state));
- free ((((nss_ldap_backend_t *) be)->state));
- ((nss_ldap_backend_t *) be)->state = NULL;
- _nss_ldap_leave ();
- }
-
- /* Ditch the backend. */
- free (be);
-
- debug ("<== _nss_ldap_default_destr");
-
- return NSS_SUCCESS;
-}
-
-/*
- * This is the default "constructor" which gets called from each
- * constructor, in the NSS dispatch table.
- */
-NSS_STATUS
-_nss_ldap_default_constr (nss_ldap_backend_t * be)
-{
- debug ("==> _nss_ldap_default_constr");
-
- be->state = NULL;
-#ifdef HPUX
- __thread_mutex_init (&__lock, NULL);
-#endif
-
- debug ("<== _nss_ldap_default_constr");
-
- return NSS_SUCCESS;
-}
-#endif /* HAVE_NSSWITCH_H */
-
#if defined(HAVE_PTHREAD_ATFORK) || defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
static void
do_atfork_prepare (void)
@@ -998,7 +948,7 @@ do_close_no_unbind (void)
/*
* A simple alias around do_init().
*/
-NSS_STATUS
+enum nss_status
_nss_ldap_init (void)
{
return do_init ();
@@ -1013,14 +963,14 @@ _nss_ldap_close (void)
do_close ();
}
-static NSS_STATUS
+static enum nss_status
do_init_session (LDAP ** ld, const char *uri, int defport)
{
int rc;
int ldaps;
char uribuf[NSS_BUFSIZ];
char *p;
- NSS_STATUS stat;
+ enum nss_status stat;
ldaps = (strncasecmp (uri, "ldaps://", sizeof ("ldaps://") - 1) == 0);
p = strchr (uri, ':');
@@ -1084,7 +1034,7 @@ do_init_session (LDAP ** ld, const char *uri, int defport)
}
-static NSS_STATUS
+static enum nss_status
do_init (void)
{
ldap_config_t *cfg;
@@ -1092,7 +1042,7 @@ do_init (void)
pid_t pid;
#endif
uid_t euid;
- NSS_STATUS stat;
+ enum nss_status stat;
int sd=-1;
debug ("==> do_init");
@@ -1415,13 +1365,13 @@ do_start_tls (ldap_session_t * session)
* As with do_close(), this assumes ownership of sess.
* It also wants to own __config: is there a potential deadlock here? XXX
*/
-static NSS_STATUS
+static enum nss_status
do_open (void)
{
ldap_config_t *cfg;
int usesasl;
char *bindarg;
- NSS_STATUS stat;
+ enum nss_status stat;
#ifdef LDAP_OPT_NETWORK_TIMEOUT
struct timeval tv;
#endif
@@ -2032,118 +1982,15 @@ _nss_ldap_ent_context_release (ent_context_t * ctx)
return;
}
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_IRS_H)
-/*
- * Make all triple permutations
- */
-static NSS_STATUS
-do_triple_permutations (const char *machine, const char *user,
- const char *domain, char *bufptr, size_t buflen)
-{
- /*
- * Map a triple
- *
- * (M,U,D)
- *
- * to the filter
- *
- * (|(nisNetgroupTriple=P1)...(nisNetgroupTriple=PN))
- *
- * where P1..PN are all permutations of triples that may match
- * ie. including wildcards. Certainly this would be preferable
- * to do server-side with an appropriate matching rule.
- */
- char escaped_machine[3 * (MAXHOSTNAMELEN + 1)];
- char escaped_user[3 * (LOGNAME_MAX + 1)];
- char escaped_domain[3 * (MAXHOSTNAMELEN + 1)];
- const char *AT_NISNETGROUPTRIPLE = AT (nisNetgroupTriple);
- NSS_STATUS stat;
-
-#define ESCAPE_TRIPLE_COMPONENT(component) do { \
- if ((component) == NULL) \
- { \
- (escaped_##component)[0] = '*'; \
- (escaped_##component)[1] = '\0'; \
- } \
- else \
- { \
- stat = _nss_ldap_escape_string((component), (escaped_##component), \
- (sizeof((escaped_##component)))); \
- if (stat != NSS_SUCCESS) \
- return stat; \
- } \
- } while (0)
-
- ESCAPE_TRIPLE_COMPONENT (machine);
- ESCAPE_TRIPLE_COMPONENT (user);
- ESCAPE_TRIPLE_COMPONENT (domain);
-
-#define _APPEND_STRING(_buffer, _buflen, _s, _len) do { \
- if ((_buflen) < (size_t)((_len) + 1)) \
- { \
- return NSS_TRYAGAIN; \
- } \
- memcpy((_buffer), (_s), (_len)); \
- (_buffer)[(_len)] = '\0'; \
- (_buffer) += (_len); \
- (_buflen) -= (_len); \
- } while (0)
-
-#define APPEND_STRING(_buffer, _buflen, _s) _APPEND_STRING(_buffer, _buflen, _s, strlen((_s)))
-#define APPEND_CONSTANT_STRING(_buffer, _buflen, _s) _APPEND_STRING(_buffer, _buflen, _s, (sizeof((_s)) - 1))
-
-#define APPEND_TRIPLE(_buffer, _buflen, _machine, _user, _domain) do { \
- APPEND_CONSTANT_STRING((_buffer), (_buflen), "("); \
- APPEND_STRING((_buffer), (_buflen), AT_NISNETGROUPTRIPLE); \
- APPEND_CONSTANT_STRING((_buffer), (_buflen), "=\\("); \
- if ((_machine) != NULL) \
- { \
- APPEND_STRING((_buffer), (_buflen), (_machine)); \
- } \
- APPEND_CONSTANT_STRING((_buffer), (_buflen), ","); \
- if ((_user) != NULL) \
- { \
- APPEND_STRING((_buffer), (_buflen), (_user)); \
- } \
- APPEND_CONSTANT_STRING((_buffer), (_buflen), ","); \
- if ((_domain) != NULL) \
- { \
- APPEND_STRING((_buffer), (_buflen), (_domain)); \
- } \
- APPEND_CONSTANT_STRING((_buffer), (_buflen), "\\))"); \
- } while (0)
-
- APPEND_CONSTANT_STRING (bufptr, buflen, "(&(");
- APPEND_STRING (bufptr, buflen, AT (objectClass));
- APPEND_CONSTANT_STRING (bufptr, buflen, "=");
- APPEND_STRING (bufptr, buflen, OC (nisNetgroup));
- APPEND_CONSTANT_STRING (bufptr, buflen, ")(|");
-
- APPEND_TRIPLE (bufptr, buflen, escaped_machine, escaped_user,
- escaped_domain);
- APPEND_TRIPLE (bufptr, buflen, escaped_machine, escaped_user, NULL);
- APPEND_TRIPLE (bufptr, buflen, escaped_machine, NULL, NULL);
- APPEND_TRIPLE (bufptr, buflen, NULL, escaped_user, escaped_domain);
- APPEND_TRIPLE (bufptr, buflen, NULL, escaped_user, NULL);
- APPEND_TRIPLE (bufptr, buflen, escaped_machine, NULL, escaped_domain);
- APPEND_TRIPLE (bufptr, buflen, NULL, NULL, escaped_domain);
- APPEND_TRIPLE (bufptr, buflen, NULL, NULL, NULL);
-
- APPEND_CONSTANT_STRING (bufptr, buflen, "))");
-
- return NSS_SUCCESS;
-}
-#endif /* HAVE_NSSWITCH_H || HAVE_IRS_H */
-
/*
* AND or OR a set of filters.
*/
-static NSS_STATUS
+static enum nss_status
do_aggregate_filter (const char **values,
ldap_args_types_t type,
const char *filterprot, char *bufptr, size_t buflen)
{
- NSS_STATUS stat;
+ enum nss_status stat;
const char **valueP;
assert (buflen > sizeof ("(|)"));
@@ -2190,7 +2037,7 @@ do_aggregate_filter (const char **values,
/*
* Do the necessary formatting to create a string filter.
*/
-static NSS_STATUS
+static enum nss_status
do_filter (const ldap_args_t * args, const char *filterprot,
ldap_service_search_descriptor_t * sd, char *userBuf,
size_t userBufSiz, char **dynamicUserBuf, const char **retFilter)
@@ -2198,7 +2045,7 @@ do_filter (const ldap_args_t * args, const char *filterprot,
char buf1[LDAP_FILT_MAXSIZ], buf2[LDAP_FILT_MAXSIZ];
char *filterBufP, filterBuf[LDAP_FILT_MAXSIZ];
size_t filterSiz;
- NSS_STATUS stat = NSS_SUCCESS;
+ enum nss_status stat = NSS_SUCCESS;
debug ("==> do_filter");
@@ -2255,26 +2102,6 @@ do_filter (const ldap_args_t * args, const char *filterprot,
snprintf (filterBufP, filterSiz, filterprot,
args->la_arg1.la_number, buf1);
break;
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_IRS_H)
- case LA_TYPE_TRIPLE:
- do
- {
- stat = do_triple_permutations (args->la_arg1.la_triple.host,
- args->la_arg1.la_triple.user,
- args->la_arg1.la_triple.domain,
- filterBufP, filterSiz);
- if (stat == NSS_TRYAGAIN)
- {
- filterBufP = *dynamicUserBuf = realloc (*dynamicUserBuf,
- 2 * filterSiz);
- if (filterBufP == NULL)
- return NSS_UNAVAIL;
- filterSiz *= 2;
- }
- }
- while (stat == NSS_TRYAGAIN);
- break;
-#endif /* HAVE_NSSWITCH_H || HAVE_IRS_H */
case LA_TYPE_STRING_LIST_OR:
case LA_TYPE_STRING_LIST_AND:
do
@@ -2368,11 +2195,11 @@ do_filter (const ldap_args_t * args, const char *filterprot,
* Wrapper around ldap_result() to skip over search references
* and deal transparently with the last entry.
*/
-static NSS_STATUS
+static enum nss_status
do_result (ent_context_t * ctx, int all)
{
int rc = LDAP_UNAVAILABLE;
- NSS_STATUS stat = NSS_TRYAGAIN;
+ enum nss_status stat = NSS_TRYAGAIN;
struct timeval tv, *tvp;
debug ("==> do_result");
@@ -2489,14 +2316,14 @@ do_result (ent_context_t * ctx, int all)
* Function to call either do_search() or do_search_s() with
* reconnection logic.
*/
-static NSS_STATUS
+static enum nss_status
do_with_reconnect (const char *base, int scope,
const char *filter, const char **attrs, int sizelimit,
void *private, search_func_t search_func)
{
int rc = LDAP_UNAVAILABLE, tries = 0, backoff = 0;
int hard = 1, start_uri = 0, log = 0;
- NSS_STATUS stat = NSS_UNAVAIL;
+ enum nss_status stat = NSS_UNAVAIL;
int maxtries;
debug ("==> do_with_reconnect");
@@ -2737,26 +2564,16 @@ do_search (const char *base, int scope,
}
static void
-do_map_errno (NSS_STATUS status, int *errnop)
+do_map_errno (enum nss_status status, int *errnop)
{
switch (status)
{
case NSS_TRYAGAIN:
-#ifdef HAVE_NSSWITCH_H
- errno = ERANGE;
- *errnop = 1; /* this is really
- erange */
-#else
*errnop = ERANGE;
-#endif /* HAVE_NSSWITCH_H */
break;
-
-#ifndef HAVE_NSSWITCH_H
case NSS_NOTFOUND:
*errnop = ENOENT;
break;
-#endif /* !HAVE_NSSWITCH_H */
-
case NSS_SUCCESS:
default:
*errnop = 0;
@@ -2768,11 +2585,11 @@ do_map_errno (NSS_STATUS status, int *errnop)
* to retrieve them from the LDAP server until one parses
* correctly or there is an exceptional condition.
*/
-static NSS_STATUS
+static enum nss_status
do_parse (ent_context_t * ctx, void *result, char
*buffer, size_t buflen, int *errnop, parser_t parser)
{
- NSS_STATUS parseStat = NSS_NOTFOUND;
+ enum nss_status parseStat = NSS_NOTFOUND;
debug ("==> do_parse");
@@ -2785,7 +2602,7 @@ do_parse (ent_context_t * ctx, void *result, char
*/
do
{
- NSS_STATUS resultStat = NSS_SUCCESS;
+ enum nss_status resultStat = NSS_SUCCESS;
if (ctx->ec_state.ls_retry == 0 &&
(ctx->ec_state.ls_type == LS_TYPE_KEY
@@ -2838,11 +2655,11 @@ do_parse (ent_context_t * ctx, void *result, char
/*
* Parse, fetching reuslts from chain instead of server.
*/
-static NSS_STATUS
+static enum nss_status
do_parse_s (ent_context_t * ctx, void *result, char
*buffer, size_t buflen, int *errnop, parser_t parser)
{
- NSS_STATUS parseStat = NSS_NOTFOUND;
+ enum nss_status parseStat = NSS_NOTFOUND;
LDAPMessage *e = NULL;
debug ("==> do_parse_s");
@@ -2901,7 +2718,7 @@ do_parse_s (ent_context_t * ctx, void *result, char
* for functions that need to retrieve attributes from a DN,
* such as the RFC2307bis group expansion function.
*/
-NSS_STATUS
+enum nss_status
_nss_ldap_read (const char *dn, const char **attributes, LDAPMessage ** res)
{
return do_with_reconnect (dn, LDAP_SCOPE_BASE, "(objectclass=*)",
@@ -3001,7 +2818,7 @@ _nss_ldap_next_attribute (LDAPMessage * entry, BerElement * ber)
* The generic synchronous lookup cover function.
* Assumes caller holds lock.
*/
-NSS_STATUS
+enum nss_status
_nss_ldap_search_s (const ldap_args_t * args,
const char *filterprot, ldap_map_selector_t sel, const
char **user_attrs, int sizelimit, LDAPMessage ** res)
@@ -3011,7 +2828,7 @@ _nss_ldap_search_s (const ldap_args_t * args,
char filterBuf[LDAP_FILT_MAXSIZ], *dynamicFilterBuf = NULL;
const char **attrs, *filter;
int scope;
- NSS_STATUS stat;
+ enum nss_status stat;
ldap_service_search_descriptor_t *sd = NULL;
debug ("==> _nss_ldap_search_s");
@@ -3099,7 +2916,7 @@ _nss_ldap_search_s (const ldap_args_t * args,
* The generic lookup cover function (asynchronous).
* Assumes caller holds lock.
*/
-NSS_STATUS
+enum nss_status
_nss_ldap_search (const ldap_args_t * args,
const char *filterprot, ldap_map_selector_t sel,
const char **user_attrs, int sizelimit, int *msgid,
@@ -3110,7 +2927,7 @@ _nss_ldap_search (const ldap_args_t * args,
char filterBuf[LDAP_FILT_MAXSIZ], *dynamicFilterBuf = NULL;
const char **attrs, *filter;
int scope;
- NSS_STATUS stat;
+ enum nss_status stat;
ldap_service_search_descriptor_t *sd = NULL;
debug ("==> _nss_ldap_search");
@@ -3196,7 +3013,7 @@ _nss_ldap_search (const ldap_args_t * args,
}
#ifdef HAVE_LDAP_SEARCH_EXT
-static NSS_STATUS
+static enum nss_status
do_next_page (const ldap_args_t * args,
const char *filterprot, ldap_map_selector_t sel, int
sizelimit, int *msgid, struct berval *pCookie)
@@ -3206,7 +3023,7 @@ do_next_page (const ldap_args_t * args,
char filterBuf[LDAP_FILT_MAXSIZ], *dynamicFilterBuf = NULL;
const char **attrs, *filter;
int scope;
- NSS_STATUS stat;
+ enum nss_status stat;
ldap_service_search_descriptor_t *sd = NULL;
LDAPControl *serverctrls[2] = {
NULL, NULL
@@ -3289,13 +3106,13 @@ do_next_page (const ldap_args_t * args,
* enumeration is not completed.
* Locks mutex.
*/
-NSS_STATUS
+enum nss_status
_nss_ldap_getent (ent_context_t ** ctx,
void *result, char *buffer, size_t buflen,
int *errnop, const char *filterprot,
ldap_map_selector_t sel, parser_t parser)
{
- NSS_STATUS status;
+ enum nss_status status;
/*
* we need to lock here as the context may not be thread-specific
@@ -3316,7 +3133,7 @@ _nss_ldap_getent (ent_context_t ** ctx,
* Internal entry point for enumeration routines.
* Caller holds global mutex
*/
-NSS_STATUS
+enum nss_status
_nss_ldap_getent_ex (ldap_args_t * args,
ent_context_t ** ctx, void *result,
char *buffer, size_t buflen, int *errnop,
@@ -3324,7 +3141,7 @@ _nss_ldap_getent_ex (ldap_args_t * args,
ldap_map_selector_t sel,
const char **user_attrs, parser_t parser)
{
- NSS_STATUS stat = NSS_SUCCESS;
+ enum nss_status stat = NSS_SUCCESS;
debug ("==> _nss_ldap_getent_ex");
@@ -3399,13 +3216,13 @@ next:
* General match function.
* Locks mutex.
*/
-NSS_STATUS
+enum nss_status
_nss_ldap_getbyname (ldap_args_t * args,
void *result, char *buffer, size_t buflen, int
*errnop, const char *filterprot,
ldap_map_selector_t sel, parser_t parser)
{
- NSS_STATUS stat = NSS_NOTFOUND;
+ enum nss_status stat = NSS_NOTFOUND;
ent_context_t ctx;
_nss_ldap_enter ();
@@ -3453,7 +3270,7 @@ _nss_ldap_getbyname (ldap_args_t * args,
/*
* Assign all values, bar omitvalue (if not NULL), to *valptr.
*/
-NSS_STATUS
+enum nss_status
_nss_ldap_assign_attrvals (LDAPMessage * e,
const char *attr, const char *omitvalue,
char ***valptr, char **pbuffer, size_t *
@@ -3547,7 +3364,7 @@ _nss_ldap_assign_attrvals (LDAPMessage * e,
}
/* Assign a single value to *valptr. */
-NSS_STATUS
+enum nss_status
_nss_ldap_assign_attrval (LDAPMessage * e,
const char *attr, char **valptr, char **buffer,
size_t * buflen)
@@ -3679,7 +3496,7 @@ _nss_ldap_locate_userpassword (char **vals)
* Assign a single value to *valptr, after examining userPassword for
* a syntactically suitable value.
*/
-NSS_STATUS
+enum nss_status
_nss_ldap_assign_userpassword (LDAPMessage * e,
const char *attr, char **valptr,
char **buffer, size_t * buflen)
@@ -3728,11 +3545,11 @@ _nss_ldap_assign_userpassword (LDAPMessage * e,
return NSS_SUCCESS;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_oc_check (LDAPMessage * e, const char *oc)
{
char **vals, **valiter;
- NSS_STATUS ret = NSS_NOTFOUND;
+ enum nss_status ret = NSS_NOTFOUND;
if (__session.ls_conn == NULL)
{
@@ -3795,7 +3612,7 @@ const char *
_nss_ldap_map_at (ldap_map_selector_t sel, const char *attribute)
{
const char *mapped = NULL;
- NSS_STATUS stat;
+ enum nss_status stat;
stat = _nss_ldap_map_get (__config, sel, MAP_ATTRIBUTE, attribute, &mapped);
@@ -3806,7 +3623,7 @@ const char *
_nss_ldap_unmap_at (ldap_map_selector_t sel, const char *attribute)
{
const char *mapped = NULL;
- NSS_STATUS stat;
+ enum nss_status stat;
stat = _nss_ldap_map_get (__config, sel, MAP_ATTRIBUTE_REVERSE, attribute, &mapped);
@@ -3817,7 +3634,7 @@ const char *
_nss_ldap_map_oc (ldap_map_selector_t sel, const char *objectclass)
{
const char *mapped = NULL;
- NSS_STATUS stat;
+ enum nss_status stat;
stat = _nss_ldap_map_get (__config, sel, MAP_OBJECTCLASS, objectclass, &mapped);
@@ -3828,7 +3645,7 @@ const char *
_nss_ldap_unmap_oc (ldap_map_selector_t sel, const char *objectclass)
{
const char *mapped = NULL;
- NSS_STATUS stat;
+ enum nss_status stat;
stat = _nss_ldap_map_get (__config, sel, MAP_OBJECTCLASS_REVERSE, objectclass, &mapped);
@@ -3855,7 +3672,7 @@ _nss_ldap_map_df (const char *attribute)
return value;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_map_put (ldap_config_t * config,
ldap_map_selector_t sel,
ldap_map_type_t type,
@@ -3864,7 +3681,7 @@ _nss_ldap_map_put (ldap_config_t * config,
{
ldap_datum_t key, val;
void **map;
- NSS_STATUS stat;
+ enum nss_status stat;
switch (type)
{
@@ -3924,7 +3741,7 @@ _nss_ldap_map_put (ldap_config_t * config,
return stat;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_map_get (ldap_config_t * config,
ldap_map_selector_t sel,
ldap_map_type_t type,
@@ -3932,7 +3749,7 @@ _nss_ldap_map_get (ldap_config_t * config,
{
ldap_datum_t key, val;
void *map;
- NSS_STATUS stat;
+ enum nss_status stat;
if (config == NULL || sel > LM_NONE || type > MAP_MAX)
{
@@ -4028,12 +3845,12 @@ do_proxy_rebind (LDAP * ld, char **whop, char **credp, int *methodp,
}
#endif
-NSS_STATUS
+enum nss_status
_nss_ldap_proxy_bind (const char *user, const char *password)
{
ldap_args_t args;
LDAPMessage *res, *e;
- NSS_STATUS stat;
+ enum nss_status stat;
int rc;
#if LDAP_SET_REBIND_PROC_ARGS == 3
ldap_proxy_bind_args_t proxy_args_buf;
diff --git a/ldap-nss.h b/ldap-nss.h
index f49e001..74d1b02 100644
--- a/ldap-nss.h
+++ b/ldap-nss.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_NSS_H
#define _LDAP_NSS_LDAP_LDAP_NSS_H
@@ -54,15 +55,7 @@
#include <netinet/in.h>
#include <syslog.h>
-#ifdef HAVE_NSSWITCH_H
-#include <nss_common.h>
-#include <nss_dbdefs.h>
-#include <nsswitch.h>
-#elif defined(HAVE_NSS_H)
#include <nss.h>
-#elif defined(HAVE_IRS_H)
-#include "irs-nss.h"
-#endif
#include "ldap-schema.h"
@@ -78,7 +71,6 @@
#define NSS_BUFLEN_PASSWD NSS_BUFSIZ
#endif
-#ifndef HAVE_NSSWITCH_H
#define NSS_BUFLEN_HOSTS (NSS_BUFSIZ + (MAXALIASES + MAXALIASES + 2) * sizeof (char *))
#define NSS_BUFLEN_NETGROUP (MAXHOSTNAMELEN * 2 + LOGNAME_MAX + 3)
#define NSS_BUFLEN_NETWORKS NSS_BUFSIZ
@@ -88,7 +80,6 @@
#define NSS_BUFLEN_SHADOW NSS_BUFSIZ
#define NSS_BUFLEN_ETHERS NSS_BUFSIZ
#define NSS_BUFLEN_BOOTPARAMS NSS_BUFSIZ
-#endif /* HAVE_NSSWITCH_H */
/*
* Timeouts for reconnecting code. Similar to rebind
@@ -101,10 +92,6 @@
#define LDAP_NSS_MAXSLEEPTIME 64 /* maximum seconds to sleep */
#define LDAP_NSS_MAXCONNTRIES 2 /* reconnect attempts before sleeping */
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_IRS_H)
-#define LDAP_NSS_MAXNETGR_DEPTH 16 /* maximum depth of netgroup nesting for innetgr() */
-#endif /* HAVE_NSSWITCH_H */
-
#define LDAP_NSS_MAXGR_DEPTH 16 /* maximum depth of group nesting for getgrent()/initgroups() */
#if LDAP_NSS_NGROUPS > 64
@@ -139,11 +126,7 @@
#ifdef DEBUG
#ifdef DEBUG_SYSLOG
-#ifdef HAVE_NSSWITCH_H
-#define debug(fmt, args...) syslog(LOG_AUTHPRIV | LOG_DEBUG, "nss_ldap: %s:%d thread %u - " fmt, __FILE__, __LINE__, thr_self() , ## args)
-#else
#define debug(fmt, args...) syslog(LOG_AUTHPRIV | LOG_DEBUG, "nss_ldap: %s:%d thread %u - " fmt, __FILE__, __LINE__, pthread_self() , ## args)
-#endif /* HAVE_NSSWITCH_H */
#else
#ifndef __GNUC__
#include <stdarg.h>
@@ -439,11 +422,9 @@ struct ldap_session
typedef struct ldap_session ldap_session_t;
-#ifndef HAVE_NSSWITCH_H
#ifndef UID_NOBODY
#define UID_NOBODY (-2)
#endif
-#endif
#ifndef GID_NOBODY
#define GID_NOBODY UID_NOBODY
@@ -572,85 +553,23 @@ struct name_list
struct name_list *next;
};
-#ifdef HAVE_NSSWITCH_H
-
-struct nss_ldap_backend
-{
- nss_backend_op_t *ops;
- int n_ops;
- ent_context_t *state;
-};
-
-typedef struct nss_ldap_backend nss_ldap_backend_t;
-
-struct nss_ldap_netgr_backend
-{
- nss_backend_op_t *ops;
- int n_ops;
- ent_context_t *state;
- struct name_list *known_groups; /* netgroups seen, for loop detection */
- struct name_list *needed_groups; /* nested netgroups to chase */
-};
-
-typedef struct nss_ldap_netgr_backend nss_ldap_netgr_backend_t;
-
-typedef nss_status_t NSS_STATUS;
-
-#define NSS_RETURN NSS_UNAVAIL
-
-#elif defined(HAVE_IRS_H)
-
-typedef enum
-{
- NSS_TRYAGAIN = -2,
- NSS_UNAVAIL,
- NSS_NOTFOUND,
- NSS_SUCCESS,
- NSS_RETURN
-}
-NSS_STATUS;
-
-struct nss_ldap_netgr_backend
-{
- char buffer[NSS_BUFLEN_NETGROUP];
- ent_context_t *state;
- struct name_list *known_groups; /* netgroups seen, for loop detection */
- struct name_list *needed_groups; /* nested netgroups to chase */
-};
-
-typedef struct nss_ldap_netgr_backend nss_ldap_netgr_backend_t;
-#elif defined(HAVE_NSS_H)
-
-typedef enum nss_status NSS_STATUS;
-
#define NSS_SUCCESS NSS_STATUS_SUCCESS
#define NSS_NOTFOUND NSS_STATUS_NOTFOUND
#define NSS_UNAVAIL NSS_STATUS_UNAVAIL
#define NSS_TRYAGAIN NSS_STATUS_TRYAGAIN
#define NSS_RETURN NSS_STATUS_RETURN
-/* to let us index a lookup table on NSS_STATUSes */
+/* to let us index a lookup table on enum nss_statuses */
#define _NSS_LOOKUP_OFFSET NSS_STATUS_TRYAGAIN
-#endif /* HAVE_NSSWITCH_H */
-
#ifndef _NSS_LOOKUP_OFFSET
#define _NSS_LOOKUP_OFFSET (0)
#endif
-typedef NSS_STATUS (*parser_t) (LDAPMessage *, ldap_state_t *, void *,
+typedef enum nss_status (*parser_t) (LDAPMessage *, ldap_state_t *, void *,
char *, size_t);
-#ifdef HPUX
-extern int __thread_mutex_lock(pthread_mutex_t *);
-extern int __thread_mutex_unlock(pthread_mutex_t *);
-#endif /* HPUX */
-
-#ifdef _AIX
-extern int __multi_threaded;
-#endif /* _AIX */
-
/*
* Portable locking macro.
*/
@@ -720,17 +639,6 @@ typedef struct ldap_error ldap_error_t;
#endif /* LDAP_OPT_THREAD_FN_PTRS */
-#ifdef HAVE_NSSWITCH_H
-NSS_STATUS _nss_ldap_default_destr (nss_backend_t *, void *);
-#endif
-
-/*
- * context management routines.
- * _nss_ldap_default_constr() is called once in the constructor
- */
-#ifdef HAVE_NSSWITCH_H
-NSS_STATUS _nss_ldap_default_constr (nss_ldap_backend_t * be);
-#endif
/*
* _nss_ldap_ent_context_init() is called for each getXXent() call
@@ -765,7 +673,7 @@ const char **_nss_ldap_get_attributes (ldap_map_selector_t sel);
/*
* Synchronous search cover (caller acquires lock).
*/
-NSS_STATUS _nss_ldap_search_s (const ldap_args_t * args, /* IN */
+enum nss_status _nss_ldap_search_s (const ldap_args_t * args, /* IN */
const char *filterprot, /* IN */
ldap_map_selector_t sel, /* IN */
const char **user_attrs, /* IN */
@@ -775,7 +683,7 @@ NSS_STATUS _nss_ldap_search_s (const ldap_args_t * args, /* IN */
/*
* Asynchronous search cover (caller acquires lock).
*/
-NSS_STATUS _nss_ldap_search (const ldap_args_t * args, /* IN */
+enum nss_status _nss_ldap_search (const ldap_args_t * args, /* IN */
const char *filterprot, /* IN */
ldap_map_selector_t sel, /* IN */
const char **user_attrs, /* IN */
@@ -786,7 +694,7 @@ NSS_STATUS _nss_ldap_search (const ldap_args_t * args, /* IN */
/*
* Emulate X.500 read operation.
*/
-NSS_STATUS _nss_ldap_read (const char *dn, /* IN */
+enum nss_status _nss_ldap_read (const char *dn, /* IN */
const char **attributes, /* IN */
LDAPMessage ** pRes /* OUT */ );
@@ -794,7 +702,7 @@ NSS_STATUS _nss_ldap_read (const char *dn, /* IN */
* extended enumeration routine; uses asynchronous API.
* Caller must have acquired the global mutex
*/
-NSS_STATUS _nss_ldap_getent_ex (ldap_args_t * args, /* IN */
+enum nss_status _nss_ldap_getent_ex (ldap_args_t * args, /* IN */
ent_context_t ** key, /* IN/OUT */
void *result, /* IN/OUT */
char *buffer, /* IN */
@@ -809,7 +717,7 @@ NSS_STATUS _nss_ldap_getent_ex (ldap_args_t * args, /* IN */
* common enumeration routine; uses asynchronous API.
* Acquires the global mutex
*/
-NSS_STATUS _nss_ldap_getent (ent_context_t ** key, /* IN/OUT */
+enum nss_status _nss_ldap_getent (ent_context_t ** key, /* IN/OUT */
void *result, /* IN/OUT */
char *buffer, /* IN */
size_t buflen, /* IN */
@@ -821,7 +729,7 @@ NSS_STATUS _nss_ldap_getent (ent_context_t ** key, /* IN/OUT */
/*
* common lookup routine; uses synchronous API.
*/
-NSS_STATUS _nss_ldap_getbyname (ldap_args_t * args, /* IN/OUT */
+enum nss_status _nss_ldap_getbyname (ldap_args_t * args, /* IN/OUT */
void *result, /* IN/OUT */
char *buffer, /* IN */
size_t buflen, /* IN */
@@ -831,7 +739,7 @@ NSS_STATUS _nss_ldap_getbyname (ldap_args_t * args, /* IN/OUT */
parser_t parser /* IN */ );
/* parsing utility functions */
-NSS_STATUS _nss_ldap_assign_attrvals (LDAPMessage * e, /* IN */
+enum nss_status _nss_ldap_assign_attrvals (LDAPMessage * e, /* IN */
const char *attr, /* IN */
const char *omitvalue, /* IN */
char ***valptr, /* OUT */
@@ -839,7 +747,7 @@ NSS_STATUS _nss_ldap_assign_attrvals (LDAPMessage * e, /* IN */
size_t * buflen, /* IN/OUT */
size_t * pvalcount /* OUT */ );
-NSS_STATUS _nss_ldap_assign_attrval (LDAPMessage * e, /* IN */
+enum nss_status _nss_ldap_assign_attrval (LDAPMessage * e, /* IN */
const char *attr, /* IN */
char **valptr, /* OUT */
char **buffer, /* IN/OUT */
@@ -848,13 +756,13 @@ NSS_STATUS _nss_ldap_assign_attrval (LDAPMessage * e, /* IN */
const char *_nss_ldap_locate_userpassword (char **vals);
-NSS_STATUS _nss_ldap_assign_userpassword (LDAPMessage * e, /* IN */
+enum nss_status _nss_ldap_assign_userpassword (LDAPMessage * e, /* IN */
const char *attr, /* IN */
char **valptr, /* OUT */
char **buffer, /* IN/OUT */
size_t * buflen); /* IN/OUT */
-NSS_STATUS _nss_ldap_oc_check (LDAPMessage * e, const char *oc);
+enum nss_status _nss_ldap_oc_check (LDAPMessage * e, const char *oc);
#if defined(HAVE_SHADOW_H)
int _nss_ldap_shadow_date(const char *val);
@@ -864,12 +772,12 @@ void _nss_ldap_shadow_handle_flag(struct spwd *sp);
#define _nss_ldap_shadow_handle_flag(_sp) do { /* nothing */ } while (0)
#endif /* HAVE_SHADOW_H */
-NSS_STATUS _nss_ldap_map_put (ldap_config_t * config,
+enum nss_status _nss_ldap_map_put (ldap_config_t * config,
ldap_map_selector_t sel,
ldap_map_type_t map,
const char *key, const char *value);
-NSS_STATUS _nss_ldap_map_get (ldap_config_t * config,
+enum nss_status _nss_ldap_map_get (ldap_config_t * config,
ldap_map_selector_t sel,
ldap_map_type_t map,
const char *key, const char **value);
@@ -894,9 +802,9 @@ struct ldap_proxy_bind_args
typedef struct ldap_proxy_bind_args ldap_proxy_bind_args_t;
-NSS_STATUS _nss_ldap_proxy_bind (const char *user, const char *password);
+enum nss_status _nss_ldap_proxy_bind (const char *user, const char *password);
-NSS_STATUS _nss_ldap_init (void);
+enum nss_status _nss_ldap_init (void);
void _nss_ldap_close (void);
int _nss_ldap_test_config_flag (unsigned int flag);
diff --git a/ldap-parse.h b/ldap-parse.h
index 1234616..083e9c7 100644
--- a/ldap-parse.h
+++ b/ldap-parse.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,80 +19,12 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_PARSE_H
#define _LDAP_NSS_LDAP_LDAP_PARSE_H
-#if defined(HAVE_NSSWITCH_H)
-#define NSS_ARGS(args) ((nss_XbyY_args_t *)args)
-
-#define LOOKUP_NAME(args, filter, selector, parser, req_buflen) \
- ldap_args_t a; \
- NSS_STATUS s; \
- if (NSS_ARGS(args)->buf.buflen < req_buflen) { \
- NSS_ARGS(args)->erange = 1; \
- return NSS_TRYAGAIN; \
- } \
- LA_INIT(a); \
- LA_STRING(a) = NSS_ARGS(args)->key.name; \
- LA_TYPE(a) = LA_TYPE_STRING; \
- s = _nss_ldap_getbyname(&a, \
- NSS_ARGS(args)->buf.result, \
- NSS_ARGS(args)->buf.buffer, \
- NSS_ARGS(args)->buf.buflen, \
- &NSS_ARGS(args)->erange, \
- filter, \
- selector, \
- parser); \
- if (s == NSS_SUCCESS) { \
- NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result; \
- } \
- return s
-#define LOOKUP_NUMBER(args, field, filter, selector, parser, req_buflen) \
- ldap_args_t a; \
- NSS_STATUS s; \
- if (NSS_ARGS(args)->buf.buflen < req_buflen) { \
- NSS_ARGS(args)->erange = 1; \
- return NSS_TRYAGAIN; \
- } \
- LA_INIT(a); \
- LA_NUMBER(a) = NSS_ARGS(args)->field; \
- LA_TYPE(a) = LA_TYPE_NUMBER; \
- s = _nss_ldap_getbyname(&a, \
- NSS_ARGS(args)->buf.result, \
- NSS_ARGS(args)->buf.buffer, \
- NSS_ARGS(args)->buf.buflen, \
- &NSS_ARGS(args)->erange, \
- filter, \
- selector, \
- parser); \
- if (s == NSS_SUCCESS) { \
- NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result; \
- } \
- return s
-#define LOOKUP_GETENT(args, be, filter, selector, parser, req_buflen) \
- NSS_STATUS s; \
- if (NSS_ARGS(args)->buf.buflen < req_buflen) { \
- NSS_ARGS(args)->erange = 1; \
- return NSS_TRYAGAIN; \
- } \
- s = _nss_ldap_getent(&((nss_ldap_backend_t *)be)->state, \
- NSS_ARGS(args)->buf.result, \
- NSS_ARGS(args)->buf.buffer, \
- NSS_ARGS(args)->buf.buflen, \
- &NSS_ARGS(args)->erange, \
- filter, \
- selector, \
- parser); \
- if (s == NSS_SUCCESS) { \
- NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result; \
- } \
- return s
-
-#elif defined(HAVE_NSS_H)
-
#define LOOKUP_NAME(name, result, buffer, buflen, errnop, filter, selector, parser, req_buflen) \
ldap_args_t a; \
if (buflen < req_buflen) { \
@@ -119,63 +52,6 @@
} \
return _nss_ldap_getent(&key, result, buffer, buflen, errnop, filter, selector, parser)
-#elif defined(HAVE_IRS_H)
-
-#define LOOKUP_NAME(name, this, filter, selector, parser, req_buflen) \
- ldap_args_t a; \
- struct pvt *pvt = (struct pvt *)this->private; \
- NSS_STATUS s; \
- LA_INIT(a); \
- LA_STRING(a) = name; \
- LA_TYPE(a) = LA_TYPE_STRING; \
- s = _nss_ldap_getbyname(&a, &pvt->result, pvt->buffer, sizeof(pvt->buffer), &errno, filter, \
- selector, parser); \
- if (s != NSS_SUCCESS) { \
- MAP_ERRNO(s, errno); \
- return NULL; \
- } \
- return &pvt->result;
-#define LOOKUP_NUMBER(number, this, filter, selector, parser, req_buflen) \
- ldap_args_t a; \
- struct pvt *pvt = (struct pvt *)this->private; \
- NSS_STATUS s; \
- LA_INIT(a); \
- LA_NUMBER(a) = number; \
- LA_TYPE(a) = LA_TYPE_NUMBER; \
- s = _nss_ldap_getbyname(&a, &pvt->result, pvt->buffer, sizeof(pvt->buffer), &errno, filter, \
- selector, parser); \
- if (s != NSS_SUCCESS) { \
- MAP_ERRNO(s, errno); \
- return NULL; \
- } \
- return &pvt->result;
-#define LOOKUP_GETENT(this, filter, selector, parser, req_buflen) \
- struct pvt *pvt = (struct pvt *)this->private; \
- NSS_STATUS s; \
- s = _nss_ldap_getent(&pvt->state, &pvt->result, pvt->buffer, \
- sizeof(pvt->buffer), &errno, filter, \
- selector, parser); \
- if (s != NSS_SUCCESS) { \
- MAP_ERRNO(s, errno); \
- return NULL; \
- } \
- return &pvt->result;
-#endif /* HAVE_NSSWITCH_H */
-
-#if defined(HAVE_NSSWITCH_H)
-
-#define LOOKUP_SETENT(key) \
- if (_nss_ldap_ent_context_init(&((nss_ldap_backend_t *)key)->state) == NULL) \
- return NSS_UNAVAIL; \
- return NSS_SUCCESS
-#define LOOKUP_ENDENT(key) \
- _nss_ldap_enter(); \
- _nss_ldap_ent_context_release(((nss_ldap_backend_t *)key)->state); \
- _nss_ldap_leave(); \
- return NSS_SUCCESS
-
-#elif defined(HAVE_NSS_H)
-
#define LOOKUP_SETENT(key) \
if (_nss_ldap_ent_context_init(&key) == NULL) \
return NSS_UNAVAIL; \
@@ -186,17 +62,4 @@
_nss_ldap_leave(); \
return NSS_SUCCESS
-#elif defined(HAVE_IRS_H)
-
-#define LOOKUP_SETENT(this) \
- struct pvt *pvt = (struct pvt *)this->private; \
- (void) _nss_ldap_ent_context_init(&pvt->state)
-#define LOOKUP_ENDENT(this) \
- struct pvt *pvt = (struct pvt *)this->private; \
- _nss_ldap_enter(); \
- _nss_ldap_ent_context_release(pvt->state); \
- _nss_ldap_leave();
-
-#endif /* HAVE_NSSWITCH_H */
-
#endif /* _LDAP_NSS_LDAP_LDAP_PARSE_H */
diff --git a/ldap-proto.c b/ldap-proto.c
index 824a6df..95328c0 100644
--- a/ldap-proto.c
+++ b/ldap-proto.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
/*
Determine the canonical name of the RPC with _nss_ldap_getrdnvalue(),
@@ -26,10 +27,6 @@
as aliases.
*/
-
-static char rcsId[] =
- "$Id$";
-
#include "config.h"
#ifdef HAVE_PORT_BEFORE_H
@@ -62,11 +59,9 @@ static char rcsId[] =
#include <port_after.h>
#endif
-#ifdef HAVE_NSS_H
static ent_context_t *proto_context = NULL;
-#endif
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_proto (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
@@ -74,7 +69,7 @@ _nss_ldap_parse_proto (LDAPMessage * e,
struct protoent *proto = (struct protoent *) result;
char *number;
- NSS_STATUS stat;
+ enum nss_status stat;
stat =
_nss_ldap_getrdnvalue (e, ATM (LM_PROTOCOLS, cn), &proto->p_name,
@@ -99,15 +94,7 @@ _nss_ldap_parse_proto (LDAPMessage * e,
return NSS_SUCCESS;
}
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getprotobyname_r (nss_backend_t * be, void *args)
-{
- LOOKUP_NAME (args, _nss_ldap_filt_getprotobyname, LM_PROTOCOLS,
- _nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getprotobyname_r (const char *name, struct protoent *result,
char *buffer, size_t buflen, int *errnop)
{
@@ -115,17 +102,8 @@ _nss_ldap_getprotobyname_r (const char *name, struct protoent *result,
_nss_ldap_filt_getprotobyname, LM_PROTOCOLS,
_nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getprotobynumber_r (nss_backend_t * be, void *args)
-{
- LOOKUP_NUMBER (args, key.number, _nss_ldap_filt_getprotobynumber,
- LM_PROTOCOLS, _nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getprotobynumber_r (int number, struct protoent *result,
char *buffer, size_t buflen, int *errnop)
{
@@ -133,41 +111,18 @@ _nss_ldap_getprotobynumber_r (int number, struct protoent *result,
_nss_ldap_filt_getprotobynumber, LM_PROTOCOLS,
_nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_setprotoent_r (nss_backend_t * proto_context, void *fakeargs)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_setprotoent (void)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+ enum nss_status _nss_ldap_setprotoent (void)
{
LOOKUP_SETENT (proto_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_endprotoent_r (nss_backend_t * proto_context, void *fakeargs)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_endprotoent (void)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+ enum nss_status _nss_ldap_endprotoent (void)
{
LOOKUP_ENDENT (proto_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getprotoent_r (nss_backend_t * proto_context, void *args)
-{
- LOOKUP_GETENT (args, proto_context, _nss_ldap_filt_getprotoent,
- LM_PROTOCOLS, _nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getprotoent_r (struct protoent *result, char *buffer, size_t buflen,
int *errnop)
{
@@ -175,44 +130,3 @@ _nss_ldap_getprotoent_r (struct protoent *result, char *buffer, size_t buflen,
_nss_ldap_filt_getprotoent, LM_PROTOCOLS,
_nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_protocols_destr (nss_backend_t * proto_context, void *args)
-{
- return _nss_ldap_default_destr (proto_context, args);
-}
-
-static nss_backend_op_t proto_ops[] = {
- _nss_ldap_protocols_destr,
- _nss_ldap_endprotoent_r,
- _nss_ldap_setprotoent_r,
- _nss_ldap_getprotoent_r,
- _nss_ldap_getprotobyname_r,
- _nss_ldap_getprotobynumber_r
-};
-
-nss_backend_t *
-_nss_ldap_protocols_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_backend_t *be;
-
- if (!(be = (nss_ldap_backend_t *) malloc (sizeof (*be))))
- return NULL;
-
- be->ops = proto_ops;
- be->n_ops = sizeof (proto_ops) / sizeof (nss_backend_op_t);
-
- if (_nss_ldap_default_constr (be) != NSS_SUCCESS)
- return NULL;
-
- return (nss_backend_t *) be;
-}
-
-#endif /* !HAVE_NSS_H */
-
-#ifdef HAVE_IRS_H
-#include "irs-proto.c"
-#endif
diff --git a/ldap-proto.h b/ldap-proto.h
index 623dc2a..f075d72 100644
--- a/ldap-proto.h
+++ b/ldap-proto.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_PROTO_H
#define _LDAP_NSS_LDAP_LDAP_PROTO_H
@@ -30,26 +31,9 @@
*/
-static NSS_STATUS _nss_ldap_parse_proto (LDAPMessage * e,
+static enum nss_status _nss_ldap_parse_proto (LDAPMessage * e,
ldap_state_t * pvt,
void *result,
char *buffer, size_t buflen);
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS _nss_ldap_getprotobyname_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_getprotobynumber_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_setprotoent_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_endprotoent_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_getprotoent_r (nss_backend_t * be,
- void *fakeargs);
-
-nss_backend_t *_nss_ldap_protocols_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-#endif /* HAVE_NSSWITCH_H */
-
#endif /* _LDAP_NSS_LDAP_LDAP_PROTO_H */
diff --git a/ldap-pwd.c b/ldap-pwd.c
index 0eaee03..d9ffb51 100644
--- a/ldap-pwd.c
+++ b/ldap-pwd.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -16,10 +17,7 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
-
-static char rcsId[] =
- "$Id$";
+*/
#include "config.h"
@@ -54,15 +52,13 @@ static char rcsId[] =
#include <port_after.h>
#endif
-#ifdef HAVE_NSS_H
static ent_context_t *pw_context = NULL;
-#endif
-static INLINE NSS_STATUS _nss_ldap_assign_emptystring (char **valptr,
+static INLINE enum nss_status _nss_ldap_assign_emptystring (char **valptr,
char **buffer,
size_t * buflen);
-static INLINE NSS_STATUS
+static INLINE enum nss_status
_nss_ldap_assign_emptystring (char **valptr, char **buffer, size_t * buflen)
{
if (*buflen < 2)
@@ -78,14 +74,14 @@ _nss_ldap_assign_emptystring (char **valptr, char **buffer, size_t * buflen)
return NSS_SUCCESS;
}
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_pw (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
{
struct passwd *pw = (struct passwd *) result;
char *uid, *gid;
- NSS_STATUS stat;
+ enum nss_status stat;
char tmpbuf[ sizeof( uid_t ) * 8 / 3 + 2 ];
size_t tmplen;
char *tmp;
@@ -160,20 +156,6 @@ _nss_ldap_parse_pw (LDAPMessage * e,
if (stat != NSS_SUCCESS)
(void) _nss_ldap_assign_emptystring (&pw->pw_shell, &buffer, &buflen);
-#ifdef HAVE_NSSWITCH_H
- stat =
- _nss_ldap_assign_attrval (e, ATM (LM_PASSWD, description),
- &pw->pw_comment, &buffer, &buflen);
- if (stat != NSS_SUCCESS)
- {
- /*
- * Fix for recall #233
- */
- pw->pw_comment = pw->pw_gecos;
- }
- (void) _nss_ldap_assign_emptystring (&pw->pw_age, &buffer, &buflen);
-#endif /* HAVE_NSSWITCH_H */
-
#ifdef HAVE_PASSWD_PW_CHANGE
tmp = NULL;
stat =
@@ -203,8 +185,7 @@ _nss_ldap_parse_pw (LDAPMessage * e,
return NSS_SUCCESS;
}
-#ifdef HAVE_NSS_H
-NSS_STATUS
+enum nss_status
_nss_ldap_getpwnam_r (const char *name,
struct passwd * result,
char *buffer, size_t buflen, int *errnop)
@@ -212,17 +193,8 @@ _nss_ldap_getpwnam_r (const char *name,
LOOKUP_NAME (name, result, buffer, buflen, errnop, _nss_ldap_filt_getpwnam,
LM_PASSWD, _nss_ldap_parse_pw, LDAP_NSS_BUFLEN_DEFAULT);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_getpwnam_r (nss_backend_t * be, void *args)
-{
- LOOKUP_NAME (args, _nss_ldap_filt_getpwnam, LM_PASSWD, _nss_ldap_parse_pw,
- LDAP_NSS_BUFLEN_DEFAULT);
-}
-#endif /* HAVE_NSS_H */
-#ifdef HAVE_NSS_H
-NSS_STATUS
+enum nss_status
_nss_ldap_getpwuid_r (uid_t uid,
struct passwd *result,
char *buffer, size_t buflen, int *errnop)
@@ -230,45 +202,20 @@ _nss_ldap_getpwuid_r (uid_t uid,
LOOKUP_NUMBER (uid, result, buffer, buflen, errnop, _nss_ldap_filt_getpwuid,
LM_PASSWD, _nss_ldap_parse_pw, LDAP_NSS_BUFLEN_DEFAULT);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_getpwuid_r (nss_backend_t * be, void *args)
-{
- LOOKUP_NUMBER (args, key.uid, _nss_ldap_filt_getpwuid, LM_PASSWD,
- _nss_ldap_parse_pw, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#endif
-#if defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_setpwent (void)
{
LOOKUP_SETENT (pw_context);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_setpwent_r (nss_backend_t * be, void *args)
-{
- LOOKUP_SETENT (be);
-}
-#endif
-#if defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_endpwent (void)
{
LOOKUP_ENDENT (pw_context);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_endpwent_r (nss_backend_t * be, void *args)
-{
- LOOKUP_ENDENT (be);
-}
-#endif
-#ifdef HAVE_NSS_H
-NSS_STATUS
+enum nss_status
_nss_ldap_getpwent_r (struct passwd *result,
char *buffer, size_t buflen, int *errnop)
{
@@ -276,52 +223,3 @@ _nss_ldap_getpwent_r (struct passwd *result,
_nss_ldap_filt_getpwent, LM_PASSWD, _nss_ldap_parse_pw,
LDAP_NSS_BUFLEN_DEFAULT);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_getpwent_r (nss_backend_t * be, void *args)
-{
- LOOKUP_GETENT (args, be, _nss_ldap_filt_getpwent, LM_PASSWD,
- _nss_ldap_parse_pw, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_passwd_destr (nss_backend_t * pw_context, void *args)
-{
- return _nss_ldap_default_destr (pw_context, args);
-}
-
-static nss_backend_op_t passwd_ops[] = {
- _nss_ldap_passwd_destr,
- _nss_ldap_endpwent_r, /* NSS_DBOP_ENDENT */
- _nss_ldap_setpwent_r, /* NSS_DBOP_SETENT */
- _nss_ldap_getpwent_r, /* NSS_DBOP_GETENT */
- _nss_ldap_getpwnam_r, /* NSS_DBOP_PASSWD_BYNAME */
- _nss_ldap_getpwuid_r /* NSS_DBOP_PASSWD_BYUID */
-};
-
-nss_backend_t *
-_nss_ldap_passwd_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_backend_t *be;
-
- if (!(be = (nss_ldap_backend_t *) malloc (sizeof (*be))))
- return NULL;
-
- be->ops = passwd_ops;
- be->n_ops = sizeof (passwd_ops) / sizeof (nss_backend_op_t);
-
- if (_nss_ldap_default_constr (be) != NSS_SUCCESS)
- return NULL;
-
- return (nss_backend_t *) be;
-}
-
-
-#endif /* !HAVE_NSS_H */
-
-#ifdef HAVE_IRS_H
-#include "irs-pwd.c"
-#endif /* HAVE_IRS_H */
diff --git a/ldap-pwd.h b/ldap-pwd.h
index 2175a9d..2f1d44e 100644
--- a/ldap-pwd.h
+++ b/ldap-pwd.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,26 +19,9 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_PWD_H
#define _LDAP_NSS_LDAP_LDAP_PWD_H
-static NSS_STATUS _nss_ldap_parse_pw (LDAPMessage * e,
- ldap_state_t * pvt,
- void *result,
- char *buffer, size_t buflen);
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS _nss_ldap_getpwnam_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_getpwuid_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_setpwent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_endpwent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_getpwent_r (nss_backend_t * be, void *fakeargs);
-
-nss_backend_t *_nss_ldap_passwd_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-#endif
-
#endif /* _LDAP_NSS_LDAP_LDAP_PWD_H */
diff --git a/ldap-rpc.c b/ldap-rpc.c
index a5122e6..7f404d0 100644
--- a/ldap-rpc.c
+++ b/ldap-rpc.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
/*
Determine the canonical name of the RPC with _nss_ldap_getrdnvalue(),
@@ -26,10 +27,6 @@
as aliases.
*/
-
-static char rcsId[] =
- "$Id$";
-
#include "config.h"
#ifdef HAVE_PORT_BEFORE_H
@@ -67,13 +64,9 @@ static char rcsId[] =
#include <port_after.h>
#endif
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
-
-#ifdef HAVE_NSS_H
static ent_context_t *rpc_context = NULL;
-#endif
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_rpc (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
@@ -81,7 +74,7 @@ _nss_ldap_parse_rpc (LDAPMessage * e,
struct rpcent *rpc = (struct rpcent *) result;
char *number;
- NSS_STATUS stat;
+ enum nss_status stat;
stat =
_nss_ldap_getrdnvalue (e, ATM (LM_RPC, cn), &rpc->r_name, &buffer,
@@ -106,15 +99,7 @@ _nss_ldap_parse_rpc (LDAPMessage * e,
return NSS_SUCCESS;
}
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getrpcbyname_r (nss_backend_t * be, void *args)
-{
- LOOKUP_NAME (args, _nss_ldap_filt_getrpcbyname, LM_RPC,
- _nss_ldap_parse_rpc, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getrpcbyname_r (const char *name, struct rpcent *result,
char *buffer, size_t buflen, int *errnop)
{
@@ -122,17 +107,8 @@ _nss_ldap_getrpcbyname_r (const char *name, struct rpcent *result,
_nss_ldap_filt_getrpcbyname, LM_RPC, _nss_ldap_parse_rpc,
LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getrpcbynumber_r (nss_backend_t * be, void *args)
-{
- LOOKUP_NUMBER (args, key.number, _nss_ldap_filt_getrpcbynumber, LM_RPC,
- _nss_ldap_parse_rpc, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getrpcbynumber_r (int number, struct rpcent *result,
char *buffer, size_t buflen, int *errnop)
{
@@ -140,41 +116,18 @@ _nss_ldap_getrpcbynumber_r (int number, struct rpcent *result,
_nss_ldap_filt_getrpcbynumber, LM_RPC, _nss_ldap_parse_rpc,
LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_setrpcent_r (nss_backend_t * rpc_context, void *args)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_setrpcent (void)
-#endif
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
+ enum nss_status _nss_ldap_setrpcent (void)
{
LOOKUP_SETENT (rpc_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_endrpcent_r (nss_backend_t * rpc_context, void *args)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_endrpcent (void)
-#endif
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
+ enum nss_status _nss_ldap_endrpcent (void)
{
LOOKUP_ENDENT (rpc_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getrpcent_r (nss_backend_t * rpc_context, void *args)
-{
- LOOKUP_GETENT (args, rpc_context, _nss_ldap_filt_getrpcent, LM_RPC,
- _nss_ldap_parse_rpc, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getrpcent_r (struct rpcent *result, char *buffer, size_t buflen,
int *errnop)
{
@@ -182,41 +135,3 @@ _nss_ldap_getrpcent_r (struct rpcent *result, char *buffer, size_t buflen,
_nss_ldap_filt_getrpcent, LM_RPC, _nss_ldap_parse_rpc,
LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_rpc_destr (nss_backend_t * rpc_context, void *args)
-{
- return _nss_ldap_default_destr (rpc_context, args);
-}
-
-static nss_backend_op_t rpc_ops[] = {
- _nss_ldap_rpc_destr,
- _nss_ldap_endrpcent_r,
- _nss_ldap_setrpcent_r,
- _nss_ldap_getrpcent_r,
- _nss_ldap_getrpcbyname_r,
- _nss_ldap_getrpcbynumber_r
-};
-
-nss_backend_t *
-_nss_ldap_rpc_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_backend_t *be;
-
- if (!(be = (nss_ldap_backend_t *) malloc (sizeof (*be))))
- return NULL;
-
- be->ops = rpc_ops;
- be->n_ops = sizeof (rpc_ops) / sizeof (nss_backend_op_t);
-
- if (_nss_ldap_default_constr (be) != NSS_SUCCESS)
- return NULL;
-
- return (nss_backend_t *) be;
-}
-#endif /* HAVE_NSSWITCH_H */
-
-#endif /* !HAVE_IRS_H */
diff --git a/ldap-rpc.h b/ldap-rpc.h
index b035341..6f780dc 100644
--- a/ldap-rpc.h
+++ b/ldap-rpc.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_RPC_H
#define _LDAP_NSS_LDAP_LDAP_RPC_H
@@ -29,25 +30,9 @@
* as aliases.
*/
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
-static NSS_STATUS _nss_ldap_parse_rpc (LDAPMessage * e,
+static enum nss_status _nss_ldap_parse_rpc (LDAPMessage * e,
ldap_state_t * pvt,
void *result,
char *buffer, size_t buflen);
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS _nss_ldap_getrpcbyname_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_getrpcbynumber_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_setrpcent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_endrpcent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_getrpcent_r (nss_backend_t * be, void *fakeargs);
-
-nss_backend_t *_nss_ldap_rpc_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-#endif /* !HAVE_IRS_H */
#endif /* _LDAP_NSS_LDAP_LDAP_RPC_H */
diff --git a/ldap-schema.c b/ldap-schema.c
index 7bfb37e..746a301 100644
--- a/ldap-schema.c
+++ b/ldap-schema.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 2000.
@@ -18,10 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
-
-static char rcsId[] =
- "$Id$";
+*/
#include "config.h"
@@ -49,9 +47,6 @@ static char rcsId[] =
#include <ldap.h>
#endif
-#ifndef HAVE_SNPRINTF
-#include "snprintf.h"
-#endif /* HAVE_SNPRINTF */
#include "ldap-nss.h"
#include "ldap-schema.h"
#include "util.h"
diff --git a/ldap-schema.h b/ldap-schema.h
index 9178114..4d2d900 100644
--- a/ldap-schema.h
+++ b/ldap-schema.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1999.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_SCHEMA_H
#define _LDAP_NSS_LDAP_LDAP_SCHEMA_H
diff --git a/ldap-service.c b/ldap-service.c
index 31985fb..7f137e0 100644
--- a/ldap-service.c
+++ b/ldap-service.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
/*
Determine the canonical name of the RPC with _nss_ldap_getrdnvalue(),
@@ -26,10 +27,6 @@
as aliases.
*/
-
-static char rcsId[] =
- "$Id$";
-
#include "config.h"
#ifdef HAVE_PORT_BEFORE_H
@@ -67,18 +64,16 @@ static char rcsId[] =
#include <port_after.h>
#endif
-#ifdef HAVE_NSS_H
static ent_context_t *serv_context = NULL;
-#endif
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_serv (LDAPMessage * e,
ldap_state_t * state,
void *result, char *buffer, size_t buflen)
{
struct servent *service = (struct servent *) result;
char *port;
- NSS_STATUS stat = NSS_SUCCESS;
+ enum nss_status stat = NSS_SUCCESS;
/* this is complicated and ugly, because some git (me) specified that service
* entries should expand to two entities (or more) if they have multi-valued
@@ -187,36 +182,7 @@ _nss_ldap_parse_serv (LDAPMessage * e,
return NSS_SUCCESS;
}
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getservbyname_r (nss_backend_t * be, void *args)
-{
- ldap_args_t a;
- NSS_STATUS status;
-
- LA_INIT (a);
- LA_STRING (a) = NSS_ARGS (args)->key.serv.serv.name;
- LA_TYPE (a) = (NSS_ARGS (args)->key.serv.proto == NULL) ?
- LA_TYPE_STRING : LA_TYPE_STRING_AND_STRING;
- LA_STRING2 (a) = NSS_ARGS (args)->key.serv.proto;
-
- status = _nss_ldap_getbyname (&a,
- NSS_ARGS (args)->buf.result,
- NSS_ARGS (args)->buf.buffer,
- NSS_ARGS (args)->buf.buflen,
- &NSS_ARGS (args)->erange,
- (NSS_ARGS (args)->key.serv.proto == NULL) ?
- _nss_ldap_filt_getservbyname :
- _nss_ldap_filt_getservbynameproto, LM_SERVICES,
- _nss_ldap_parse_serv);
-
- if (status == NSS_SUCCESS)
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result;
-
- return status;
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getservbyname_r (const char *name,
const char *proto,
struct servent * result,
@@ -234,38 +200,8 @@ _nss_ldap_getservbyname_r (const char *name,
: _nss_ldap_filt_getservbynameproto),
LM_SERVICES, _nss_ldap_parse_serv);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getservbyport_r (nss_backend_t * be, void *args)
-{
- ldap_args_t a;
- NSS_STATUS status;
-
- LA_INIT (a);
- LA_NUMBER (a) = htons (NSS_ARGS (args)->key.serv.serv.port);
- LA_TYPE (a) = (NSS_ARGS (args)->key.serv.proto == NULL) ?
- LA_TYPE_NUMBER : LA_TYPE_NUMBER_AND_STRING;
- LA_STRING2 (a) = NSS_ARGS (args)->key.serv.proto;
-
- status = _nss_ldap_getbyname (&a,
- NSS_ARGS (args)->buf.result,
- NSS_ARGS (args)->buf.buffer,
- NSS_ARGS (args)->buf.buflen,
- &NSS_ARGS (args)->erange,
- (NSS_ARGS (args)->key.serv.proto == NULL) ?
- _nss_ldap_filt_getservbyport :
- _nss_ldap_filt_getservbyportproto, LM_SERVICES,
- _nss_ldap_parse_serv);
-
- if (status == NSS_SUCCESS)
- NSS_ARGS (args)->returnval = NSS_ARGS (args)->buf.result;
-
- return status;
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getservbyport_r (int port,
const char *proto,
struct servent * result,
@@ -283,41 +219,18 @@ _nss_ldap_getservbyport_r (int port,
_nss_ldap_filt_getservbyportproto,
LM_SERVICES, _nss_ldap_parse_serv);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_setservent_r (nss_backend_t * serv_context, void *args)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_setservent (void)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+ enum nss_status _nss_ldap_setservent (void)
{
LOOKUP_SETENT (serv_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_endservent_r (nss_backend_t * serv_context, void *args)
-#elif defined(HAVE_NSS_H)
- NSS_STATUS _nss_ldap_endservent (void)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+ enum nss_status _nss_ldap_endservent (void)
{
LOOKUP_ENDENT (serv_context);
}
-#endif
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_getservent_r (nss_backend_t * serv_context, void *args)
-{
- LOOKUP_GETENT (args, serv_context, _nss_ldap_filt_getservent, LM_SERVICES,
- _nss_ldap_parse_serv, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#elif defined(HAVE_NSS_H)
-NSS_STATUS
+enum nss_status
_nss_ldap_getservent_r (struct servent *result, char *buffer, size_t buflen,
int *errnop)
{
@@ -325,44 +238,3 @@ _nss_ldap_getservent_r (struct servent *result, char *buffer, size_t buflen,
_nss_ldap_filt_getservent, LM_SERVICES,
_nss_ldap_parse_serv, LDAP_NSS_BUFLEN_DEFAULT);
}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_services_destr (nss_backend_t * serv_context, void *args)
-{
- return _nss_ldap_default_destr (serv_context, args);
-}
-
-static nss_backend_op_t services_ops[] = {
- _nss_ldap_services_destr,
- _nss_ldap_endservent_r,
- _nss_ldap_setservent_r,
- _nss_ldap_getservent_r,
- _nss_ldap_getservbyname_r,
- _nss_ldap_getservbyport_r
-};
-
-nss_backend_t *
-_nss_ldap_services_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_backend_t *be;
-
- if (!(be = (nss_ldap_backend_t *) malloc (sizeof (*be))))
- return NULL;
-
- be->ops = services_ops;
- be->n_ops = sizeof (services_ops) / sizeof (nss_backend_op_t);
-
- if (_nss_ldap_default_constr (be) != NSS_SUCCESS)
- return NULL;
-
- return (nss_backend_t *) be;
-}
-
-#endif /* !HAVE_NSS_H */
-
-#ifdef HAVE_IRS_H
-#include "irs-service.c"
-#endif
diff --git a/ldap-service.h b/ldap-service.h
index aa229ed..e4dbc53 100644
--- a/ldap-service.h
+++ b/ldap-service.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,7 +19,7 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_SERVICE_H
#define _LDAP_NSS_LDAP_LDAP_SERVICE_H
@@ -34,23 +35,9 @@
*/
-static NSS_STATUS _nss_ldap_parse_serv (LDAPMessage * e,
+static enum nss_status _nss_ldap_parse_serv (LDAPMessage * e,
ldap_state_t * pvt,
void *result,
char *buffer, size_t buflen);
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS _nss_ldap_getservbyname_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_getservbyport_r (nss_backend_t * be,
- void *fakeargs);
-static NSS_STATUS _nss_ldap_setservent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_endservent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_getservent_r (nss_backend_t * be, void *fakeargs);
-
-nss_backend_t *_nss_ldap_services_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-#endif /* !HAVE_NSS_H */
-
#endif /* _LDAP_NSS_LDAP_LDAP_SERVICE_H */
diff --git a/ldap-sldap.c b/ldap-sldap.c
deleted file mode 100644
index efbc23b..0000000
--- a/ldap-sldap.c
+++ /dev/null
@@ -1,1320 +0,0 @@
-/* Copyright (C) 2006 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 2006.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- $Id$
- */
-
-
-static char rcsId[] =
- "$Id$";
-
-#include "config.h"
-
-#ifdef HAVE_PORT_BEFORE_H
-#include <port_before.h>
-#endif
-
-#if defined(HAVE_THREAD_H) && !defined(_AIX)
-#include <thread.h>
-#elif defined(HAVE_PTHREAD_H)
-#include <pthread.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <netdb.h>
-#include <assert.h>
-
-#ifdef HAVE_LBER_H
-#include <lber.h>
-#endif
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#ifdef HAVE_NET_ROUTE_H
-#include <net/route.h>
-#endif
-#include <net/if.h>
-#include <netinet/in.h>
-
-#include "ldap-nss.h"
-#include "ldap-automount.h"
-#include "ldap-sldap.h"
-#include "util.h"
-
-#ifdef HAVE_PORT_AFTER_H
-#include <port_after.h>
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-
-/*
- * This implements enough of the Solaris libsldap interface in order
- * for the automounter to work.
- */
-
-static ns_ldap_return_code __ns_ldap_initResult (ns_ldap_result_t ** pResult);
-static ns_ldap_return_code __ns_ldap_initSearch (ns_ldap_cookie_t * cookie);
-static ldap_map_selector_t __ns_ldap_str2selector (const char *map);
-static ns_ldap_return_code __ns_ldap_unmapObjectClasses (ns_ldap_cookie_t *
- cookie,
- char **mappedClasses,
- char
- ***pOrigClasses);
-
-#ifdef DEBUG
-static const char *
-NS_LDAP_ERR2STR (ns_ldap_return_code err)
-{
- char *str = NULL;
-
- __ns_ldap_err2str (err, &str);
-
- return str;
-}
-#endif /* DEBUG */
-
-static void **
-__ns_ldap_makeStringParam (const char *string)
-{
- void **p;
-
- p = (void **) malloc (2 * sizeof (void *));
- if (p == NULL)
- {
- return NULL;
- }
- p[0] = strdup (string);
- if (p[0] == NULL)
- {
- free (p);
- return NULL;
- }
- p[1] = NULL;
-
- return p;
-}
-
-char **
-__ns_ldap_getMappedAttributes (const char *service, const char *attribute)
-{
- const char *mapped;
-
- mapped = _nss_ldap_map_at (__ns_ldap_str2selector (service), attribute);
- if (mapped == NULL)
- {
- return NULL;
- }
-
- return (char **) __ns_ldap_makeStringParam (mapped);
-}
-
-char **
-__ns_ldap_getMappedObjectClass (const char *service, const char *objectClass)
-{
- const char *mapped;
-
- mapped = _nss_ldap_map_oc (__ns_ldap_str2selector (service), objectClass);
- if (mapped == NULL)
- {
- return NULL;
- }
-
- return (char **) __ns_ldap_makeStringParam (mapped);
-}
-
-static ns_ldap_return_code
-__ns_ldap_mapError (NSS_STATUS error)
-{
- ns_ldap_return_code code;
-
- switch (error)
- {
- case NSS_SUCCESS:
- code = NS_LDAP_SUCCESS;
- break;
- case NSS_TRYAGAIN:
- code = NS_LDAP_MEMORY;
- break;
- case NSS_NOTFOUND:
- code = NS_LDAP_NOTFOUND;
- break;
- case NSS_UNAVAIL:
- default:
- code = NS_LDAP_OP_FAILED;
- break;
- }
-
- return code;
-}
-
-static ns_ldap_return_code
-__ns_ldap_mapErrorDetail (ns_ldap_return_code code, ns_ldap_error_t ** errorp)
-{
- char *m = NULL;
- char *s = NULL;
-
- *errorp = (ns_ldap_error_t *) calloc (1, sizeof (ns_ldap_error_t));
- if (*errorp == NULL)
- {
- return NS_LDAP_MEMORY;
- }
-
- (*errorp)->status = _nss_ldap_get_ld_errno (&m, &s);
- (*errorp)->message = (m != NULL) ? strdup (m) : NULL;
-
- return code;
-}
-
-ns_ldap_return_code
-__ns_ldap_freeError (ns_ldap_error_t ** errorp)
-{
- if (errorp == NULL)
- {
- return NS_LDAP_INVALID_PARAM;
- }
- if (*errorp != NULL)
- {
- if ((*errorp)->message != NULL)
- {
- free ((*errorp)->message);
- (*errorp)->message = NULL;
- }
- free (*errorp);
- *errorp = NULL;
- }
- return NS_LDAP_SUCCESS;
-}
-
-ns_ldap_return_code
-__ns_ldap_freeParam (void ***data)
-{
- void **p;
-
- if (*data != NULL)
- {
- for (p = *data; *p != NULL; p++)
- {
- free (*p);
- *p = NULL;
- }
- free (*data);
- *data = NULL;
- }
-
- return NS_LDAP_SUCCESS;
-}
-
-
-ns_ldap_return_code
-__ns_ldap_getParam (const ParamIndexType type, void ***data,
- ns_ldap_error_t ** errorp)
-{
- ns_ldap_return_code ret;
-
- *errorp = NULL;
-
- debug ("==> __ns_ldap_getParam (param=%d)", type);
-
- switch (type)
- {
- case NS_LDAP_FILE_VERSION_P:
- *data = __ns_ldap_makeStringParam (NS_LDAP_VERSION);
- ret = NS_LDAP_SUCCESS;
- break;
- default:
- ret = NS_LDAP_INVALID_PARAM;
- break;
- }
-
- debug ("<== __ns_ldap_getParam (ret=%s)", NS_LDAP_ERR2STR (ret));
-
- return ret;
-}
-
-ns_ldap_return_code
-__ns_ldap_freeAttr (ns_ldap_attr_t ** pAttr)
-{
- int i;
- ns_ldap_attr_t *attr = *pAttr;
-
- if (attr != NULL)
- {
- if (attr->attrname != NULL)
- {
- free (attr->attrname);
- }
- if (attr->attrvalue != NULL)
- {
- for (i = 0; i < attr->value_count; i++)
- {
- free (attr->attrvalue[i]);
- }
- free (attr->attrvalue);
- }
- }
-
- return NS_LDAP_SUCCESS;
-}
-
-ns_ldap_return_code
-__ns_ldap_freeEntry (ns_ldap_entry_t ** pentry)
-{
- int i;
- ns_ldap_entry_t *entry = *pentry;
-
- if (entry != NULL)
- {
- if (entry->attr_pair != NULL)
- {
- for (i = 0; i < entry->attr_count; i++)
- {
- __ns_ldap_freeAttr (&entry->attr_pair[i]);
- }
- free (entry->attr_pair);
- }
- free (entry);
- *pentry = NULL;
- }
-
- return NS_LDAP_SUCCESS;
-}
-
-ns_ldap_return_code
-__ns_ldap_freeResult (ns_ldap_result_t ** pResult)
-{
- ns_ldap_result_t *result;
- ns_ldap_entry_t *entry, *next = NULL;
-
- if (pResult == NULL)
- {
- return NS_LDAP_INVALID_PARAM;
- }
-
- result = *pResult;
- if (result == NULL)
- {
- return NS_LDAP_SUCCESS;
- }
-
- entry = result->entry;
-
- while (entry != NULL)
- {
- next = entry->next;
- __ns_ldap_freeEntry (&entry);
- entry = next;
- }
-
- free (result);
- *pResult = NULL;
-
- return NS_LDAP_SUCCESS;
-}
-
-ns_ldap_return_code
-__ns_ldap_allocAttr (ns_ldap_attr_t ** pAttr)
-{
- ns_ldap_attr_t *attr;
-
- *pAttr = NULL;
-
- attr = (ns_ldap_attr_t *) malloc (sizeof (*attr));
- if (attr == NULL)
- {
- return NS_LDAP_MEMORY;
- }
-
- attr->attrname = NULL;
- attr->attrvalue = NULL;
- attr->value_count = 0;
-
- *pAttr = attr;
-
- return NS_LDAP_SUCCESS;
-}
-
-ns_ldap_return_code
-__ns_ldap_parseAttr (ns_ldap_cookie_t * cookie,
- LDAPMessage * entry,
- const char *attribute, ns_ldap_attr_t ** pAttr)
-{
- ns_ldap_attr_t *attr;
- const char *unmappedAttribute;
- ns_ldap_return_code ret;
- char **values;
- int freeValues = 1;
-
- ret = __ns_ldap_allocAttr (&attr);
- if (ret != NS_LDAP_SUCCESS)
- {
- return ret;
- }
-
- if ((cookie->flags & NS_LDAP_NOMAP) == 0)
- {
- unmappedAttribute = _nss_ldap_unmap_at (cookie->sel, attribute);
- if (unmappedAttribute == NULL)
- {
- __ns_ldap_freeAttr (&attr);
- return NS_LDAP_INVALID_PARAM;
- }
- }
- else
- {
- unmappedAttribute = attribute;
- }
-
- attr->attrname = strdup (unmappedAttribute);
- if (attr->attrname == NULL)
- {
- __ns_ldap_freeAttr (&attr);
- return NS_LDAP_MEMORY;
- }
- attr->attrvalue = NULL;
-
- values = _nss_ldap_get_values (entry, attribute);
-
- if ((cookie->flags & NS_LDAP_NOMAP) == 0)
- {
- if (strcasecmp (attribute, "objectClass") == 0)
- {
- /* Map object class values */
- ret =
- __ns_ldap_unmapObjectClasses (cookie, values, &attr->attrvalue);
- if (ret != NS_LDAP_SUCCESS)
- {
- __ns_ldap_freeAttr (&attr);
- return ret;
- }
- }
- }
-
- if (attr->attrvalue == NULL)
- {
- attr->attrvalue = values;
- freeValues = 0;
- }
-
- attr->value_count =
- (attr->attrvalue != NULL) ? ldap_count_values (attr->attrvalue) : 0;
-
- if (freeValues)
- {
- ldap_value_free (values);
- }
-
- *pAttr = attr;
-
- return NS_LDAP_SUCCESS;
-}
-
-ns_ldap_return_code
-__ns_ldap_parseDn (ns_ldap_cookie_t * cookie, LDAPMessage * entry,
- ns_ldap_attr_t ** pAttr)
-{
- ns_ldap_attr_t *attr;
- ns_ldap_return_code ret;
-
- ret = __ns_ldap_allocAttr (&attr);
- if (ret != NS_LDAP_SUCCESS)
- {
- return ret;
- }
-
- attr->attrname = strdup ("dn");
- if (attr->attrname == NULL)
- {
- __ns_ldap_freeAttr (&attr);
- return NS_LDAP_MEMORY;
- }
-
- attr->value_count = 1;
-
- attr->attrvalue = (char **) malloc (1 * sizeof (char *));
- if (attr->attrvalue == NULL)
- {
- __ns_ldap_freeAttr (&attr);
- return NS_LDAP_MEMORY;
- }
-
- attr->attrvalue[0] = _nss_ldap_get_dn (entry);
- if (attr->attrvalue[0] == NULL)
- {
- __ns_ldap_freeAttr (&attr);
- return NS_LDAP_MEMORY;
- }
-
- *pAttr = attr;
-
- return NS_LDAP_SUCCESS;
-}
-
-NSS_STATUS
-__ns_ldap_parseEntry (LDAPMessage * msg, ldap_state_t * state,
- void *result, char *buffer, size_t buflen)
-{
- ns_ldap_cookie_t *cookie = (ns_ldap_cookie_t *) result;
- char *attribute;
- BerElement *ber = NULL;
- ns_ldap_return_code ret = NS_LDAP_SUCCESS;
- ns_ldap_entry_t *entry;
- int attr_count;
-
-#ifdef DEBUG
- {
- char *dn = _nss_ldap_get_dn (msg);
- debug ("==> __ns_ldap_parseEntry (%s)", dn);
- ldap_memfree (dn);
- }
-#endif
-
- entry = (ns_ldap_entry_t *) malloc (sizeof (*entry));
- if (entry == NULL)
- {
- cookie->ret = NS_LDAP_MEMORY;
- debug ("<== __ns_ldap_parseEntry (no memory)");
- return NSS_NOTFOUND;
- }
-
- entry->attr_count = 0;
- entry->attr_pair = NULL;
- entry->next = NULL;
-
- attr_count = 1; /* for DN */
-
- for (attribute = _nss_ldap_first_attribute (msg, &ber);
- attribute != NULL; attribute = _nss_ldap_next_attribute (msg, ber))
- {
- attr_count++;
-#ifdef HAVE_LDAP_MEMFREE
- ldap_memfree (attribute);
-#endif
- }
-
- if (ber != NULL)
- ber_free (ber, 0);
-
- entry->attr_pair =
- (ns_ldap_attr_t **) calloc (attr_count, sizeof (ns_ldap_attr_t *));
- if (entry->attr_pair == NULL)
- {
- __ns_ldap_freeEntry (&entry);
- cookie->ret = NS_LDAP_MEMORY;
- debug ("<== __ns_ldap_parseEntry (no memory)");
- return NSS_NOTFOUND;
- }
-
- ret = __ns_ldap_parseDn (cookie, msg, &entry->attr_pair[entry->attr_count]);
- if (ret != NS_LDAP_SUCCESS)
- {
- __ns_ldap_freeEntry (&entry);
- cookie->ret = ret;
- debug ("<== __ns_ldap_parseEntry (failed to parse DN)");
- return ret;
- }
-
- entry->attr_count++;
-
- for (attribute = _nss_ldap_first_attribute (msg, &ber);
- attribute != NULL; attribute = _nss_ldap_next_attribute (msg, ber))
- {
- ns_ldap_attr_t *attr;
-
- ret = __ns_ldap_parseAttr (cookie, msg, attribute, &attr);
-#ifdef HAVE_LDAP_MEMFREE
- ldap_memfree (attribute);
-#endif
- if (ret != NS_LDAP_SUCCESS)
- {
- continue;
- }
- entry->attr_pair[entry->attr_count++] = attr;
- }
-
- if (ber != NULL)
- ber_free (ber, 0);
-
- if (ret == NS_LDAP_SUCCESS)
- {
- ns_ldap_entry_t *last;
-
- if (cookie->result == NULL)
- {
- ret = __ns_ldap_initResult (&cookie->result);
- if (ret != NS_LDAP_SUCCESS)
- {
- __ns_ldap_freeEntry (&entry);
- cookie->ret = ret;
- debug ("<== __ns_ldap_parseEntry (failed to init result: %s)",
- NS_LDAP_ERR2STR (ret));
- return __ns_ldap_mapError (ret);
- }
- cookie->result->entry = entry;
- }
- else
- {
- assert (cookie->entry != NULL);
-
- for (last = cookie->entry; last->next != NULL; last = last->next)
- ;
- last->next = entry;
- }
-
- cookie->entry = entry;
-
- if (cookie->callback != NULL)
- {
- cookie->cb_ret = (*cookie->callback) (entry, cookie->userdata);
- }
-
- cookie->result->entries_count++;
- }
- else
- {
- __ns_ldap_freeEntry (&entry);
- }
-
- cookie->ret = ret;
-
- debug ("<== __ns_ldap_parseEntry (ret=%s)", NS_LDAP_ERR2STR (ret));
-
- return __ns_ldap_mapError (ret);
-}
-
-static ns_ldap_return_code
-__ns_ldap_initResult (ns_ldap_result_t ** pResult)
-{
- ns_ldap_result_t *result;
-
- result = (ns_ldap_result_t *) malloc (sizeof (ns_ldap_result_t));
- if (result == NULL)
- {
- return NS_LDAP_MEMORY;
- }
-
- result->entries_count = 0;
- result->entry = NULL;
-
- *pResult = result;
-
- return NS_LDAP_SUCCESS;
-}
-
-static ldap_map_selector_t
-__ns_ldap_str2selector (const char *map)
-{
- ldap_map_selector_t sel;
-
- if (map == NULL)
- {
- sel = LM_NONE;
- }
- else
- {
- sel = _nss_ldap_str2selector (map);
-
- if (strcmp (map, "automount") == 0)
- {
- sel = LM_NONE; /* for enumeration only */
- }
- else if (sel == LM_NONE && (strncmp (map, "auto_", 5)) == 0)
- {
- sel = LM_AUTOMOUNT;
- }
- else
- {
- sel = _nss_ldap_str2selector (map);
- }
- }
-
- return sel;
-}
-
-static ns_ldap_return_code
-__ns_ldap_unmapObjectClasses (ns_ldap_cookie_t * cookie, char **mappedClasses,
- char ***pOrigClasses)
-{
- char **origClasses = NULL;
- int count, i;
-
- count = ldap_count_values (mappedClasses);
- origClasses = (char **) calloc (count + 1, sizeof (char *));
- if (origClasses == NULL)
- {
- return NS_LDAP_MEMORY;
- }
-
- for (i = 0; i < count; i++)
- {
- origClasses[i] =
- strdup (_nss_ldap_unmap_oc (cookie->sel, mappedClasses[i]));
- if (origClasses[i] == NULL)
- {
- ldap_value_free (origClasses);
- return NS_LDAP_MEMORY;
- }
- }
- origClasses[i] = NULL;
- *pOrigClasses = origClasses;
-
- return NS_LDAP_SUCCESS;
-}
-
-static ns_ldap_return_code
-__ns_ldap_mapAttributes (ns_ldap_cookie_t * cookie, const char ***pAttributes)
-{
- const char **attributes;
- int i;
-
- *pAttributes = NULL;
-
- if (cookie->attribute == NULL)
- {
- return NS_LDAP_SUCCESS;
- }
-
- for (i = 0; cookie->attribute[i] != NULL; i++)
- ;
-
- attributes = (const char **) calloc (i + 1, sizeof (char **));
- if (attributes == NULL)
- {
- return NS_LDAP_MEMORY;
- }
-
- for (i = 0; cookie->attribute[i] != NULL; i++)
- {
- attributes[i] = _nss_ldap_map_at (cookie->sel, cookie->attribute[i]);
- assert (attributes[i] != NULL);
- }
- attributes[i] = NULL;
- *pAttributes = attributes;
-
- return NS_LDAP_SUCCESS;
-}
-
-static ns_ldap_return_code
-__ns_ldap_emitFilterString (char **pFilter, size_t * len, size_t * size,
- const char *s)
-{
- size_t slen = strlen (s);
- char *filter;
-
- if (*len + slen >= *size)
- {
- /* need some more space */
- size_t newSize = *size;
- char *newFilter;
-
- if (newSize == 0)
- newSize = NSS_BUFSIZ;
- else
- newSize *= 2;
-
- newFilter = realloc (*pFilter, newSize);
- if (newFilter == NULL)
- {
- return NS_LDAP_MEMORY;
- }
- *pFilter = newFilter;
- *size = newSize;
- }
-
- filter = *pFilter;
-
- memcpy (&filter[*len], s, slen);
- filter[*len + slen] = '\0';
-
- *len += slen;
-
- return NS_LDAP_SUCCESS;
-}
-
-
-#define EMIT_STRING(_s) do { \
- ns_ldap_return_code ret = __ns_ldap_emitFilterString(&filter, &len, &size, (_s)); \
- if (ret != NS_LDAP_SUCCESS) { \
- if (filter != NULL) free(filter); \
- return ret; \
- } \
- } while (0)
-
-#define EMIT_CHAR(_c) do { \
- char _s[2]; \
- ns_ldap_return_code ret; \
- _s[0] = _c; \
- _s[1] = '\0'; \
- ret = __ns_ldap_emitFilterString(&filter, &len, &size, (_s)); \
- if (ret != NS_LDAP_SUCCESS) { \
- if (filter != NULL) free(filter); \
- return ret; \
- } \
- } while (0)
-
-
-static ns_ldap_return_code
-__ns_ldap_mapFilter (ns_ldap_cookie_t * cookie, char **pFilter)
-{
- enum
- { EXPECT_LHS, FOUND_LHS, EXPECT_RHS, FOUND_RHS } state;
- char *lhs = NULL;
- char *rhs = NULL;
- size_t len = 0, size = 0;
- char tmp;
- size_t i;
- char *filter = NULL;
- size_t filterLen = strlen (cookie->filter);
-
- state = EXPECT_LHS;
-
- for (i = 0; i <= filterLen; i++)
- {
- switch (state)
- {
- case EXPECT_LHS:
- switch (cookie->filter[i])
- {
- case '(':
- case ')':
- case '&':
- case '|':
- case '!':
- EMIT_CHAR (cookie->filter[i]);
- break;
- default:
- state = FOUND_LHS;
- lhs = &cookie->filter[i];
- break;
- }
- break;
- case FOUND_LHS:
- switch (cookie->filter[i])
- {
- case '<':
- case '=':
- case '>':
- case '~':
- state = EXPECT_RHS;
- tmp = cookie->filter[i];
- cookie->filter[i] = '\0';
- /* map LHS (attribute type) */
- EMIT_STRING (_nss_ldap_map_at (cookie->sel, lhs));
- EMIT_CHAR (tmp);
- break;
- default:
- break;
- }
- break;
- case EXPECT_RHS:
- switch (cookie->filter[i])
- {
- case '<':
- case '=':
- case '>':
- case '~':
- EMIT_CHAR (cookie->filter[i]);
- break;
- default:
- state = FOUND_RHS;
- rhs = &cookie->filter[i];
- break;
- }
- break;
- case FOUND_RHS:
- switch (cookie->filter[i])
- {
- case '&':
- case '|':
- case '!':
- case ')':
- case '\0':
- state = EXPECT_LHS;
- tmp = cookie->filter[i];;
- cookie->filter[i] = '\0';
- if (strcasecmp (lhs, "objectClass") == 0)
- EMIT_STRING (_nss_ldap_map_oc (cookie->sel, rhs));
- else
- EMIT_STRING (rhs);
- if (strcasecmp (rhs, "automount") == 0)
- cookie->sel = LM_AUTOMOUNT;
- EMIT_CHAR (tmp);
- break;
- default:
- break;
- }
- break;
- }
- }
-
- *pFilter = filter;
-
- return NS_LDAP_SUCCESS;
-}
-
-static ns_ldap_return_code
-__ns_ldap_freeCookie (ns_ldap_cookie_t ** pCookie)
-{
- ns_ldap_cookie_t *cookie;
-
- cookie = *pCookie;
-
- if (cookie != NULL)
- {
- if (cookie->map != NULL)
- free (cookie->map);
- if (cookie->filter != NULL)
- free (cookie->filter);
- if (cookie->attribute != NULL)
- ldap_value_free (cookie->attribute);
- if (cookie->state != NULL)
- {
- _nss_ldap_ent_context_release (cookie->state);
- free (cookie->state);
- }
- if (cookie->mapped_filter != NULL)
- free (cookie->mapped_filter);
- if (cookie->mapped_attribute != NULL)
- free (cookie->mapped_attribute);
- _nss_ldap_am_context_free (&cookie->am_state);
- __ns_ldap_freeResult (&cookie->result);
- free (cookie);
- }
-
- *pCookie = NULL;
-
- return NS_LDAP_SUCCESS;
-}
-
-static ns_ldap_return_code
-__ns_ldap_initCookie (const char *map,
- const char *filter,
- int (*init_filter_cb) (const ns_ldap_search_desc_t *
- desc, char **realfilter,
- const void *userdata),
- const char *const *attribute, const ns_cred_t * cred,
- const int flags, ns_ldap_cookie_t ** pCookie,
- int (*callback) (const ns_ldap_entry_t * entry,
- const void *userdata),
- const void *userdata)
-{
- ns_ldap_cookie_t *cookie;
- ns_ldap_return_code ret;
- size_t i;
-
- assert (pCookie != NULL && *pCookie == NULL);
-
- ret = __ns_ldap_mapError (_nss_ldap_init ());
- if (ret != NS_LDAP_SUCCESS)
- {
- return ret;
- }
-
- cookie = (ns_ldap_cookie_t *) calloc (1, sizeof (*cookie));
- if (cookie == NULL)
- {
- return NS_LDAP_MEMORY;
- }
-
- if (filter == NULL)
- {
- __ns_ldap_freeCookie (&cookie);
- return NS_LDAP_INVALID_PARAM;
- }
-
- if (map != NULL)
- {
- cookie->map = strdup (map);
- if (cookie->map == NULL)
- {
- __ns_ldap_freeCookie (&cookie);
- return NS_LDAP_MEMORY;
- }
- }
-
- cookie->filter = strdup (filter);
- if (cookie->filter == NULL)
- {
- __ns_ldap_freeCookie (&cookie);
- return NS_LDAP_MEMORY;
- }
-
- if (attribute != NULL)
- {
- for (i = 0; attribute[i] != NULL; i++)
- ;
-
- cookie->attribute = (char **) calloc (i + 1, sizeof (char *));
- if (cookie->attribute == NULL)
- {
- __ns_ldap_freeCookie (&cookie);
- return NS_LDAP_MEMORY;
- }
-
- for (i = 0; attribute[i] != NULL; i++)
- {
- cookie->attribute[i] = strdup (attribute[i]);
- if (cookie->attribute[i] == NULL)
- {
- __ns_ldap_freeCookie (&cookie);
- return NS_LDAP_MEMORY;
- }
- }
- cookie->attribute[i] = NULL;
- }
-
- cookie->flags = flags;
- cookie->init_filter_cb = init_filter_cb;
- cookie->callback = callback;
- cookie->userdata = userdata;
- cookie->ret = -1;
- cookie->cb_ret = NS_LDAP_CB_NEXT;
- cookie->erange = 0;
- cookie->sel = __ns_ldap_str2selector (map);
-
- if (_nss_ldap_ent_context_init_locked (&cookie->state) == NULL)
- {
- __ns_ldap_freeCookie (&cookie);
- return NS_LDAP_INTERNAL;
- }
-
- cookie->result = NULL;
- cookie->entry = NULL;
-
- ret = __ns_ldap_initSearch (cookie);
- if (ret != NS_LDAP_SUCCESS)
- {
- __ns_ldap_freeCookie (&cookie);
- return ret;
- }
-
- *pCookie = cookie;
-
- return NS_LDAP_SUCCESS;
-}
-
-static ns_ldap_return_code
-__ns_ldap_initSearch (ns_ldap_cookie_t * cookie)
-{
- ns_ldap_return_code ret;
- NSS_STATUS stat;
-
- assert (cookie != NULL);
- assert (cookie->state != NULL);
-
- ret = __ns_ldap_mapAttributes (cookie, &cookie->mapped_attribute);
- if (ret != NS_LDAP_SUCCESS)
- {
- return ret;
- }
-
- ret = __ns_ldap_mapFilter (cookie, &cookie->mapped_filter);
- if (ret != NS_LDAP_SUCCESS)
- {
- return ret;
- }
-
- /*
- * In the automount case, we need to do a search for a list of
- * search bases
- */
- if (cookie->sel == LM_AUTOMOUNT)
- {
- assert (cookie->am_state == NULL);
- assert (cookie->map != NULL);
-
- stat = _nss_ldap_am_context_init (cookie->map, &cookie->am_state);
- if (stat != NSS_SUCCESS)
- {
- return __ns_ldap_mapError (stat);
- }
- }
-
- return ret;
-}
-
-/*
- * Performs a search given an existing cookie
- *
- * If cookie->result != NULL then the entry will be appended to
- * the result list. Use this for implementing __ns_ldap_list().
- *
- * If cookie->result == NULL then a new result list will be
- * allocated. Use this for implementing __ns_ldap_nextEntry().
- *
- * cookie->entry always points to the last entry in cookie->result
- *
- * Caller should acquire global lock
- */
-static ns_ldap_return_code
-__ns_ldap_search (ns_ldap_cookie_t * cookie)
-{
- ldap_args_t a;
- NSS_STATUS stat;
- ldap_automount_context_t *am = cookie->am_state;
-
- LA_INIT (a);
- LA_TYPE (a) = LA_TYPE_NONE;
-
- if (cookie->sel == LM_AUTOMOUNT)
- {
- assert (am != NULL);
- assert (am->lac_dn_count > 0);
-
- LA_BASE (a) = am->lac_dn_list[am->lac_dn_index];
- } /* XXX todo is support maps that are RDNs relative to default search base */
-
- assert (cookie->mapped_filter != NULL);
-
-retry_search:
- cookie->ret = -1;
-
- stat = _nss_ldap_getent_ex (&a, &cookie->state, cookie,
- NULL, 0, &cookie->erange,
- cookie->mapped_filter,
- cookie->sel,
- cookie->mapped_attribute, __ns_ldap_parseEntry);
-
- if (stat == NSS_NOTFOUND &&
- cookie->sel == LM_AUTOMOUNT && am->lac_dn_index < am->lac_dn_count - 1)
- {
- am->lac_dn_index++;
- goto retry_search;
- }
-
- if (cookie->ret < 0)
- {
- cookie->ret = __ns_ldap_mapError (stat);
- }
-
- return cookie->ret;
-}
-
-ns_ldap_return_code
-__ns_ldap_firstEntry (const char *service,
- const char *filter,
- int (*init_filter_cb) (const ns_ldap_search_desc_t *
- desc, char **realfilter,
- const void *userdata),
- const char *const *attribute, const ns_cred_t * cred,
- const int flags, void **pCookie,
- ns_ldap_result_t ** result, ns_ldap_error_t ** errorp,
- const void *userdata)
-{
- ns_ldap_return_code ret;
- ns_ldap_cookie_t *cookie = NULL;
-
- *pCookie = NULL;
- *result = NULL;
- *errorp = NULL;
-
- debug ("==> __ns_ldap_firstEntry (map=%s filter=%s)",
- service != NULL ? service : "(null)", filter);
-
- _nss_ldap_enter ();
-
- ret = __ns_ldap_initCookie (service, filter, init_filter_cb,
- attribute, cred, flags, &cookie, NULL,
- userdata);
- if (ret == NS_LDAP_SUCCESS)
- {
- ret = __ns_ldap_search (cookie);
-
- *result = cookie->result;
- cookie->result = NULL;
- }
-
- __ns_ldap_mapErrorDetail (ret, errorp);
-
- _nss_ldap_leave ();
-
- *pCookie = cookie;
-
- debug ("<== __ns_ldap_firstEntry ret=%s cookie=%p", NS_LDAP_ERR2STR (ret),
- cookie);
-
- return ret;
-}
-
-ns_ldap_return_code
-__ns_ldap_nextEntry (void *_cookie,
- ns_ldap_result_t ** result, ns_ldap_error_t ** errorp)
-{
- ns_ldap_return_code ret;
- ns_ldap_cookie_t *cookie;
-
- *result = NULL;
- *errorp = NULL;
-
- cookie = (ns_ldap_cookie_t *) _cookie;
- if (cookie == NULL)
- {
- return NS_LDAP_INVALID_PARAM;
- }
-
- debug ("==> __ns_ldap_nextEntry cookie=%p", cookie);
-
- _nss_ldap_enter ();
-
- ret = __ns_ldap_search (cookie);
-
- *result = cookie->result;
- cookie->result = NULL;
-
- __ns_ldap_mapErrorDetail (ret, errorp);
-
- _nss_ldap_leave ();
-
- debug ("<== __ns_ldap_nextEntry ret=%s", NS_LDAP_ERR2STR (ret));
-
- return ret;
-}
-
-ns_ldap_return_code
-__ns_ldap_endEntry (void **pCookie, ns_ldap_error_t ** errorp)
-{
- ns_ldap_cookie_t *cookie;
-
- _nss_ldap_enter ();
-
- cookie = (ns_ldap_cookie_t *) * pCookie;
-
- debug ("==> __ns_ldap_freeEntry cookie=%p", cookie);
-
- __ns_ldap_mapErrorDetail (cookie->ret, errorp);
- __ns_ldap_freeCookie (&cookie);
-
- *pCookie = NULL;
-
- _nss_ldap_leave ();
-
- debug ("<== __ns_ldap_freeEntry");
-
- return NS_LDAP_SUCCESS;
-}
-
-ns_ldap_return_code
-__ns_ldap_list (const char *map,
- const char *filter,
- int (*init_filter_cb) (const ns_ldap_search_desc_t * desc,
- char **realfilter,
- const void *userdata),
- const char *const *attribute, const ns_cred_t * cred,
- const int flags, ns_ldap_result_t ** pResult,
- ns_ldap_error_t ** errorp,
- int (*callback) (const ns_ldap_entry_t * entry,
- const void *userdata), const void *userdata)
-{
- ns_ldap_cookie_t *cookie = NULL;
- ns_ldap_result_t *result = NULL;
- ns_ldap_return_code ret;
-
- debug ("==> __ns_ldap_list map=%s filter=%s",
- map != NULL ? map : "(null)", filter);
-
- *pResult = NULL;
- *errorp = NULL;
-
- _nss_ldap_enter ();
-
- ret = __ns_ldap_initCookie (map, filter, init_filter_cb,
- attribute, cred, flags, &cookie, callback,
- userdata);
-
- while (ret == NS_LDAP_SUCCESS)
- {
- ret = __ns_ldap_search (cookie);
-
- if (result == NULL)
- {
- result = cookie->result;
- }
-
- if (cookie->cb_ret != NS_LDAP_CB_NEXT)
- {
- assert (cookie->callback != NULL);
- break;
- }
- }
-
- if (cookie != NULL)
- {
- if (ret == NS_LDAP_NOTFOUND && cookie->entry != NULL)
- {
- ret = NS_LDAP_SUCCESS;
- }
-
- *pResult = result;
- cookie->result = NULL;
- }
-
- __ns_ldap_freeCookie (&cookie);
- __ns_ldap_mapErrorDetail (ret, errorp);
-
- _nss_ldap_leave ();
-
- debug ("<== __ns_ldap_list ret=%s", NS_LDAP_ERR2STR (ret));
-
- return ret;
-}
-
-ns_ldap_return_code
-__ns_ldap_err2str (ns_ldap_return_code err, char **strmsg)
-{
- switch (err)
- {
- case NS_LDAP_SUCCESS:
- case NS_LDAP_SUCCESS_WITH_INFO:
- *strmsg = "Success";
- break;
- case NS_LDAP_OP_FAILED:
- *strmsg = "Operation failed";
- break;
- case NS_LDAP_NOTFOUND:
- *strmsg = "Not found";
- break;
- case NS_LDAP_MEMORY:
- *strmsg = "Out of memory";
- break;
- case NS_LDAP_CONFIG:
- *strmsg = "Configuration error";
- break;
- case NS_LDAP_PARTIAL:
- *strmsg = "Partial results received";
- break;
- case NS_LDAP_INTERNAL:
- *strmsg = "Internal LDAP error";
- break;
- case NS_LDAP_INVALID_PARAM:
- *strmsg = "Invalid parameter";
- break;
- default:
- *strmsg = "Unknown error";
- return NS_LDAP_INVALID_PARAM;
- break;
- }
-
- return NS_LDAP_SUCCESS;
-}
-
-#endif /* HAVE_NSSWITCH_H */
diff --git a/ldap-sldap.h b/ldap-sldap.h
deleted file mode 100644
index 5b1dba8..0000000
--- a/ldap-sldap.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/* Copyright (C) 1997-2006 Luke Howard.
- This file is part of the nss_ldap library.
- Contributed by Luke Howard, <lukeh@padl.com>, 2006.
-
- The nss_ldap library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The nss_ldap library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the nss_ldap library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- $Id$
- */
-
-#ifndef _LDAP_NSS_LDAP_LDAP_SLDAP_H
-#define _LDAP_NSS_LDAP_LDAP_SLDAP_H
-
-#define NS_LDAP_VERSION NS_LDAP_VERSION_2
-#define NS_LDAP_VERSION_1 "1.0"
-#define NS_LDAP_VERSION_2 "2.0"
-
-typedef enum {
- NS_LDAP_FILE_VERSION_P = 0
-} ParamIndexType;
-
-typedef enum {
- NS_LDAP_SUCCESS = 0,
- NS_LDAP_OP_FAILED,
- NS_LDAP_NOTFOUND,
- NS_LDAP_MEMORY,
- NS_LDAP_CONFIG,
- NS_LDAP_PARTIAL,
- NS_LDAP_INTERNAL,
- NS_LDAP_INVALID_PARAM,
- NS_LDAP_SUCCESS_WITH_INFO
-} ns_ldap_return_code;
-
-typedef struct ns_ldap_search_desc {
- char *basedn;
- int scope;
- char *filter;
-} ns_ldap_search_desc_t;
-
-typedef struct ns_ldap_attribute_map {
- char *origAttr;
- char **mappedAttr;
-} ns_ldap_attribute_map_t;
-
-typedef struct ns_ldap_objectclass_map {
- char *origOC;
- char *mappedOC;
-} ns_ldap_objectclass_map_t;
-
-typedef struct ns_ldap_passwd_mgmt {
- int pad[2];
-} ns_ldap_passwd_mgmt_t;
-
-typedef struct ns_ldap_error {
- int status;
- char *message;
- ns_ldap_passwd_mgmt_t pwd_mgmt;
-} ns_ldap_error_t;
-
-typedef struct ns_ldap_attr {
- char *attrname;
- unsigned int value_count;
- char **attrvalue;
-} ns_ldap_attr_t;
-
-typedef struct ns_ldap_entry {
- unsigned int attr_count;
- ns_ldap_attr_t **attr_pair;
- struct ns_ldap_entry *next;
-} ns_ldap_entry_t;
-
-typedef struct ns_ldap_result {
- unsigned int entries_count;
- ns_ldap_entry_t *entry;
-} ns_ldap_result_t;
-
-#define NS_LDAP_HARD 0x001
-#define NS_LDAP_ALL_RES 0x002
-#define NS_LDAP_FOLLOWREF 0x004
-#define NS_LDAP_NOREF 0x008
-#define NS_LDAP_SCOPE_BASE 0x010
-#define NS_LDAP_SCOPE_ONELEVEL 0x020
-#define NS_LDAP_SCOPE_SUBTREE 0x040
-#define NS_LDAP_KEEP_CONN 0x080
-#define NS_LDAP_NEW_CONN 0x400
-#define NS_LDAP_NOMAP 0x800
-
-#define NS_LDAP_CB_NEXT 0
-#define NS_LDAP_CB_DONE 1
-
-typedef struct ns_ldap_cookie {
- char *map;
- char *filter;
- char **attribute;
- int flags;
-
- int (*init_filter_cb)(const ns_ldap_search_desc_t *desc, char **realfilter, const void *userdata);
- int (*callback)(const ns_ldap_entry_t *entry, const void *userdata);
- const void *userdata;
-
- char *mapped_filter;
- const char **mapped_attribute;
-
- int ret;
- int cb_ret;
- int erange;
- ldap_map_selector_t sel;
- ent_context_t *state;
- ldap_automount_context_t *am_state;
-
- ns_ldap_result_t *result;
- ns_ldap_entry_t *entry;
-} ns_ldap_cookie_t;
-
-char **__ns_ldap_getMappedAttributes(const char *service, const char *attribute);
-char **__ns_ldap_getMappedObjectClass(const char *service, const char *attribute);
-
-ns_ldap_return_code __ns_ldap_getParam(const ParamIndexType type, void ***data, ns_ldap_error_t **errorp);
-ns_ldap_return_code __ns_ldap_freeError(ns_ldap_error_t **errorp);
-ns_ldap_return_code __ns_ldap_freeEntry(ns_ldap_entry_t **pentry);
-ns_ldap_return_code __ns_ldap_freeResult(ns_ldap_result_t **result);
-
-typedef void ns_cred_t;
-
-ns_ldap_return_code __ns_ldap_firstEntry(const char *service,
- const char *filter,
- int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
- char **realfilter, const void *userdata),
- const char * const *attribute,
- const ns_cred_t *cred,
- const int flags,
- void **cookie,
- ns_ldap_result_t ** result,
- ns_ldap_error_t **errorp,
- const void *userdata);
-
-ns_ldap_return_code __ns_ldap_nextEntry(
- void *cookie,
- ns_ldap_result_t ** result,
- ns_ldap_error_t **errorp);
-
-ns_ldap_return_code __ns_ldap_endEntry(
- void **cookie,
- ns_ldap_error_t **errorp);
-
-ns_ldap_return_code __ns_ldap_list(
- const char *service,
- const char *filter,
- int (*init_filter_cb)(const ns_ldap_search_desc_t *desc, char **realfilter, const void *userdata),
- const char * const *attribute,
- const ns_cred_t *cred,
- const int flags,
- ns_ldap_result_t **result,
- ns_ldap_error_t **errorp,
- int (*callback)(const ns_ldap_entry_t *entry, const void *userdata),
- const void *userdata);
-
-ns_ldap_return_code __ns_ldap_err2str(ns_ldap_return_code err, char **strmsg);
-
-#endif /* _LDAP_NSS_LDAP_LDAP_SLDAP_H */
diff --git a/ldap-spwd.c b/ldap-spwd.c
index a529c74..e026e2e 100644
--- a/ldap-spwd.c
+++ b/ldap-spwd.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -16,10 +17,9 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
-static char rcsId[] =
- "$Id$";
+ $Id$
+*/
#include "config.h"
@@ -56,19 +56,16 @@ static char rcsId[] =
#include <port_after.h>
#endif
-#if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
-#ifdef HAVE_NSS_H
static ent_context_t *sp_context = NULL;
-#endif
-static NSS_STATUS
+static enum nss_status
_nss_ldap_parse_sp (LDAPMessage * e,
ldap_state_t * pvt,
void *result, char *buffer, size_t buflen)
{
struct spwd *sp = (struct spwd *) result;
- NSS_STATUS stat;
+ enum nss_status stat;
char *tmp = NULL;
stat =
@@ -120,8 +117,7 @@ _nss_ldap_parse_sp (LDAPMessage * e,
return NSS_SUCCESS;
}
-#ifdef HAVE_NSS_H
-NSS_STATUS
+enum nss_status
_nss_ldap_getspnam_r (const char *name,
struct spwd * result,
char *buffer, size_t buflen, int *errnop)
@@ -129,41 +125,18 @@ _nss_ldap_getspnam_r (const char *name,
LOOKUP_NAME (name, result, buffer, buflen, errnop, _nss_ldap_filt_getspnam,
LM_SHADOW, _nss_ldap_parse_sp, LDAP_NSS_BUFLEN_DEFAULT);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_getspnam_r (nss_backend_t * be, void *args)
-{
- LOOKUP_NAME (args, _nss_ldap_filt_getspnam, LM_SHADOW, _nss_ldap_parse_sp,
- LDAP_NSS_BUFLEN_DEFAULT);
-}
-#endif /* HAVE_NSS_H */
-#if defined(HAVE_NSS_H)
-NSS_STATUS _nss_ldap_setspent (void)
-#else
-static NSS_STATUS
-_nss_ldap_setspent_r (nss_backend_t * sp_context, void *args)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+enum nss_status _nss_ldap_setspent (void)
{
LOOKUP_SETENT (sp_context);
}
-#endif
-#if defined(HAVE_NSS_H)
-NSS_STATUS _nss_ldap_endspent (void)
-#else
-static NSS_STATUS
-_nss_ldap_endspent_r (nss_backend_t * sp_context, void *args)
-#endif
-#if defined(HAVE_NSS_H) || defined(HAVE_NSSWITCH_H)
+enum nss_status _nss_ldap_endspent (void)
{
LOOKUP_ENDENT (sp_context);
}
-#endif
-#ifdef HAVE_NSS_H
-NSS_STATUS
+enum nss_status
_nss_ldap_getspent_r (struct spwd *result,
char *buffer, size_t buflen, int *errnop)
{
@@ -171,50 +144,5 @@ _nss_ldap_getspent_r (struct spwd *result,
_nss_ldap_filt_getspent, LM_SHADOW, _nss_ldap_parse_sp,
LDAP_NSS_BUFLEN_DEFAULT);
}
-#elif defined(HAVE_NSSWITCH_H)
-static NSS_STATUS
-_nss_ldap_getspent_r (nss_backend_t * sp_context, void *args)
-{
- LOOKUP_GETENT (args, sp_context, _nss_ldap_filt_getspent, LM_SHADOW,
- _nss_ldap_parse_sp, LDAP_NSS_BUFLEN_DEFAULT);
-}
-#endif
-
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS
-_nss_ldap_shadow_destr (nss_backend_t * sp_context, void *args)
-{
- return _nss_ldap_default_destr (sp_context, args);
-}
-
-static nss_backend_op_t shadow_ops[] = {
- _nss_ldap_shadow_destr,
- _nss_ldap_endspent_r, /* NSS_DBOP_ENDENT */
- _nss_ldap_setspent_r, /* NSS_DBOP_SETENT */
- _nss_ldap_getspent_r, /* NSS_DBOP_GETENT */
- _nss_ldap_getspnam_r /* NSS_DBOP_SHADOW_BYNAME */
-};
-
-
-nss_backend_t *
-_nss_ldap_shadow_constr (const char *db_name,
- const char *src_name, const char *cfg_args)
-{
- nss_ldap_backend_t *be;
-
- if (!(be = (nss_ldap_backend_t *) malloc (sizeof (*be))))
- return NULL;
-
- be->ops = shadow_ops;
- be->n_ops = sizeof (shadow_ops) / sizeof (nss_backend_op_t);
-
- if (_nss_ldap_default_constr (be) != NSS_SUCCESS)
- return NULL;
-
- return (nss_backend_t *) be;
-}
-
-#endif /* !HAVE_NSS_H */
-#endif
#endif /* HAVE_SHADOW_H */
diff --git a/ldap-spwd.h b/ldap-spwd.h
index a313ace..bc6844c 100644
--- a/ldap-spwd.h
+++ b/ldap-spwd.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -18,25 +19,14 @@
Boston, MA 02111-1307, USA.
$Id$
- */
+*/
#ifndef _LDAP_NSS_LDAP_LDAP_SPWD_H
#define _LDAP_NSS_LDAP_LDAP_SPWD_H
-static NSS_STATUS _nss_ldap_parse_sp (LDAPMessage * e,
+static enum nss_status _nss_ldap_parse_sp (LDAPMessage * e,
ldap_state_t * pvt,
void *result,
char *buffer, size_t buflen);
-#ifdef HAVE_NSSWITCH_H
-static NSS_STATUS _nss_ldap_getspnam_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_setspent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_endspent_r (nss_backend_t * be, void *fakeargs);
-static NSS_STATUS _nss_ldap_getspent_r (nss_backend_t * be, void *fakeargs);
-
-nss_backend_t *_nss_ldap_shadow_constr (const char *db_name,
- const char *src_name,
- const char *cfg_args);
-#endif /* !HAVE_NSS_H */
-
#endif /* _LDAP_NSS_LDAP_LDAP_SPWD_H */
diff --git a/ltf.c b/ltf.c
index 8fc4456..d6f18d5 100644
--- a/ltf.c
+++ b/ltf.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -16,9 +17,9 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
-static char rcsId[] = "$Id$";
+ $Id$
+*/
#include "config.h"
@@ -49,7 +50,7 @@ static char rcsId[] = "$Id$";
static void *ltf_mutex_alloc (void);
static void ltf_mutex_free (void *m);
-static NSS_STATUS ltf_tsd_setup (void);
+static enum nss_status ltf_tsd_setup (void);
static void ltf_set_ld_error (int err, char *matched, char *errmsg,
void *dummy);
static int ltf_get_ld_error (char **matched, char **errmsg, void *dummy);
@@ -80,7 +81,7 @@ static int ltf_mutex_unlock (void *);
static pthread_key_t key;
-NSS_STATUS _nss_ldap_ltf_thread_init (LDAP * ld)
+enum nss_status _nss_ldap_ltf_thread_init (LDAP * ld)
{
struct ldap_thread_fns tfns;
@@ -128,13 +129,7 @@ ltf_mutex_lock (void *mutexp)
{
#if defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
return __libc_lock_lock (*(pthread_mutex_t *) mutexp);
-#elif defined(HPUX)
- return __thread_mutex_lock ((pthread_mutex_t *) mutexp);
#else
-# ifdef _AIX
- if (__multi_threaded == 0)
- return 0;
-# endif
return pthread_mutex_lock ((pthread_mutex_t *) mutexp);
#endif /* HAVE_LIBC_LOCK_H || HAVE_BITS_LIBC_LOCK_H */
}
@@ -144,18 +139,12 @@ ltf_mutex_unlock (void *mutexp)
{
#if defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
return __libc_lock_unlock (*(pthread_mutex_t *) mutexp);
-#elif defined(HPUX)
- return __thread_mutex_unlock ((pthread_mutex_t *) mutexp);
#else
-# ifdef _AIX
- if (__multi_threaded == 0)
- return 0;
-# endif
return pthread_mutex_unlock ((pthread_mutex_t *) mutexp);
#endif /* HAVE_LIBC_LOCK_H || HAVE_BITS_LIBC_LOCK_H */
}
-static NSS_STATUS
+static enum nss_status
ltf_tsd_setup (void)
{
void *tsd;
@@ -270,7 +259,7 @@ ltf_destr (void *tsd)
free (tsd);
}
-static NSS_STATUS
+static enum nss_status
ltf_tsd_setup (void)
{
void *tsd;
@@ -331,7 +320,7 @@ ltf_get_errno (void)
return errno;
}
-NSS_STATUS _nss_ldap_ltf_thread_init (LDAP * ld)
+enum nss_status _nss_ldap_ltf_thread_init (LDAP * ld)
{
struct ldap_thread_fns tfns;
diff --git a/ltf.h b/ltf.h
index 329b1a4..bb2e659 100644
--- a/ltf.h
+++ b/ltf.h
@@ -1,5 +1,6 @@
-/* Copyright (C) 1997-2005 Luke Howard.
- Portions Copyright (C) 1997-2002 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
+ Portions Copyright (C) 1997-2002 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
@@ -17,13 +18,13 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
+*/
#ifndef _LDAP_NSS_LDAP_LTF_H
#define _LDAP_NSS_LDAP_LTF_H
#ifdef LDAP_OPT_THREAD_FN_PTRS
-NSS_STATUS _nss_ldap_ltf_thread_init (LDAP * ld);
+enum nss_status _nss_ldap_ltf_thread_init (LDAP * ld);
#endif
#endif /* _LDAP_NSS_LDAP_LTF_H */
diff --git a/nss_common.h b/nss_common.h
index 137b791..373a442 100644
--- a/nss_common.h
+++ b/nss_common.h
@@ -28,6 +28,9 @@
#include <pthread.h>
#endif
+
+#error "not used"
+
typedef enum {
NSS_SUCCESS,
NSS_NOTFOUND,
@@ -36,7 +39,8 @@ typedef enum {
} nss_status_t;
struct nss_backend;
-
+
+
typedef nss_status_t (*nss_backend_op_t)(struct nss_backend *, void *args);
struct nss_backend {
diff --git a/nss_dbdefs.h b/nss_dbdefs.h
deleted file mode 100644
index 7fc4655..0000000
--- a/nss_dbdefs.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- Donated by HP to enable Winbindd to build on HPUX 11.x.
- Copyright (C) Jeremy Allison 2002.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-#ifndef _NSS_DBDEFS_H
-#define _NSS_DBDEFS_H
-
-#include <errno.h>
-#include <netdb.h>
-#include <limits.h>
-
-#ifndef NSS_INCLUDE_UNSAFE
-#define NSS_INCLUDE_UNSAFE 1 /* Build old, MT-unsafe interfaces, */
-#endif /* NSS_INCLUDE_UNSAFE */
-
-enum nss_netgr_argn {
- NSS_NETGR_MACHINE,
- NSS_NETGR_USER,
- NSS_NETGR_DOMAIN,
- NSS_NETGR_N
-};
-
-enum nss_netgr_status {
- NSS_NETGR_FOUND,
- NSS_NETGR_NO,
- NSS_NETGR_NOMEM
-};
-
-struct nss_setnetgrent_args {
- const char *netgroup;
- nss_backend_t *iterator;
-};
-
-struct nss_getnetgrent_args {
- char *buffer;
- int buflen;
- enum nss_netgr_status status;
- char *retp[NSS_NETGR_N];
-};
-
-typedef unsigned nss_innetgr_argc;
-typedef char **nss_innetgr_argv;
-
-struct nss_innetgr_1arg {
- nss_innetgr_argc argc;
- nss_innetgr_argv argv;
-};
-
-struct nss_innetgr_args {
- struct nss_innetgr_1arg arg[NSS_NETGR_N];
- struct nss_innetgr_1arg groups;
- enum nss_netgr_status status;
-};
-
-typedef struct {
- void *result; /* "result" parameter to getXbyY_r() */
- char *buffer; /* "buffer" " " */
- int buflen; /* "buflen" " " */
-} nss_XbyY_buf_t;
-
-extern nss_XbyY_buf_t *_nss_XbyY_buf_alloc(int struct_size, int buffer_size);
-extern void _nss_XbyY_buf_free(nss_XbyY_buf_t *);
-
-union nss_XbyY_key {
- uid_t uid;
- gid_t gid;
- const char *name;
- int number;
- struct {
- long net; /* int on Solaris */
- int type;
- } netaddr;
- struct {
- const char *addr;
- int len;
- int type;
- } hostaddr;
- struct {
- union {
- const char *name;
- int port;
- } serv;
- const char *proto;
- } serv;
- void *ether;
- /* Solaris has private key args here */
-};
-
-typedef struct nss_XbyY_args {
- nss_XbyY_buf_t buf;
- int stayopen;
- /*
- * Support for setXXXent(stayopen)
- * Used only in hosts, protocols,
- * networks, rpc, and services.
- */
- int (*str2ent)(const char *instr, int instr_len, void *ent, char *buffer, int buflen);
- union nss_XbyY_key key;
-
- void *returnval;
- int erange;
-#undef h_errno
- int h_errno;
- nss_status_t status;
-} nss_XbyY_args_t;
-
-struct nss_groupsbymem {
- const char *username;
- gid_t *gid_array;
- int maxgids;
- int force_slow_way;
- int (*str2ent)(const char *instr, int instr_len, void *ent, char *buffer, int buflen);
- nss_status_t (*process_cstr)(const char *instr, int instr_len, struct nss_groupsbymem *);
- int numgids;
-};
-
-#endif /* _NSS_DBDEFS_H */
-
diff --git a/nss_ldap.5 b/nss_ldap.5
index 89f153b..9e8d1dc 100644
--- a/nss_ldap.5
+++ b/nss_ldap.5
@@ -1,5 +1,5 @@
.TH nss_ldap 5
-.\" Copyright 1997-2005 Luke Howard."
+.\" Copyright 1997-2005 Luke Howard"
.\" Copying restrictions apply. See COPYING.
.\" $Id$
.SH NAME
diff --git a/pagectrl.c b/pagectrl.c
index 70b9672..4bf1097 100644
--- a/pagectrl.c
+++ b/pagectrl.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002 Max Caines, All Rights Reserved.
+/*
+ Copyright (C) 2002 Max Caines, All Rights Reserved.
This file is part of the nss_ldap library.
Contributed by Max Caines, <Max.Caines@wlv.ac.uk>, April 2002.
This software is not subject to any license of the University
@@ -18,9 +19,9 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
-static char rcsId[] = "$Id$";
+ $Id$
+*/
#include "config.h"
diff --git a/pagectrl.h b/pagectrl.h
index c5af8db..96bf853 100644
--- a/pagectrl.h
+++ b/pagectrl.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
(The author maintains a non-exclusive licence to distribute this file
@@ -18,7 +19,9 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
+
+ $Id$
+*/
#ifndef _LDAP_NSS_LDAP_PAGECTRL_H
#define _LDAP_NSS_LDAP_PAGECTRL_H
diff --git a/resolve.c b/resolve.c
index ead586b..698f67a 100644
--- a/resolve.c
+++ b/resolve.c
@@ -52,8 +52,6 @@
#include "resolve.h"
-static char rcsId[] = "$Id$";
-
#if defined(HAVE_RES_SEARCH) && defined(HAVE_DN_EXPAND)
#define DECL(X) {#X, T_##X}
diff --git a/resolve.h b/resolve.h
index 5253a8d..182367d 100644
--- a/resolve.h
+++ b/resolve.h
@@ -1,5 +1,3 @@
-
-
/*
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Hvgskolan
* (Royal Institute of Technology, Stockholm, Sweden).
@@ -38,8 +36,6 @@
* SUCH DAMAGE.
*/
-/* $Id$ */
-
/* THIS IS NOT (yet) A PUBLIC INTERFACE */
#ifndef __RESOLVE_H__
diff --git a/snprintf.c b/snprintf.c
deleted file mode 100644
index be64118..0000000
--- a/snprintf.c
+++ /dev/null
@@ -1,374 +0,0 @@
-static char rcsId[] = "$Id$";
-
-#include "config.h"
-
-#ifndef HAVE_SNPRINTF
-
-/**************************************************************
- * Original:
- * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
- * A bombproof version of doprnt (dopr) included.
- * Sigh. This sort of thing is always nasty do deal with. Note that
- * the version here does not include floating point...
- *
- * snprintf() is used instead of sprintf() as it does limit checks
- * for string length. This covers a nasty loophole.
- *
- * The other functions are there to prevent NULL pointers from
- * causing nast effects.
- **************************************************************/
-
-static void dopr ();
-static char *end;
-
-#include "snprintf.h"
-#include <string.h>
-
-#ifdef HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-
-/* varargs declarations: */
-
-#if defined(HAVE_STDARG_H)
-#include <stdarg.h>
-#define HAVE_STDARGS /* let's hope that works everywhere (mj) */
-#define VA_LOCAL_DECL va_list ap;
-#define VA_START(f) va_start(ap, f)
-#define VA_SHIFT(v,t) ; /* no-op for ANSI */
-#define VA_END va_end(ap)
-#else
-#if defined(HAVE_VARARGS_H)
-#include <varargs.h>
-#undef HAVE_STDARGS
-#define VA_LOCAL_DECL va_list ap;
-#define VA_START(f) va_start(ap) /* f is ignored! */
-#define VA_SHIFT(v,t) v = va_arg(ap,t)
-#define VA_END va_end(ap)
-#else
-XX **NO VARARGS ** XX
-#endif
-#endif
-#ifdef HAVE_STDARGS
-int snprintf (char *str, size_t count, const char *fmt, ...);
-int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
-#else
-int snprintf ();
-int vsnprintf ();
-#endif
-
-int
-vsnprintf (str, count, fmt, args)
- char *str;
- size_t count;
- const char *fmt;
- va_list args;
-{
- str[0] = 0;
- end = str + count - 1;
- dopr (str, fmt, args);
- if (count > 0)
- {
- end[0] = 0;
- }
- return (strlen (str));
-}
-
-/* VARARGS3 */
-#ifdef HAVE_STDARGS
-int
-snprintf (char *str, size_t count, const char *fmt, ...)
-#else
-int
-snprintf (va_alist)
- va_dcl
-#endif
-{
-#ifndef HAVE_STDARGS
- char *str;
- size_t count;
- char *fmt;
-#endif
- VA_LOCAL_DECL VA_START (fmt);
- VA_SHIFT (str, char *);
- VA_SHIFT (count, size_t);
- VA_SHIFT (fmt, char *);
- (void) vsnprintf (str, count, fmt, ap);
- VA_END;
- return (strlen (str));
-}
-
-/*
- * dopr(): poor man's version of doprintf
- */
-
-static void fmtstr (char *value, int ljust, int len, int zpad);
-static void fmtnum (long value, int base, int dosign,
- int ljust, int len, int zpad);
-static void dostr (char *);
-static char *output;
-static void dopr_outch (int c);
-
-static void
-dopr (buffer, format, args)
- char *buffer;
- char *format;
- va_list args;
-{
- int ch;
- long value;
- int longflag = 0;
- char *strvalue;
- int ljust;
- int len;
- int zpad;
-
- output = buffer;
- while ((ch = *format++))
- {
- switch (ch)
- {
- case '%':
- ljust = len = zpad = 0;
- nextch:
- ch = *format++;
- switch (ch)
- {
- case 0:
- dostr ("**end of format**");
- return;
- case '-':
- ljust = 1;
- goto nextch;
- case '0': /* set zero padding if len not set */
- if (len == 0)
- zpad = '0';
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- len = len * 10 + ch - '0';
- goto nextch;
- case 'l':
- longflag = 1;
- goto nextch;
- case 'u':
- case 'U':
- /*fmtnum(value,base,dosign,ljust,len,zpad) */
- if (longflag)
- {
- value = va_arg (args, long);
- }
- else
- {
- value = va_arg (args, int);
- }
- fmtnum (value, 10, 0, ljust, len, zpad);
- break;
- case 'o':
- case 'O':
- /*fmtnum(value,base,dosign,ljust,len,zpad) */
- if (longflag)
- {
- value = va_arg (args, long);
- }
- else
- {
- value = va_arg (args, int);
- }
- fmtnum (value, 8, 0, ljust, len, zpad);
- break;
- case 'd':
- case 'D':
- if (longflag)
- {
- value = va_arg (args, long);
- }
- else
- {
- value = va_arg (args, int);
- }
- fmtnum (value, 10, 1, ljust, len, zpad);
- break;
- case 'x':
- if (longflag)
- {
- value = va_arg (args, long);
- }
- else
- {
- value = va_arg (args, int);
- }
- fmtnum (value, 16, 0, ljust, len, zpad);
- break;
- case 'X':
- if (longflag)
- {
- value = va_arg (args, long);
- }
- else
- {
- value = va_arg (args, int);
- }
- fmtnum (value, -16, 0, ljust, len, zpad);
- break;
- case 's':
- strvalue = va_arg (args, char *);
- fmtstr (strvalue, ljust, len, zpad);
- break;
- case 'c':
- ch = va_arg (args, int);
- dopr_outch (ch);
- break;
- case '%':
- dopr_outch (ch);
- continue;
- default:
- dostr ("???????");
- }
- longflag = 0;
- break;
- default:
- dopr_outch (ch);
- break;
- }
- }
- *output = 0;
-}
-
-static void
-fmtstr (value, ljust, len, zpad)
- char *value;
- int ljust, len, zpad;
-{
- int padlen, strlen; /* amount to pad */
-
- if (value == 0)
- {
- value = "<NULL>";
- }
- for (strlen = 0; value[strlen]; ++strlen); /* strlen */
- padlen = len - strlen;
- if (padlen < 0)
- padlen = 0;
- if (ljust)
- padlen = -padlen;
- while (padlen > 0)
- {
- dopr_outch (' ');
- --padlen;
- }
- dostr (value);
- while (padlen < 0)
- {
- dopr_outch (' ');
- ++padlen;
- }
-}
-
-static void
-fmtnum (value, base, dosign, ljust, len, zpad)
- long value;
- int base, dosign, ljust, len, zpad;
-{
- int signvalue = 0;
- unsigned long uvalue;
- char convert[20];
- int place = 0;
- int padlen = 0; /* amount to pad */
- int caps = 0;
-
- /* DEBUGP(("value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n",
- value, base, dosign, ljust, len, zpad )); */
- uvalue = value;
- if (dosign)
- {
- if (value < 0)
- {
- signvalue = '-';
- uvalue = -value;
- }
- }
- if (base < 0)
- {
- caps = 1;
- base = -base;
- }
- do
- {
- convert[place++] =
- (caps ? "0123456789ABCDEF" : "0123456789abcdef")
- [uvalue % (unsigned) base];
- uvalue = (uvalue / (unsigned) base);
- }
- while (uvalue);
- convert[place] = 0;
- padlen = len - place;
- if (padlen < 0)
- padlen = 0;
- if (ljust)
- padlen = -padlen;
- /* DEBUGP(( "str '%s', place %d, sign %c, padlen %d\n",
- convert,place,signvalue,padlen)); */
- if (zpad && padlen > 0)
- {
- if (signvalue)
- {
- dopr_outch (signvalue);
- --padlen;
- signvalue = 0;
- }
- while (padlen > 0)
- {
- dopr_outch (zpad);
- --padlen;
- }
- }
- while (padlen > 0)
- {
- dopr_outch (' ');
- --padlen;
- }
- if (signvalue)
- dopr_outch (signvalue);
- while (place > 0)
- dopr_outch (convert[--place]);
- while (padlen < 0)
- {
- dopr_outch (' ');
- ++padlen;
- }
-}
-
-static void
-dostr (str)
- char *str;
-{
- while (*str)
- dopr_outch (*str++);
-}
-
-static void
-dopr_outch (c)
- int c;
-{
- if (iscntrl (c) && c != '\n' && c != '\t')
- {
- c = '@' + (c & 0x1F);
- if (end == 0 || output < end)
- {
- *output++ = '^';
- }
- }
- if (end == 0 || output < end)
- {
- *output++ = c;
- }
-}
-
-#endif /* !HAVE_SNPRINTF */
diff --git a/snprintf.h b/snprintf.h
deleted file mode 100644
index b61d037..0000000
--- a/snprintf.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**************************************************************
- * Original:
- * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
- * A bombproof version of doprnt (dopr) included.
- * Sigh. This sort of thing is always nasty do deal with. Note that
- * the version here does not include floating point...
- *
- * snprintf() is used instead of sprintf() as it does limit checks
- * for string length. This covers a nasty loophole.
- *
- * The other functions are there to prevent NULL pointers from
- * causing nast effects.
- **************************************************************/
-
-/* keep namespace tidy */
-#define vsnprintf _nss_ldap_vsnprintf
-#define snprintf _nss_ldap_snprintf
-
-#define HAVE_STDARG_H
-#include <sys/types.h>
-/* varargs declarations: */
-/* you might have to hand force this by doing #define HAVE_STDARG_H */
-
-#if defined(HAVE_STDARG_H)
-#include <stdarg.h>
-#define HAVE_STDARGS /* let's hope that works everywhere (mj) */
-#define VA_LOCAL_DECL va_list ap;
-#define VA_START(f) va_start(ap, f)
-#define VA_SHIFT(v,t) ; /* no-op for ANSI */
-#define VA_END va_end(ap)
-#else
-#if defined(HAVE_VARARGS_H)
-#include <varargs.h>
-#undef HAVE_STDARGS
-#define VA_LOCAL_DECL va_list ap;
-#define VA_START(f) va_start(ap) /* f is ignored! */
-#define VA_SHIFT(v,t) v = va_arg(ap,t)
-#define VA_END va_end(ap)
-#else
-XX **NO VARARGS ** XX
-#endif
-#endif
-/* you can have ANSI C definitions */
-#ifdef HAVE_STDARGS
-int snprintf (char *str, size_t count, const char *fmt, ...);
-int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
-void setproctitle (char *fmt, ...);
-#else
-int snprintf ();
-int vsnprintf ();
-void setproctitle ();
-#endif
diff --git a/util.c b/util.c
index c4ada48..d8d6876 100644
--- a/util.c
+++ b/util.c
@@ -1,8 +1,7 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
- (The author maintains a non-exclusive licence to distribute this file
- under their own conditions.)
The nss_ldap library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -18,7 +17,9 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
+
+ $Id$
+*/
#include "config.h"
@@ -51,26 +52,20 @@
#include <ldap.h>
#endif
-#ifndef HAVE_SNPRINTF
-#include "snprintf.h"
-#endif
-
#include "ldap-nss.h"
#include "util.h"
-static char rcsId[] = "$Id$";
-
-static NSS_STATUS do_getrdnvalue (const char *dn,
+static enum nss_status do_getrdnvalue (const char *dn,
const char *rdntype,
char **rval, char **buffer,
size_t * buflen);
-static NSS_STATUS do_parse_map_statement (ldap_config_t * cfg,
+static enum nss_status do_parse_map_statement (ldap_config_t * cfg,
const char *statement,
ldap_map_type_t type);
-static NSS_STATUS do_searchdescriptorconfig (const char *key,
+static enum nss_status do_searchdescriptorconfig (const char *key,
const char *value,
size_t valueLength,
ldap_service_search_descriptor_t
@@ -85,10 +80,10 @@ NSS_LDAP_DEFINE_LOCK (__cache_lock);
#define cache_lock() NSS_LDAP_LOCK(__cache_lock)
#define cache_unlock() NSS_LDAP_UNLOCK(__cache_lock)
-static NSS_STATUS
+static enum nss_status
dn2uid_cache_put (const char *dn, const char *uid)
{
- NSS_STATUS stat;
+ enum nss_status stat;
ldap_datum_t key, val;
cache_lock ();
@@ -115,11 +110,11 @@ dn2uid_cache_put (const char *dn, const char *uid)
return stat;
}
-static NSS_STATUS
+static enum nss_status
dn2uid_cache_get (const char *dn, char **uid, char **buffer, size_t * buflen)
{
ldap_datum_t key, val;
- NSS_STATUS stat;
+ enum nss_status stat;
cache_lock ();
@@ -159,11 +154,11 @@ dn2uid_cache_get (const char *dn, char **uid, char **buffer, size_t * buflen)
static int lock_inited = 0;
#endif
-NSS_STATUS
+enum nss_status
_nss_ldap_dn2uid (const char *dn, char **uid, char **buffer, size_t * buflen,
int *pIsNestedGroup, LDAPMessage ** pRes)
{
- NSS_STATUS stat;
+ enum nss_status stat;
debug ("==> _nss_ldap_dn2uid");
@@ -217,13 +212,13 @@ _nss_ldap_dn2uid (const char *dn, char **uid, char **buffer, size_t * buflen,
return stat;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_getrdnvalue (LDAPMessage * entry,
const char *rdntype,
char **rval, char **buffer, size_t * buflen)
{
char *dn;
- NSS_STATUS status;
+ enum nss_status status;
dn = _nss_ldap_get_dn (entry);
if (dn == NULL)
@@ -273,7 +268,7 @@ _nss_ldap_getrdnvalue (LDAPMessage * entry,
return status;
}
-static NSS_STATUS
+static enum nss_status
do_getrdnvalue (const char *dn,
const char *rdntype,
char **rval, char **buffer, size_t * buflen)
@@ -385,7 +380,7 @@ do_getrdnvalue (const char *dn,
return NSS_NOTFOUND;
}
-static NSS_STATUS
+static enum nss_status
do_parse_map_statement (ldap_config_t * cfg,
const char *statement, ldap_map_type_t type)
{
@@ -416,7 +411,7 @@ do_parse_map_statement (ldap_config_t * cfg,
}
/* parse a comma-separated list */
-static NSS_STATUS
+static enum nss_status
do_parse_list (char *values, char ***valptr,
char **pbuffer, size_t *pbuflen)
{
@@ -519,7 +514,7 @@ _nss_ldap_str2selector (const char *key)
return sel;
}
-static NSS_STATUS
+static enum nss_status
do_searchdescriptorconfig (const char *key, const char *value, size_t len,
ldap_service_search_descriptor_t ** result,
char **buffer, size_t * buflen)
@@ -603,7 +598,7 @@ do_searchdescriptorconfig (const char *key, const char *value, size_t len,
return NSS_SUCCESS;
}
-NSS_STATUS _nss_ldap_init_config (ldap_config_t * result)
+enum nss_status _nss_ldap_init_config (ldap_config_t * result)
{
int i, j;
@@ -674,7 +669,7 @@ NSS_STATUS _nss_ldap_init_config (ldap_config_t * result)
return NSS_SUCCESS;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_add_uri (ldap_config_t *result, const char *uri,
char **buffer, size_t *buflen)
{
@@ -713,13 +708,13 @@ _nss_ldap_add_uri (ldap_config_t *result, const char *uri,
return NSS_SUCCESS;
}
-static NSS_STATUS
+static enum nss_status
do_add_uris (ldap_config_t *result, char *uris,
char **buffer, size_t *buflen)
{
/* Add a space separated list of URIs */
char *p;
- NSS_STATUS stat = NSS_SUCCESS;
+ enum nss_status stat = NSS_SUCCESS;
for (p = uris; p != NULL; )
{
@@ -738,13 +733,13 @@ do_add_uris (ldap_config_t *result, char *uris,
return stat;
}
-static NSS_STATUS
+static enum nss_status
do_add_hosts (ldap_config_t *result, char *hosts,
char **buffer, size_t *buflen)
{
/* Add a space separated list of hosts */
char *p;
- NSS_STATUS stat = NSS_SUCCESS;
+ enum nss_status stat = NSS_SUCCESS;
for (p = hosts; p != NULL; )
{
@@ -767,12 +762,12 @@ do_add_hosts (ldap_config_t *result, char *hosts,
return stat;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_readconfig (ldap_config_t ** presult, char **buffer, size_t *buflen)
{
FILE *fp;
char b[NSS_LDAP_CONFIG_BUFSIZ];
- NSS_STATUS stat = NSS_SUCCESS;
+ enum nss_status stat = NSS_SUCCESS;
ldap_config_t *result;
struct stat statbuf;
@@ -1238,7 +1233,7 @@ _nss_ldap_readconfig (ldap_config_t ** presult, char **buffer, size_t *buflen)
return stat;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_escape_string (const char *str, char *buf, size_t buflen)
{
int ret = NSS_TRYAGAIN;
@@ -1339,7 +1334,7 @@ do_free_dictionary (struct ldap_dictionary *dict)
free (dict);
}
-static NSS_STATUS
+static enum nss_status
do_dup_datum (unsigned flags, ldap_datum_t * dst, const ldap_datum_t * src)
{
dst->data = malloc (src->size);
@@ -1375,7 +1370,7 @@ _nss_ldap_db_close (void *db)
}
}
-NSS_STATUS
+enum nss_status
_nss_ldap_db_get (void *db,
unsigned flags,
const ldap_datum_t * key,
@@ -1408,7 +1403,7 @@ _nss_ldap_db_get (void *db,
return NSS_NOTFOUND;
}
-NSS_STATUS
+enum nss_status
_nss_ldap_db_put (void *db,
unsigned flags,
const ldap_datum_t * key,
@@ -1457,7 +1452,7 @@ _nss_ldap_db_put (void *db,
/*
* Add a nested netgroup or group to the namelist
*/
-NSS_STATUS
+enum nss_status
_nss_ldap_namelist_push (struct name_list **head, const char *name)
{
struct name_list *nl;
@@ -1560,7 +1555,7 @@ _nss_ldap_namelist_find (struct name_list *head, const char *netgroup)
return found;
}
-NSS_STATUS _nss_ldap_validateconfig (ldap_config_t *config)
+enum nss_status _nss_ldap_validateconfig (ldap_config_t *config)
{
struct stat statbuf;
diff --git a/util.h b/util.h
index ad61d45..c3ea898 100644
--- a/util.h
+++ b/util.h
@@ -1,8 +1,7 @@
-/* Copyright (C) 1997-2005 Luke Howard.
+/*
+ Copyright (C) 1997-2005 Luke Howard
This file is part of the nss_ldap library.
Contributed by Luke Howard, <lukeh@padl.com>, 1997.
- (The author maintains a non-exclusive licence to distribute this file
- under their own conditions.)
The nss_ldap library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
@@ -18,7 +17,9 @@
License along with the nss_ldap library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- */
+
+ $Id$
+*/
#ifndef _LDAP_NSS_LDAP_UTIL_H
#define _LDAP_NSS_LDAP_UTIL_H
@@ -35,14 +36,14 @@
* get the RDN's value: eg. if the RDN was cn=lukeh, getrdnvalue(entry)
* would return lukeh.
*/
-NSS_STATUS _nss_ldap_getrdnvalue (LDAPMessage * entry,
+enum nss_status _nss_ldap_getrdnvalue (LDAPMessage * entry,
const char *rdntype,
char **rval, char **buf, size_t * len);
/*
* map a distinguished name to a login name, or group entry
*/
-NSS_STATUS _nss_ldap_dn2uid (const char *dn,
+enum nss_status _nss_ldap_dn2uid (const char *dn,
char **uid, char **buf, size_t * len,
int *pIsNestedGroup, LDAPMessage ** pRes);
@@ -124,15 +125,15 @@ NSS_STATUS _nss_ldap_dn2uid (const char *dn,
* ** implemented
*/
-NSS_STATUS _nss_ldap_init_config (ldap_config_t *);
-NSS_STATUS _nss_ldap_readconfig (ldap_config_t ** result, char **buffer, size_t *buflen);
-NSS_STATUS _nss_ldap_validateconfig (ldap_config_t *config);
+enum nss_status _nss_ldap_init_config (ldap_config_t *);
+enum nss_status _nss_ldap_readconfig (ldap_config_t ** result, char **buffer, size_t *buflen);
+enum nss_status _nss_ldap_validateconfig (ldap_config_t *config);
/*
* Escape '*' in a string for use as a filter
*/
-NSS_STATUS _nss_ldap_escape_string (const char *str,
+enum nss_status _nss_ldap_escape_string (const char *str,
char *buf, size_t buflen);
#define MAP_H_ERRNO(nss_status, herr) do { \
@@ -190,23 +191,23 @@ typedef struct ldap_datum ldap_datum_t;
void *_nss_ldap_db_open (void);
void _nss_ldap_db_close (void *db);
-NSS_STATUS _nss_ldap_db_put (void *db,
+enum nss_status _nss_ldap_db_put (void *db,
unsigned flags,
const ldap_datum_t * key,
const ldap_datum_t * value);
-NSS_STATUS _nss_ldap_db_get (void *db,
+enum nss_status _nss_ldap_db_get (void *db,
unsigned flags,
const ldap_datum_t * key,
ldap_datum_t * value);
/* Routines for managing namelists */
-NSS_STATUS _nss_ldap_namelist_push (struct name_list **head, const char *name);
+enum nss_status _nss_ldap_namelist_push (struct name_list **head, const char *name);
void _nss_ldap_namelist_pop (struct name_list **head);
int _nss_ldap_namelist_find (struct name_list *head, const char *netgroup);
void _nss_ldap_namelist_destroy (struct name_list **head);
-NSS_STATUS
+enum nss_status
_nss_ldap_add_uri (ldap_config_t *result, const char *uri,
char **buffer, size_t *buflen);