krb5_wrap: fix smb_krb5_cc_copy_creds() for MIT krb5
authorStefan Metzmacher <metze@samba.org>
Fri, 23 Dec 2016 06:22:27 +0000 (07:22 +0100)
committerStefan Metzmacher <metze@samba.org>
Sat, 24 Dec 2016 20:04:23 +0000 (21:04 +0100)
krb5_cc_copy_creds() expects an already initialized output cache.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sat Dec 24 21:04:23 CET 2016 on sn-devel-144

lib/krb5_wrap/krb5_samba.c

index a8eafcd..307be93 100644 (file)
@@ -2899,6 +2899,18 @@ krb5_error_code smb_krb5_cc_copy_creds(krb5_context context,
 #ifdef HAVE_KRB5_CC_COPY_CACHE /* Heimdal */
        return krb5_cc_copy_cache(context, incc, outcc);
 #elif defined(HAVE_KRB5_CC_COPY_CREDS)
+       krb5_error_code ret;
+       krb5_principal princ = NULL;
+
+       ret = krb5_cc_get_principal(context, incc, &princ);
+       if (ret != 0) {
+               return ret;
+       }
+       ret = krb5_cc_initialize(context, outcc, princ);
+       krb5_free_principal(context, princ);
+       if (ret != 0) {
+               return ret;
+       }
        return krb5_cc_copy_creds(context, incc, outcc);
 #else
 #error UNKNOWN_KRB5_CC_COPY_CACHE_OR_CREDS_FUNCTION