diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2006-10-12 11:01:56 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2006-10-12 11:01:56 +0000 |
commit | dba09bb1389491f82beb862323a5ccab428a7f2d (patch) | |
tree | e617b84715ab650b6cd162876f7ff6d0b897a05a /ldap-service.c | |
parent | 54845e6fb6d0fa0f7f77b4a7d8520897e0e98496 (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
Diffstat (limited to 'ldap-service.c')
-rw-r--r-- | ldap-service.c | 148 |
1 files changed, 10 insertions, 138 deletions
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 |