summaryrefslogtreecommitdiffstats
path: root/ipa-client/ipa-getkeytab.c
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2010-08-19 16:49:50 -0400
committerAdam Young <ayoung@redhat.com>2010-08-20 09:47:54 -0400
commit05501e54f1a35ee1c1eb419c93464d9b3d1526e4 (patch)
treec6b8fc0f9b2fb6aacc1f0825523a46d7f840137c /ipa-client/ipa-getkeytab.c
parentcee78ed04df2a1d91bebb2af6407edef29be6416 (diff)
downloadfreeipa-05501e54f1a35ee1c1eb419c93464d9b3d1526e4.tar.gz
freeipa-05501e54f1a35ee1c1eb419c93464d9b3d1526e4.tar.xz
freeipa-05501e54f1a35ee1c1eb419c93464d9b3d1526e4.zip
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.
Diffstat (limited to 'ipa-client/ipa-getkeytab.c')
-rw-r--r--ipa-client/ipa-getkeytab.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/ipa-client/ipa-getkeytab.c b/ipa-client/ipa-getkeytab.c
index 4bbbf1c7c..b8701c554 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) {