auth/credentials: use smb_krb5_cc_new_unique_memory() in cli_credentials_shallow_ccache()
authorStefan Metzmacher <metze@samba.org>
Tue, 27 Feb 2024 15:21:02 +0000 (16:21 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 7 May 2024 11:30:33 +0000 (11:30 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
auth/credentials/credentials_krb5.c

index 04a38aaeed5ae24432bea7c89dbb903aff977b76..2d9503e2f1b2c968bf89f8135bc1ed637530b05b 100644 (file)
@@ -1138,7 +1138,6 @@ static int cli_credentials_shallow_ccache(struct cli_credentials *cred)
        const struct ccache_container *old_ccc = NULL;
        enum credentials_obtained old_obtained;
        struct ccache_container *ccc = NULL;
-       char *ccache_name = NULL;
        krb5_principal princ;
 
        old_obtained = cred->ccache_obtained;
@@ -1171,10 +1170,10 @@ static int cli_credentials_shallow_ccache(struct cli_credentials *cred)
        *ccc = *old_ccc;
        ccc->ccache = NULL;
 
-       ccache_name = talloc_asprintf(ccc, "MEMORY:%p", ccc);
-
-       ret = krb5_cc_resolve(ccc->smb_krb5_context->krb5_context,
-                             ccache_name, &ccc->ccache);
+       ret = smb_krb5_cc_new_unique_memory(ccc->smb_krb5_context->krb5_context,
+                                           NULL,
+                                           NULL,
+                                           &ccc->ccache);
        if (ret != 0) {
                TALLOC_FREE(ccc);
                return ret;
@@ -1182,8 +1181,6 @@ static int cli_credentials_shallow_ccache(struct cli_credentials *cred)
 
        talloc_set_destructor(ccc, free_mccache);
 
-       TALLOC_FREE(ccache_name);
-
        ret = smb_krb5_cc_copy_creds(ccc->smb_krb5_context->krb5_context,
                                     old_ccc->ccache, ccc->ccache);
        if (ret != 0) {