3 CASA routines for DHCPD... */
5 /* Copyright (c) 2006 Novell, Inc.
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.
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.
31 * This file was written by S Kalyanasundaram <skalyanasundaram@novell.com>
35 * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
36 * Copyright (c) 1995-2003 by Internet Software Consortium
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.
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.
50 * Internet Systems Consortium, Inc.
52 * Newmarket, NH 03857 USA
54 * https://www.isc.org/
57 #if defined(LDAP_CASA_AUTH)
59 #include "ldap_casa.h"
66 if( !(casaIDK
= dlopen(MICASA_LIB
,RTLD_LAZY
)))
68 p_miCASAGetCredential
= (CASA_GetCredential_T
) dlsym(casaIDK
, "miCASAGetCredential");
69 p_miCASASetCredential
= (CASA_SetCredential_T
) dlsym(casaIDK
, "miCASASetCredential");
70 p_miCASARemoveCredential
= (CASA_RemoveCredential_T
) dlsym(casaIDK
, "miCASARemoveCredential");
72 if((p_miCASAGetCredential
== NULL
) ||
73 (p_miCASASetCredential
== NULL
) ||
74 (p_miCASARemoveCredential
== NULL
))
79 p_miCASAGetCredential
= NULL
;
80 p_miCASASetCredential
= NULL
;
81 p_miCASARemoveCredential
= NULL
;
97 p_miCASAGetCredential
= NULL
;
98 p_miCASASetCredential
= NULL
;
99 p_miCASARemoveCredential
= NULL
;
104 load_uname_pwd_from_miCASA (char **ldap_username
, char **ldap_password
)
107 uint32_t credentialtype
= SSCS_CRED_TYPE_SERVER_F
;
108 SSCS_BASIC_CREDENTIAL credential
;
109 SSCS_SECRET_ID_T applicationSecretId
;
110 char *tempVar
= NULL
;
112 const char applicationName
[10] = "dhcp-ldap";
116 memset(&credential
, 0, sizeof(SSCS_BASIC_CREDENTIAL
));
117 memset(&applicationSecretId
, 0, sizeof(SSCS_SECRET_ID_T
));
119 applicationSecretId
.len
= strlen(applicationName
) + 1;
120 memcpy (applicationSecretId
.id
, applicationName
, applicationSecretId
.len
);
122 credential
.unFlags
= USERNAME_TYPE_CN_F
;
124 result
= p_miCASAGetCredential (0,
125 &applicationSecretId
,NULL
,&credentialtype
,
130 tempVar
= dmalloc (credential
.unLen
+ 1, MDL
);
132 log_fatal ("no memory for ldap_username");
133 memcpy(tempVar
, credential
.username
, credential
.unLen
);
134 *ldap_username
= tempVar
;
136 tempVar
= dmalloc (credential
.pwordLen
+ 1, MDL
);
138 log_fatal ("no memory for ldap_password");
139 memcpy(tempVar
, credential
.password
, credential
.pwordLen
);
140 *ldap_password
= tempVar
;
142 #if defined (DEBUG_LDAP)
143 log_info ("Authentication credential taken from CASA");
157 return 0; //casa libraries not loaded
160 #endif /* LDAP_CASA_AUTH */