"Fossies" - the Fresh Open Source Software Archive

Member "nss_ldap-265/ldap-bp.c" (6 Nov 2009, 3383 Bytes) of package /linux/privat/old/nss_ldap-265.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* Copyright (C) 1997-2005 Luke Howard.
    2    This file is part of the nss_ldap library.
    3    Contributed by Luke Howard, <lukeh@padl.com>, 1997.
    4 
    5    The nss_ldap library is free software; you can redistribute it and/or
    6    modify it under the terms of the GNU Library General Public License as
    7    published by the Free Software Foundation; either version 2 of the
    8    License, or (at your option) any later version.
    9 
   10    The nss_ldap library is distributed in the hope that it will be useful,
   11    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13    Library General Public License for more details.
   14 
   15    You should have received a copy of the GNU Library General Public
   16    License along with the nss_ldap library; see the file COPYING.LIB.  If not,
   17    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   18    Boston, MA 02111-1307, USA.
   19 
   20    $Id: ldap-bp.c,v 2.27 2006/01/11 18:03:48 lukeh Exp $
   21  */
   22 
   23 
   24 static char rcsId[] = "$Id: ldap-bp.c,v 2.27 2006/01/11 18:03:48 lukeh Exp $";
   25 
   26 #include "config.h"
   27 
   28 #ifdef HAVE_PORT_BEFORE_H
   29 #include <port_before.h>
   30 #endif
   31 
   32 #if defined(HAVE_THREAD_H) && !defined(_AIX)
   33 #include <thread.h>
   34 #elif defined(HAVE_PTHREAD_H)
   35 #include <pthread.h>
   36 #endif
   37 
   38 #include <stdio.h>
   39 #include <stdlib.h>
   40 #include <string.h>
   41 #include <netdb.h>
   42 #include <sys/types.h>
   43 #include <sys/socket.h>
   44 #include <netinet/in.h>
   45 
   46 #ifdef HAVE_LBER_H
   47 #include <lber.h>
   48 #endif
   49 #ifdef HAVE_LDAP_H
   50 #include <ldap.h>
   51 #endif
   52 
   53 #include "ldap-nss.h"
   54 #include "ldap-bp.h"
   55 #include "util.h"
   56 
   57 #ifdef HAVE_PORT_AFTER_H
   58 #include <port_after.h>
   59 #endif
   60 
   61 #if defined(HAVE_NSSWITCH_H) || defined(HAVE_NSS_H)
   62 
   63 #ifdef HAVE_NSS_H
   64 static ent_context_t *bp_context = NULL;
   65 #endif
   66 
   67 static NSS_STATUS
   68 _nss_ldap_parse_bp (LDAPMessage * e,
   69             ldap_state_t * pvt,
   70             void *result, char *buffer, size_t buflen)
   71 {
   72   struct bootparams *bp = (struct bootparams *) result;
   73   NSS_STATUS stat;
   74 
   75   stat =
   76     _nss_ldap_assign_attrval (e, ATM (LM_BOOTPARAMS, cn), &bp->bp_name,
   77                               &buffer, &buflen);
   78   if (stat != NSS_SUCCESS)
   79     return stat;
   80 
   81   stat =
   82     _nss_ldap_assign_attrvals (e, AT (bootParameter), NULL,
   83                    &bp->bp_params, &buffer, &buflen, NULL);
   84   if (stat != NSS_SUCCESS)
   85     return stat;
   86 
   87   return NSS_SUCCESS;
   88 }
   89 
   90 #ifdef HAVE_NSSWITCH_H
   91 static NSS_STATUS
   92 _nss_ldap_getbootparamsbyname_r (nss_backend_t * be, void *args)
   93 {
   94   LOOKUP_NAME (args, _nss_ldap_filt_getbootparamsbyname, LM_BOOTPARAMS,
   95            _nss_ldap_parse_bp, LDAP_NSS_BUFLEN_DEFAULT);
   96 }
   97 #endif
   98 
   99 #ifdef HAVE_NSSWITCH_H
  100 static NSS_STATUS
  101 _nss_ldap_bootparams_destr (nss_backend_t * bp_context, void *args)
  102 {
  103   return _nss_ldap_default_destr (bp_context, args);
  104 }
  105 
  106 static nss_backend_op_t bp_ops[] = {
  107   _nss_ldap_bootparams_destr,
  108   _nss_ldap_getbootparamsbyname_r
  109 };
  110 
  111 nss_backend_t *
  112 _nss_ldap_bootparams_constr (const char *db_name,
  113                  const char *src_name, const char *cfg_args)
  114 {
  115   nss_ldap_backend_t *be;
  116 
  117 /*
  118    if (!(be = (nss_ldap_backend_t *)malloc(sizeof(*be))))
  119    return NULL;
  120 
  121    be->ops = bp_ops;
  122    be->n_ops = sizeof(bp_ops) / sizeof(nss_backend_op_t);
  123 
  124    if (_nss_ldap_default_constr(be) != NSS_SUCCESS)
  125    return NULL;
  126 
  127    return (nss_backend_t *)be;
  128  */
  129 
  130   /* this is a noop until we figure it out properly */
  131   return NULL;
  132 }
  133 
  134 #endif /* HAVE_NSSWITCH_H */
  135 
  136 #endif /* !HAVE_IRS_H */