r21778: Wrap calls to krb5_get_init_creds_opt_free to handle the different
authorJames Peach <jpeach@samba.org>
Fri, 9 Mar 2007 18:51:48 +0000 (18:51 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:18:32 +0000 (12:18 -0500)
calling convention in the latest MIT changes.  Apparantly Heimdal
is also changing to this calling convention.
(This used to be commit c29c69d2df377fabb88a78e6f5237de106d5c2c5)

source3/configure.in
source3/include/includes.h
source3/libads/kerberos.c
source3/libsmb/clikrb5.c

index 3e407cf5dcf256a860848411bb4d5b44b5b92eb3..6a380a1cdeb4bacbb6b1985be8c6bfc7cb28d90c 100644 (file)
@@ -3549,6 +3549,26 @@ if test x"$with_ads_support" != x"no"; then
            [Whether the krb5_ticket structure contains the kvno and enctype])
   fi
 
+  AC_CACHE_CHECK(whether krb5_get_init_creds_opt_free takes a context argument,
+         smb_krb5_creds_opt_free_context,
+         [
+               AC_TRY_COMPILE([
+                   #include <krb5.h>],
+                   [
+                       krb5_context ctx;
+                       krb5_get_init_creds_opt *opt = NULL;
+                       krb5_get_init_creds_opt_free(ctx, opt);
+                   ],
+                   [smb_krb5_creds_opt_free_context=yes],
+                   [smb_krb5_creds_opt_free_context=no]
+               )
+         ])
+
+  if test x"$smb_krb5_creds_opt_free_context" = x"yes" ; then
+       AC_DEFINE(KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT, 1,
+           [Whether krb5_get_init_creds_opt_free takes a context argument])
+  fi
+
   AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_verify_checksum, [
     AC_TRY_COMPILE([
        #include <krb5.h>], 
index 3864faddb94983e93b185167904f13475d88de39..c71acd3866381cb800684772494dfce06101b192 100644 (file)
@@ -1176,8 +1176,11 @@ krb5_error_code nt_status_to_krb5(NTSTATUS nt_status);
 void smb_krb5_free_error(krb5_context context, krb5_error *krberror);
 krb5_error_code handle_krberror_packet(krb5_context context,
                                          krb5_data *packet);
-void krb5_get_init_creds_opt_free(krb5_get_init_creds_opt *opt);
-krb5_error_code krb5_get_init_creds_opt_alloc(krb5_context context, krb5_get_init_creds_opt **opt);
+
+void smb_krb5_get_init_creds_opt_free(krb5_context context,
+                                   krb5_get_init_creds_opt *opt);
+krb5_error_code smb_krb5_get_init_creds_opt_alloc(krb5_context context,
+                                   krb5_get_init_creds_opt **opt);
 #endif /* HAVE_KRB5 */
 
 
index 8e8297b07e5490980faf0d7fa88611177ca1b231..1c0e85dd557694a6bee05c5dd867d644ba8d98e6 100644 (file)
@@ -140,7 +140,7 @@ int kerberos_kinit_password_ext(const char *principal,
        if ((code = krb5_get_init_creds_password(ctx, &my_creds, me, CONST_DISCARD(char *,password), 
                                                 kerb_prompter, NULL, 0, NULL, opt)))
        {
-               krb5_get_init_creds_opt_free(opt);
+               smb_krb5_get_init_creds_opt_free(ctx, opt);
                smb_krb5_free_addresses(ctx, addr);
                krb5_cc_close(ctx, cc);
                krb5_free_principal(ctx, me);
@@ -148,7 +148,7 @@ int kerberos_kinit_password_ext(const char *principal,
                return code;
        }
 
-       krb5_get_init_creds_opt_free(opt);
+       smb_krb5_get_init_creds_opt_free(ctx, opt);
 
        if ((code = krb5_cc_initialize(ctx, cc, me))) {
                smb_krb5_free_addresses(ctx, addr);
index f06a19b345c2b9b58cc5924fba24be97a80b2676..43dfddda472355d7ad59c0a478922e43a1d72f5d 100644 (file)
@@ -1389,9 +1389,14 @@ done:
        return ret;
 }
 
-#ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC 
krb5_error_code krb5_get_init_creds_opt_alloc(krb5_context context, krb5_get_init_creds_opt **opt)
+ krb5_error_code smb_krb5_get_init_creds_opt_alloc(krb5_context context,
                                          krb5_get_init_creds_opt **opt)
 {
+#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC
+       /* Heimdal or modern MIT version */
+       return krb5_get_init_creds_opt_alloc(context, opt);
+#else
+       /* Historical MIT version */
        krb5_get_init_creds_opt *my_opt;
 
        *opt = NULL;
@@ -1404,16 +1409,28 @@ done:
 
        *opt =  my_opt;
        return 0;
+#endif /* HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC  */
 }
-#endif
 
-#ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_FREE 
void krb5_get_init_creds_opt_free(krb5_get_init_creds_opt *opt)
+ void smb_krb5_get_init_creds_opt_free(krb5_context context,
                              krb5_get_init_creds_opt *opt)
 {
+#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_FREE
+
+#ifdef KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT
+       /* Modern MIT version */
+       krb5_get_init_creds_opt_free(context, opt);
+#else
+       /* Heimdal version */
+       krb5_get_init_creds_opt_free(opt);
+#endif
+
+#else /* HAVE_KRB5_GET_INIT_CREDS_OPT_FREE */
+       /* Historical MIT version */
        SAFE_FREE(opt);
        opt = NULL;
+#endif /* HAVE_KRB5_GET_INIT_CREDS_OPT_FREE */
 }
-#endif
 
 #else /* HAVE_KRB5 */
  /* this saves a few linking headaches */