bool cli_credentials_ccache_init(struct cli_credentials *cred,
struct loadparm_context *lp_ctx,
const char *ccache_name);
+bool cli_credentials_ccache_reinit(struct cli_credentials *cred,
+ struct loadparm_context *lp_ctx);
NTSTATUS cli_credentials_set_stored_principal(struct cli_credentials *cred,
struct loadparm_context *lp_ctx,
const char *serviceprincipal);
return ok;
}
+/**
+ * @brief Reinitialize the Kerberos credential cache
+ *
+ * If the credential cache is a memory credential cache it will be destroyed
+ * and a new clean cache will be allocated. Existing caches will just be
+ * reopened.
+ *
+ * @param[in] cred The credential structure
+ *
+ * @param[in] lp_ctx The loadparm context.
+ *
+ * @return true on success, false otherwise.
+ */
+_PUBLIC_ bool cli_credentials_ccache_reinit(struct cli_credentials *cred,
+ struct loadparm_context *lp_ctx)
+{
+ krb5_context context;
+ krb5_error_code code;
+ char *tmp_name = NULL;
+ const char *ccache_name;
+ bool ok;
+ int cmp;
+
+ if (cred->krb5_ccache_obtained == CRED_UNINITIALISED) {
+ return false;
+ }
+ context = cred->krb5_ccache->smb_krb5_context->krb5_context;
+
+ code = krb5_cc_get_full_name(context,
+ cred->krb5_ccache->ccache,
+ &tmp_name);
+ if (code != 0) {
+ return false;
+ }
+
+ ccache_name = tmp_name;
+ cmp = strncasecmp_m(ccache_name, "MEMORY:", 7);
+ if (cmp == 0) {
+ ccache_name = NULL;
+ }
+
+ TALLOC_FREE(cred->krb5_ccache);
+ cred->krb5_ccache_obtained = CRED_UNINITIALISED;
+
+ ok = cli_credentials_ccache_init(cred, lp_ctx, ccache_name);
+ krb5_free_string(context, tmp_name);
+
+ return ok;
+}
+
static int cli_credentials_set_from_ccache(struct cli_credentials *cred,
struct ccache_container *ccache,
enum credentials_obtained obtained,