diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2006-11-26 22:36:28 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2006-11-26 22:36:28 +0000 |
commit | 7f989d4eb1b40593348d95510d12dd0015d66356 (patch) | |
tree | a602b45f928261e6e995d986f0bc301c9d8e9493 | |
parent | 16be7ee5d30c8bce08f32563c4fa846a6928aed4 (diff) |
clean up header files
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/libnss_ldapd@125 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r-- | server/Makefile.am | 2 | ||||
-rw-r--r-- | server/dnsconfig.c | 5 | ||||
-rw-r--r-- | server/dnsconfig.h | 5 | ||||
-rw-r--r-- | server/ether.c | 5 | ||||
-rw-r--r-- | server/group.c | 20 | ||||
-rw-r--r-- | server/ldap-nss.c | 17 | ||||
-rw-r--r-- | server/ldap-nss.h | 89 | ||||
-rw-r--r-- | server/ldap-parse.h | 69 | ||||
-rw-r--r-- | server/ldap-schema.c | 3 | ||||
-rw-r--r-- | server/ldap-schema.h | 3 | ||||
-rw-r--r-- | server/network.c | 30 | ||||
-rw-r--r-- | server/passwd.c | 9 | ||||
-rw-r--r-- | server/util.c | 97 | ||||
-rw-r--r-- | server/util.h | 95 |
14 files changed, 148 insertions, 301 deletions
diff --git a/server/Makefile.am b/server/Makefile.am index 8547aac..4534311 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -23,6 +23,6 @@ noinst_LIBRARIES = libserver.a libserver_a_SOURCES = common.c common.h \ alias.c ether.c group.c host.c netgroup.c network.c \ passwd.c protocol.c rpc.c service.c shadow.c \ - dnsconfig.c dnsconfig.h ldap-nss.c ldap-nss.h ldap-parse.h \ + dnsconfig.c dnsconfig.h ldap-nss.c ldap-nss.h \ ldap-schema.c ldap-schema.h pagectrl.c pagectrl.h \ resolve.c resolve.h util.c util.h diff --git a/server/dnsconfig.c b/server/dnsconfig.c index 80efbb1..fd99b45 100644 --- a/server/dnsconfig.c +++ b/server/dnsconfig.c @@ -52,9 +52,12 @@ #include "resolve.h" #include "dnsconfig.h" +#define DC_ATTR "DC" +#define DC_ATTR_AVA DC_ATTR"=" +#define DC_ATTR_AVA_LEN (sizeof(DC_ATTR_AVA) - 1) /* map gnu.org into DC=gnu,DC=org */ -enum nss_status +static enum nss_status _nss_ldap_getdnsdn (char *src_domain, char **rval, char **buffer, size_t * buflen) { diff --git a/server/dnsconfig.h b/server/dnsconfig.h index 8d8b963..675e883 100644 --- a/server/dnsconfig.h +++ b/server/dnsconfig.h @@ -24,11 +24,6 @@ #ifndef _LDAP_NSS_LDAP_DNSCONFIG_H #define _LDAP_NSS_LDAP_DNSCONFIG_H -/* utility routines. */ - -enum nss_status _nss_ldap_getdnsdn (char *domain, - char **rval, char **buffer, size_t * buflen); - enum nss_status _nss_ldap_mergeconfigfromdns (struct ldap_config * result, char **buffer, size_t *buflen); diff --git a/server/ether.c b/server/ether.c index 8db4f3e..9d96b2e 100644 --- a/server/ether.c +++ b/server/ether.c @@ -61,11 +61,6 @@ #include "common.h" #include "log.h" -/* for HP-UX */ -#ifndef NSS_BUFLEN_ETHERS -#define NSS_BUFLEN_ETHERS 1024 -#endif /* NSS_BUFLEN_ETHERS */ - #ifndef HAVE_STRUCT_ETHER_ADDR struct ether_addr { u_int8_t ether_addr_octet[6]; diff --git a/server/group.c b/server/group.c index ad509f3..a23a8b2 100644 --- a/server/group.c +++ b/server/group.c @@ -75,6 +75,26 @@ typedef struct ldap_initgroups_args ldap_initgroups_args_t; #endif /* HAVE_USERSEC_H */ +#define LDAP_NSS_MAXGR_DEPTH 16 /* maximum depth of group nesting for getgrent()/initgroups() */ + +#if LDAP_NSS_NGROUPS > 64 +#define LDAP_NSS_BUFLEN_GROUP (NSS_BUFSIZ + (LDAP_NSS_NGROUPS * (sizeof (char *) + LOGNAME_MAX))) +#else +#define LDAP_NSS_BUFLEN_GROUP NSS_BUFSIZ +#endif /* LDAP_NSS_NGROUPS > 64 */ + +#ifndef LOGNAME_MAX +#define LOGNAME_MAX 8 +#endif /* LOGNAME_MAX */ + +#ifndef UID_NOBODY +#define UID_NOBODY (-2) +#endif + +#ifndef GID_NOBODY +#define GID_NOBODY UID_NOBODY +#endif + static enum nss_status ng_chase (const char *dn, ldap_initgroups_args_t * lia); diff --git a/server/ldap-nss.c b/server/ldap-nss.c index ee0538d..0267aea 100644 --- a/server/ldap-nss.c +++ b/server/ldap-nss.c @@ -117,6 +117,11 @@ extern int ldap_ld_free (LDAP * ld, int close); NSS_LDAP_DEFINE_LOCK (__lock); /* + * LS_INIT only used for enumeration contexts + */ +#define LS_INIT(state) do { state.ls_type = LS_TYPE_INDEX; state.ls_retry = 0; state.ls_info.ls_index = -1; } while (0) + +/* * the configuration is read by the first call to do_open(). * Pointers to elements of the list are passed around but should not * be freed. @@ -712,8 +717,8 @@ do_set_sockopts (void) #endif /* LDAP_OPT_DESC */ { int off = 0; - NSS_LDAP_SOCKLEN_T socknamelen = sizeof (struct sockaddr_storage); - NSS_LDAP_SOCKLEN_T peernamelen = sizeof (struct sockaddr_storage); + socklen_t socknamelen = sizeof (struct sockaddr_storage); + socklen_t peernamelen = sizeof (struct sockaddr_storage); (void) setsockopt (sd, SOL_SOCKET, SO_KEEPALIVE, (void *) &off, sizeof (off)); @@ -778,9 +783,9 @@ do_close (void) static int do_sockaddr_isequal (struct sockaddr_storage *_s1, - NSS_LDAP_SOCKLEN_T _slen1, + socklen_t _slen1, struct sockaddr_storage *_s2, - NSS_LDAP_SOCKLEN_T _slen2) + socklen_t _slen2) { int ret; @@ -856,8 +861,8 @@ do_get_our_socket(int *sd) { struct sockaddr_storage sockname; struct sockaddr_storage peername; - NSS_LDAP_SOCKLEN_T socknamelen = sizeof (sockname); - NSS_LDAP_SOCKLEN_T peernamelen = sizeof (peername); + socklen_t socknamelen = sizeof (sockname); + socklen_t peernamelen = sizeof (peername); if (getsockname (*sd, (struct sockaddr *) &sockname, &socknamelen) != 0 || getpeername (*sd, (struct sockaddr *) &peername, &peernamelen) != 0) diff --git a/server/ldap-nss.h b/server/ldap-nss.h index 9af7fd7..c163eee 100644 --- a/server/ldap-nss.h +++ b/server/ldap-nss.h @@ -56,62 +56,13 @@ #define NSS_BUFLEN_GROUP LDAP_NSS_BUFLEN_GROUP #endif -#ifndef NSS_BUFLEN_PASSWD -#define NSS_BUFLEN_PASSWD NSS_BUFSIZ -#endif - -#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 -#define NSS_BUFLEN_PROTOCOLS NSS_BUFSIZ -#define NSS_BUFLEN_RPC NSS_BUFSIZ -#define NSS_BUFLEN_SERVICES NSS_BUFSIZ -#define NSS_BUFLEN_SHADOW NSS_BUFSIZ -#define NSS_BUFLEN_ETHERS NSS_BUFSIZ -#define NSS_BUFLEN_BOOTPARAMS NSS_BUFSIZ - -/* - * Timeouts for reconnecting code. Similar to rebind - * logic in Darwin NetInfo. Some may find sleeping - * unacceptable, in which case you may wish to adjust - * the constants below. - */ -#define LDAP_NSS_TRIES 5 /* number of sleeping reconnect attempts */ -#define LDAP_NSS_SLEEPTIME 4 /* seconds to sleep; doubled until max */ -#define LDAP_NSS_MAXSLEEPTIME 64 /* maximum seconds to sleep */ -#define LDAP_NSS_MAXCONNTRIES 2 /* reconnect attempts before sleeping */ - -#define LDAP_NSS_MAXGR_DEPTH 16 /* maximum depth of group nesting for getgrent()/initgroups() */ - -#if LDAP_NSS_NGROUPS > 64 -#define LDAP_NSS_BUFLEN_GROUP (NSS_BUFSIZ + (LDAP_NSS_NGROUPS * (sizeof (char *) + LOGNAME_MAX))) -#else -#define LDAP_NSS_BUFLEN_GROUP NSS_BUFSIZ -#endif /* LDAP_NSS_NGROUPS > 64 */ - -#define LDAP_NSS_BUFLEN_DEFAULT 0 - -#ifdef HAVE_USERSEC_H -#define LDAP_NSS_MAXUESS_ATTRS 8 /* maximum number of attributes in a getentry call */ -#endif /* HAVE_USERSEC_H */ - -#define LDAP_PAGESIZE 1000 - #ifndef LDAP_FILT_MAXSIZ #define LDAP_FILT_MAXSIZ 1024 -#endif /* !LDAP_FILT_MAXSIZ */ +#endif /* not LDAP_FILT_MAXSIZ */ #ifndef LDAPS_PORT #define LDAPS_PORT 636 -#endif /* !LDAPS_PORT */ - -#ifndef LOGNAME_MAX -#define LOGNAME_MAX 8 -#endif /* LOGNAME_MAX */ - -#ifndef MAP_KEY_MAXSIZ -#define MAP_KEY_MAXSIZ 64 -#endif +#endif /* not LDAPS_PORT */ #ifdef DEBUG #ifdef __XGNUC__ @@ -328,12 +279,6 @@ struct ldap_config char **ldc_initgroups_ignoreusers; }; -#ifdef HAVE_SOCKLEN_T -typedef socklen_t NSS_LDAP_SOCKLEN_T; -#else -typedef int NSS_LDAP_SOCKLEN_T; -#endif /* HAVE_SOCKLEN_T */ - #if defined(__GLIBC__) && __GLIBC_MINOR__ > 1 #else #define ss_family sa_family @@ -367,14 +312,6 @@ struct ldap_session int ls_current_uri; }; -#ifndef UID_NOBODY -#define UID_NOBODY (-2) -#endif - -#ifndef GID_NOBODY -#define GID_NOBODY UID_NOBODY -#endif - enum ldap_args_types { LA_TYPE_STRING, @@ -436,8 +373,6 @@ struct ldap_args #define LA_STRING2(q) ((q).la_arg2.la_string) #define LA_BASE(q) ((q).la_base) -#include "ldap-parse.h" - /* * the state consists of the desired attribute value or an offset into a list of * values for the desired attribute. This is necessary to support services. @@ -467,11 +402,6 @@ struct ldap_state }; /* - * LS_INIT only used for enumeration contexts - */ -#define LS_INIT(state) do { state.ls_type = LS_TYPE_INDEX; state.ls_retry = 0; state.ls_info.ls_index = -1; } while (0) - -/* * thread specific context: result chain, and state data */ struct ent_context @@ -489,21 +419,11 @@ struct name_list struct name_list *next; }; -/* to let us index a lookup table on enum nss_statuses */ - -#define NSS_STATUS_TRYAGAIN NSS_STATUS_TRYAGAIN - -#ifndef NSS_STATUS_TRYAGAIN -#define NSS_STATUS_TRYAGAIN (0) -#endif - typedef enum nss_status (*parser_t) (LDAPMessage *, struct ldap_state *, void *, char *, size_t); - typedef int (*NEWparser_t)(LDAPMessage *e,struct ldap_state *pvt,FILE *fp); - /* * Portable locking macro. */ @@ -658,13 +578,8 @@ enum nss_status _nss_ldap_assign_userpassword (LDAPMessage * e, /* IN */ 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); void _nss_ldap_shadow_handle_flag(struct spwd *sp); -#else -#define _nss_ldap_shadow_date(_v) atol((_v)) -#define _nss_ldap_shadow_handle_flag(_sp) do { /* nothing */ } while (0) -#endif /* HAVE_SHADOW_H */ enum nss_status _nss_ldap_map_put (struct ldap_config * config, enum ldap_map_selector sel, diff --git a/server/ldap-parse.h b/server/ldap-parse.h deleted file mode 100644 index 4fa94aa..0000000 --- a/server/ldap-parse.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - ldap-parse.h - helper macros for lookup functions - This file was part of the nss-ldap library which has been - forked into the nss-ldapd library. - - Copyright (C) 1997-2005 Luke Howard - Copyright (C) 2006 West Consulting - Copyright (C) 2006 Arthur de Jong - - 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., 51 Franklin St, Fifth Floor, Boston, - MA 02110-1301 USA -*/ - -#ifndef _LDAP_NSS_LDAP_LDAP_PARSE_H -#define _LDAP_NSS_LDAP_LDAP_PARSE_H - -#define LOOKUP_NAME(name, result, buffer, buflen, errnop, filter, selector, parser, req_buflen) \ - struct ldap_args a; \ - if (buflen < req_buflen) { \ - *errnop = ERANGE; \ - return NSS_STATUS_TRYAGAIN; \ - } \ - LA_INIT(a); \ - LA_STRING(a) = name; \ - LA_TYPE(a) = LA_TYPE_STRING; \ - return _nss_ldap_getbyname(&a, result, buffer, buflen, errnop, filter, selector, parser); - -#define LOOKUP_NUMBER(number, result, buffer, buflen, errnop, filter, selector, parser, req_buflen) \ - struct ldap_args a; \ - if (buflen < req_buflen) { \ - *errnop = ERANGE; \ - return NSS_STATUS_TRYAGAIN; \ - } \ - LA_INIT(a); \ - LA_NUMBER(a) = number; \ - LA_TYPE(a) = LA_TYPE_NUMBER; \ - return _nss_ldap_getbyname(&a, result, buffer, buflen, errnop, filter, selector, parser) - -#define LOOKUP_SETENT(key) \ - if (_nss_ldap_ent_context_init(&key) == NULL) \ - return NSS_STATUS_UNAVAIL; \ - return NSS_STATUS_SUCCESS - -#define LOOKUP_GETENT(key, result, buffer, buflen, errnop, filter, selector, parser, req_buflen) \ - if (buflen < req_buflen) { \ - *errnop = ERANGE; \ - return NSS_STATUS_TRYAGAIN; \ - } \ - return _nss_ldap_getent(&key, result, buffer, buflen, errnop, filter, selector, parser) - -#define LOOKUP_ENDENT(key) \ - _nss_ldap_enter(); \ - _nss_ldap_ent_context_release(key); \ - _nss_ldap_leave(); \ - return NSS_STATUS_SUCCESS - -#endif /* _LDAP_NSS_LDAP_LDAP_PARSE_H */ diff --git a/server/ldap-schema.c b/server/ldap-schema.c index 3c91ab1..d7fb6a1 100644 --- a/server/ldap-schema.c +++ b/server/ldap-schema.c @@ -47,6 +47,9 @@ #include "ldap-schema.h" #include "util.h" +/* max number of attributes per object class */ +#define ATTRTAB_SIZE 15 + /** * declare filters formerly declared in ldap-*.h */ diff --git a/server/ldap-schema.h b/server/ldap-schema.h index 28cbdd7..d6d87ba 100644 --- a/server/ldap-schema.h +++ b/server/ldap-schema.h @@ -26,9 +26,6 @@ #ifndef _LDAP_NSS_LDAP_LDAP_SCHEMA_H #define _LDAP_NSS_LDAP_LDAP_SCHEMA_H -/* max number of attributes per object class */ -#define ATTRTAB_SIZE 15 - /** * function to initialize global lookup filters. */ diff --git a/server/network.c b/server/network.c index 507eaee..7f84bb6 100644 --- a/server/network.c +++ b/server/network.c @@ -56,6 +56,36 @@ #define MAXADDRSIZE 4 #endif /* HAVE_USERSEC_H */ +#define MAP_H_ERRNO(nss_status, herr) do { \ + switch ((nss_status)) { \ + case NSS_STATUS_SUCCESS: \ + (herr) = 0; \ + break; \ + case NSS_STATUS_TRYAGAIN: \ + (herr) = TRY_AGAIN; \ + break; \ + case NSS_STATUS_NOTFOUND: \ + (herr) = HOST_NOT_FOUND;\ + break; \ + case NSS_STATUS_UNAVAIL: \ + default: \ + (herr) = NO_RECOVERY; \ + break; \ + } \ + } while (0) + +#define LOOKUP_SETENT(key) \ + if (_nss_ldap_ent_context_init(&key) == NULL) \ + return NSS_STATUS_UNAVAIL; \ + return NSS_STATUS_SUCCESS + + +#define LOOKUP_ENDENT(key) \ + _nss_ldap_enter(); \ + _nss_ldap_ent_context_release(key); \ + _nss_ldap_leave(); \ + return NSS_STATUS_SUCCESS + static struct ent_context *net_context = NULL; static enum nss_status diff --git a/server/passwd.c b/server/passwd.c index 4429226..c1d3520 100644 --- a/server/passwd.c +++ b/server/passwd.c @@ -50,6 +50,15 @@ #include "common.h" #include "log.h" +#ifndef UID_NOBODY +#define UID_NOBODY (-2) +#endif + +#ifndef GID_NOBODY +#define GID_NOBODY UID_NOBODY +#endif + + static struct ent_context *pw_context = NULL; static inline enum nss_status _nss_ldap_assign_emptystring( diff --git a/server/util.c b/server/util.c index cfe19b2..438d32a 100644 --- a/server/util.c +++ b/server/util.c @@ -56,6 +56,69 @@ #include "common.h" #include "log.h" + +#define NSS_LDAP_KEY_MAP_ATTRIBUTE "nss_map_attribute" +#define NSS_LDAP_KEY_MAP_OBJECTCLASS "nss_map_objectclass" +#define NSS_LDAP_KEY_SET_OVERRIDE "nss_override_attribute_value" +#define NSS_LDAP_KEY_SET_DEFAULT "nss_default_attribute_value" +#define NSS_LDAP_KEY_HOST "host" +#define NSS_LDAP_KEY_SCOPE "scope" +#define NSS_LDAP_KEY_BASE "base" +#define NSS_LDAP_KEY_PORT "port" +#define NSS_LDAP_KEY_BINDDN "binddn" +#define NSS_LDAP_KEY_BINDPW "bindpw" +#define NSS_LDAP_KEY_USESASL "use_sasl" +#define NSS_LDAP_KEY_SASLID "sasl_auth_id" +#define NSS_LDAP_KEY_DEREF "deref" +#define NSS_LDAP_KEY_ROOTBINDDN "rootbinddn" +#define NSS_LDAP_KEY_ROOTUSESASL "rootuse_sasl" +#define NSS_LDAP_KEY_ROOTSASLID "rootsasl_auth_id" +#define NSS_LDAP_KEY_LDAP_VERSION "ldap_version" +#define NSS_LDAP_KEY_TIMELIMIT "timelimit" +#define NSS_LDAP_KEY_BIND_TIMELIMIT "bind_timelimit" +#define NSS_LDAP_KEY_SSL "ssl" +#define NSS_LDAP_KEY_SSLPATH "sslpath" +#define NSS_LDAP_KEY_REFERRALS "referrals" +#define NSS_LDAP_KEY_RESTART "restart" +#define NSS_LDAP_KEY_URI "uri" +#define NSS_LDAP_KEY_IDLE_TIMELIMIT "idle_timelimit" +#define NSS_LDAP_KEY_RECONNECT_POLICY "bind_policy" +#define NSS_LDAP_KEY_SASL_SECPROPS "sasl_secprops" +#ifdef CONFIGURE_KRB5_CCNAME +#define NSS_LDAP_KEY_KRB5_CCNAME "krb5_ccname" +#endif /* CONFIGURE_KRB5_CCNAME */ +#define NSS_LDAP_KEY_LOGDIR "logdir" +#define NSS_LDAP_KEY_DEBUG "debug" +#define NSS_LDAP_KEY_PAGESIZE "pagesize" +#define NSS_LDAP_KEY_INITGROUPS "nss_initgroups" +#define NSS_LDAP_KEY_INITGROUPS_IGNOREUSERS "nss_initgroups_ignoreusers" + +/* more reconnect policy fine-tuning */ +#define NSS_LDAP_KEY_RECONNECT_TRIES "nss_reconnect_tries" +#define NSS_LDAP_KEY_RECONNECT_SLEEPTIME "nss_reconnect_sleeptime" +#define NSS_LDAP_KEY_RECONNECT_MAXSLEEPTIME "nss_reconnect_maxsleeptime" +#define NSS_LDAP_KEY_RECONNECT_MAXCONNTRIES "nss_reconnect_maxconntries" + +#define NSS_LDAP_KEY_PAGED_RESULTS "nss_paged_results" +#define NSS_LDAP_KEY_SCHEMA "nss_schema" +#define NSS_LDAP_KEY_SRV_DOMAIN "nss_srv_domain" +#define NSS_LDAP_KEY_CONNECT_POLICY "nss_connect_policy" + +/* + * Timeouts for reconnecting code. Similar to rebind + * logic in Darwin NetInfo. Some may find sleeping + * unacceptable, in which case you may wish to adjust + * the constants below. + */ +#define LDAP_NSS_TRIES 5 /* number of sleeping reconnect attempts */ +#define LDAP_NSS_SLEEPTIME 4 /* seconds to sleep; doubled until max */ +#define LDAP_NSS_MAXSLEEPTIME 64 /* maximum seconds to sleep */ +#define LDAP_NSS_MAXCONNTRIES 2 /* reconnect attempts before sleeping */ + +#define LDAP_PAGESIZE 1000 + + +static struct ldap_dictionary *do_alloc_dictionary(void); static enum nss_status do_getrdnvalue (const char *dn, const char *rdntype, char **rval, char **buffer, @@ -89,7 +152,7 @@ dn2uid_cache_put (const char *dn, const char *uid) if (__cache == NULL) { - __cache = _nss_ldap_db_open (); + __cache = (void *)do_alloc_dictionary(); if (__cache == NULL) { cache_unlock (); @@ -650,7 +713,7 @@ do_searchdescriptorconfig (const char *key, const char *value, size_t len, return NSS_STATUS_SUCCESS; } -enum nss_status _nss_ldap_init_config (struct ldap_config * result) +static enum nss_status _nss_ldap_init_config (struct ldap_config * result) { int i, j; @@ -712,7 +775,7 @@ enum nss_status _nss_ldap_init_config (struct ldap_config * result) { for (j = 0; j <= MAP_MAX; j++) { - result->ldc_maps[i][j] = _nss_ldap_db_open (); + result->ldc_maps[i][j] = (void *)do_alloc_dictionary(); if (result->ldc_maps[i][j] == NULL) return NSS_STATUS_UNAVAIL; } @@ -1339,8 +1402,7 @@ struct ldap_dictionary struct ldap_dictionary *next; }; -static struct ldap_dictionary * -do_alloc_dictionary (void) +static struct ldap_dictionary *do_alloc_dictionary(void) { struct ldap_dictionary *dict; @@ -1399,29 +1461,6 @@ do_dup_datum (unsigned flags, struct ldap_datum * dst, const struct ldap_datum * return NSS_STATUS_SUCCESS; } -void * -_nss_ldap_db_open (void) -{ - return (void *) do_alloc_dictionary (); -} - -void -_nss_ldap_db_close (void *db) -{ - struct ldap_dictionary *dict; - - dict = (struct ldap_dictionary *) db; - - while (dict != NULL) - { - struct ldap_dictionary *next = dict->next; - - do_free_dictionary (dict); - - dict = next; - } -} - enum nss_status _nss_ldap_db_get (void *db, unsigned flags, @@ -1478,7 +1517,7 @@ _nss_ldap_db_put (void *db, p = do_find_last (dict); assert (p != NULL); assert (p->next == NULL); - q = do_alloc_dictionary (); + q = do_alloc_dictionary(); if (q == NULL) return NSS_STATUS_TRYAGAIN; } diff --git a/server/util.h b/server/util.h index 98001f3..ee66eda 100644 --- a/server/util.h +++ b/server/util.h @@ -26,14 +26,6 @@ #ifndef _LDAP_NSS_LDAP_UTIL_H #define _LDAP_NSS_LDAP_UTIL_H -/* utility routines. */ - -#define CN_ATTR "CN" - -#define DC_ATTR "DC" -#define DC_ATTR_AVA DC_ATTR"=" -#define DC_ATTR_AVA_LEN (sizeof(DC_ATTR_AVA) - 1) - /* * get the RDN's value: eg. if the RDN was cn=lukeh, getrdnvalue(entry) * would return lukeh. @@ -51,54 +43,8 @@ enum nss_status _nss_ldap_dn2uid (const char *dn, char **uid, char **buf, size_t * len, int *pIsNestedGroup, LDAPMessage ** pRes); -#define NSS_LDAP_KEY_MAP_ATTRIBUTE "nss_map_attribute" -#define NSS_LDAP_KEY_MAP_OBJECTCLASS "nss_map_objectclass" -#define NSS_LDAP_KEY_SET_OVERRIDE "nss_override_attribute_value" -#define NSS_LDAP_KEY_SET_DEFAULT "nss_default_attribute_value" #define NSS_LDAP_CONFIG_BUFSIZ 4096 -#define NSS_LDAP_KEY_HOST "host" -#define NSS_LDAP_KEY_SCOPE "scope" -#define NSS_LDAP_KEY_BASE "base" -#define NSS_LDAP_KEY_PORT "port" -#define NSS_LDAP_KEY_BINDDN "binddn" -#define NSS_LDAP_KEY_BINDPW "bindpw" -#define NSS_LDAP_KEY_USESASL "use_sasl" -#define NSS_LDAP_KEY_SASLID "sasl_auth_id" -#define NSS_LDAP_KEY_DEREF "deref" -#define NSS_LDAP_KEY_ROOTBINDDN "rootbinddn" -#define NSS_LDAP_KEY_ROOTUSESASL "rootuse_sasl" -#define NSS_LDAP_KEY_ROOTSASLID "rootsasl_auth_id" -#define NSS_LDAP_KEY_LDAP_VERSION "ldap_version" -#define NSS_LDAP_KEY_TIMELIMIT "timelimit" -#define NSS_LDAP_KEY_BIND_TIMELIMIT "bind_timelimit" -#define NSS_LDAP_KEY_SSL "ssl" -#define NSS_LDAP_KEY_SSLPATH "sslpath" -#define NSS_LDAP_KEY_REFERRALS "referrals" -#define NSS_LDAP_KEY_RESTART "restart" -#define NSS_LDAP_KEY_URI "uri" -#define NSS_LDAP_KEY_IDLE_TIMELIMIT "idle_timelimit" -#define NSS_LDAP_KEY_RECONNECT_POLICY "bind_policy" -#define NSS_LDAP_KEY_SASL_SECPROPS "sasl_secprops" -#ifdef CONFIGURE_KRB5_CCNAME -#define NSS_LDAP_KEY_KRB5_CCNAME "krb5_ccname" -#endif /* CONFIGURE_KRB5_CCNAME */ -#define NSS_LDAP_KEY_LOGDIR "logdir" -#define NSS_LDAP_KEY_DEBUG "debug" -#define NSS_LDAP_KEY_PAGESIZE "pagesize" -#define NSS_LDAP_KEY_INITGROUPS "nss_initgroups" -#define NSS_LDAP_KEY_INITGROUPS_IGNOREUSERS "nss_initgroups_ignoreusers" - -/* more reconnect policy fine-tuning */ -#define NSS_LDAP_KEY_RECONNECT_TRIES "nss_reconnect_tries" -#define NSS_LDAP_KEY_RECONNECT_SLEEPTIME "nss_reconnect_sleeptime" -#define NSS_LDAP_KEY_RECONNECT_MAXSLEEPTIME "nss_reconnect_maxsleeptime" -#define NSS_LDAP_KEY_RECONNECT_MAXCONNTRIES "nss_reconnect_maxconntries" - -#define NSS_LDAP_KEY_PAGED_RESULTS "nss_paged_results" -#define NSS_LDAP_KEY_SCHEMA "nss_schema" -#define NSS_LDAP_KEY_SRV_DOMAIN "nss_srv_domain" -#define NSS_LDAP_KEY_CONNECT_POLICY "nss_connect_policy" /* * support separate naming contexts for each map @@ -129,7 +75,6 @@ enum nss_status _nss_ldap_dn2uid (const char *dn, * ** implemented */ -enum nss_status _nss_ldap_init_config (struct ldap_config *); enum nss_status _nss_ldap_readconfig (struct ldap_config ** result, char **buffer, size_t *buflen); enum nss_status _nss_ldap_validateconfig (struct ldap_config *config); @@ -140,44 +85,6 @@ enum nss_status _nss_ldap_validateconfig (struct ldap_config *config); enum nss_status _nss_ldap_escape_string (const char *str, char *buf, size_t buflen); -#define MAP_H_ERRNO(nss_status, herr) do { \ - switch ((nss_status)) { \ - case NSS_STATUS_SUCCESS: \ - (herr) = 0; \ - break; \ - case NSS_STATUS_TRYAGAIN: \ - (herr) = TRY_AGAIN; \ - break; \ - case NSS_STATUS_NOTFOUND: \ - (herr) = HOST_NOT_FOUND;\ - break; \ - case NSS_STATUS_UNAVAIL: \ - default: \ - (herr) = NO_RECOVERY; \ - break; \ - } \ - } while (0) - -#ifdef HAVE_IRS_H -#define MAP_ERRNO(nss_status, err) do { \ - switch ((nss_status)) { \ - case NSS_STATUS_SUCCESS: \ - (err) = 0; \ - break; \ - case NSS_STATUS_TRYAGAIN: \ - (err) = ERANGE; \ - break; \ - case NSS_STATUS_NOTFOUND: \ - (err) = ENOENT; \ - break; \ - case NSS_STATUS_UNAVAIL: \ - default: \ - (err) = EPERM; \ - break; \ - } \ - } while (0) -#endif /* HAVE_IRS_H */ - struct ldap_datum { void *data; @@ -191,8 +98,6 @@ struct ldap_datum #define NSS_LDAP_DB_NORMALIZE_CASE 0x1 -void *_nss_ldap_db_open (void); -void _nss_ldap_db_close (void *db); enum nss_status _nss_ldap_db_put (void *db, unsigned flags, const struct ldap_datum * key, |