From 51dd83a50cbfc6d1bf17eb95095bac4d223cc637 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 27 Oct 2010 15:22:46 +1100 Subject: auth/credentials Give a sensible behaviour for resetting the krb5 context This extra code isn't used at the moment, but I noticed the old API was rather supprising in it's behaviour, and might catch someone out at some later time. Andrew Bartlett Autobuild-User: Andrew Bartlett Autobuild-Date: Wed Oct 27 05:24:22 UTC 2010 on sn-devel-104 --- source4/auth/credentials/credentials_krb5.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source4') diff --git a/source4/auth/credentials/credentials_krb5.c b/source4/auth/credentials/credentials_krb5.c index fb4b440281..97b18140af 100644 --- a/source4/auth/credentials/credentials_krb5.c +++ b/source4/auth/credentials/credentials_krb5.c @@ -51,13 +51,18 @@ _PUBLIC_ int cli_credentials_get_krb5_context(struct cli_credentials *cred, return 0; } -/* This needs to be called directly after the cli_credentials_init(), - * otherwise we might have problems with the krb5 context already - * being here. +/* For most predictable behaviour, this needs to be called directly after the cli_credentials_init(), + * otherwise we may still have references to the old smb_krb5_context in a credential cache etc */ _PUBLIC_ NTSTATUS cli_credentials_set_krb5_context(struct cli_credentials *cred, struct smb_krb5_context *smb_krb5_context) { + if (smb_krb5_context == NULL) { + talloc_unlink(cred, cred->smb_krb5_context); + cred->smb_krb5_context = NULL; + return NT_STATUS_OK; + } + if (!talloc_reference(cred, smb_krb5_context)) { return NT_STATUS_NO_MEMORY; } -- cgit