ISC DHCP 4.4.3-P1
A reference DHCPv4 and DHCPv6 implementation
 
Loading...
Searching...
No Matches
ldap_casa.c
Go to the documentation of this file.
1/* ldap_casa.c
2
3 CASA routines for DHCPD... */
4
5/* Copyright (c) 2006 Novell, Inc.
6
7 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 * 1.Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * 2.Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * 3.Neither the name of ISC, ISC DHCP, nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18
19 * THIS SOFTWARE IS PROVIDED BY INTERNET SYSTEMS CONSORTIUM AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ISC OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30
31 * This file was written by S Kalyanasundaram <skalyanasundaram@novell.com>
32 */
33
34/*
35 * Copyright (C) 2004-2022 Internet Systems Consortium, Inc. ("ISC")
36 * Copyright (c) 1995-2003 by Internet Software Consortium
37 *
38 * Permission to use, copy, modify, and distribute this software for any
39 * purpose with or without fee is hereby granted, provided that the above
40 * copyright notice and this permission notice appear in all copies.
41 *
42 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
43 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
44 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
45 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
46 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
47 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
48 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49 *
50 * Internet Systems Consortium, Inc.
51 * PO Box 360
52 * Newmarket, NH 03857 USA
53 * <info@isc.org>
54 * https://www.isc.org/
55 */
56
57#if defined(LDAP_CASA_AUTH)
58#include "dhcpd.h"
59#include "ldap_casa.h"
60#include <dlfcn.h>
61#include <string.h>
62
63int
64load_casa (void)
65{
67 return 0;
68 p_miCASAGetCredential = (CASA_GetCredential_T) dlsym(casaIDK, "miCASAGetCredential");
69 p_miCASASetCredential = (CASA_SetCredential_T) dlsym(casaIDK, "miCASASetCredential");
71
75 {
76 if(casaIDK)
78 casaIDK = NULL;
82 return 0;
83 }
84 else
85 return 1;
86}
87
88static void
89release_casa(void)
90{
91 if(casaIDK)
92 {
94 casaIDK = NULL;
95 }
96
100
101}
102
103int
105 {
106 int result = 0;
110 char *tempVar = NULL;
111
112 const char applicationName[10] = "dhcp-ldap";
113
114 if ( load_casa() )
115 {
118
121
123
127
128 if(credential.unLen)
129 {
130 tempVar = dmalloc (credential.unLen + 1, MDL);
131 if (!tempVar)
132 log_fatal ("no memory for ldap_username");
133 memcpy(tempVar , credential.username, credential.unLen);
135
136 tempVar = dmalloc (credential.pwordLen + 1, MDL);
137 if (!tempVar)
138 log_fatal ("no memory for ldap_password");
139 memcpy(tempVar, credential.password, credential.pwordLen);
141
142#if defined (DEBUG_LDAP)
143 log_info ("Authentication credential taken from CASA");
144#endif
145
146 release_casa();
147 return 1;
148
149 }
150 else
151 {
152 release_casa();
153 return 0;
154 }
155 }
156 else
157 return 0; //casa libraries not loaded
158 }
159
160#endif /* LDAP_CASA_AUTH */
#define cur_time
Definition dhcpd.h:2126
#define MDL
Definition omapip.h:567
void * dmalloc(size_t, const char *, int)
Definition alloc.c:57
void log_fatal(const char *,...) __attribute__((__format__(__printf__
int int log_info(const char *,...) __attribute__((__format__(__printf__