On 08/19/2010 08:31 PM, Adam Young wrote:
On 08/19/2010 05:45 PM, Rob Crittenden wrote:
Adam Young wrote:
Gets rid of the last of our compiler warnings by removing a deprecated
function call :ldap_init should be replaced with ldap_initialize.
https://fedorahosted.org/freeipa/attachment/ticket/151/admiyo-freeipa-0012-ldap_initialize.patch
I think the scheme should be ldaps and not ldap in the port 636 case.
I'm not sure you need/want to set errno either.
rob
I think you are right on "ldaps". I'm guesiing we don't havea test
case for that/ As for errno, malloc will set it to ENOMEM, so we
should probably leave it.
I'll post an updated patch.
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel
ldaps.
Not setting errno
>From f1ba1a7071bd32aa84e494e7c61f0e124967fb07 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Thu, 19 Aug 2010 16:49:50 -0400
Subject: [PATCH] ldap_initialize
the code was calling ldap_init, which is a deprecated function, and getting a compilation warning. This version uses the recommended function ldap_initilaize.
---
ipa-client/ipa-getkeytab.c | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/ipa-client/ipa-getkeytab.c b/ipa-client/ipa-getkeytab.c
index 4bbbf1c..b8701c5 100644
--- a/ipa-client/ipa-getkeytab.c
+++ b/ipa-client/ipa-getkeytab.c
@@ -481,6 +481,23 @@ int filter_keys(krb5_context krbctx, struct keys_container *keys,
return n;
}
+static int ipa_ldap_init(LDAP ** ld, const char * scheme, const char * servername, const int port)
+{
+ char* url = NULL;
+ int url_len = snprintf(url,0,"%s://%s:%d",scheme,servername,port) +1;
+
+ url = (char *)malloc (url_len);
+ if (!url){
+ fprintf(stderr, "Out of memory \n");
+ return LDAP_NO_MEMORY;
+ }
+ sprintf(url,"%s://%s:%d",scheme,servername,port);
+ int rc = ldap_initialize(ld, url);
+
+ free(url);
+ return rc;
+}
+
static int ldap_set_keytab(krb5_context krbctx,
const char *servername,
const char *principal_name,
@@ -526,13 +543,17 @@ static int ldap_set_keytab(krb5_context krbctx,
if (ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, "/etc/ipa/ca.crt") != LDAP_OPT_SUCCESS) {
goto error_out;
}
-
- ld = ldap_init(servername, 636);
+
+ if ( ipa_ldap_init(&ld, "ldaps",servername, 636) != LDAP_SUCCESS){
+ goto error_out;
+ }
if (ldap_set_option(ld, LDAP_OPT_X_TLS, &ssl) != LDAP_OPT_SUCCESS) {
goto error_out;
}
} else {
- ld = ldap_init(servername, 389);
+ if (ipa_ldap_init(&ld, "ldap",servername, 389) != LDAP_SUCCESS){
+ goto error_out;
+ }
}
if(ld == NULL) {
--
1.7.1
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel