Use krb5_cc_move to make an atomic switch of the cred cache.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22116 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997-2006 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1997-2007 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -377,6 +377,7 @@ get_new_tickets(krb5_context context,
|
|||||||
char *renewstr = NULL;
|
char *renewstr = NULL;
|
||||||
krb5_enctype *enctype = NULL;
|
krb5_enctype *enctype = NULL;
|
||||||
struct ntlm_buf ntlmkey;
|
struct ntlm_buf ntlmkey;
|
||||||
|
krb5_ccache tempccache;
|
||||||
|
|
||||||
memset(&ntlmkey, 0, sizeof(ntlmkey));
|
memset(&ntlmkey, 0, sizeof(ntlmkey));
|
||||||
passwd[0] = '\0';
|
passwd[0] = '\0';
|
||||||
@@ -577,16 +578,25 @@ get_new_tickets(krb5_context context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = krb5_cc_initialize (context, ccache, cred.client);
|
ret = krb5_cc_new_unique(context, krb5_cc_get_type(context, ccache),
|
||||||
|
NULL, &tempccache);
|
||||||
|
if (ret)
|
||||||
|
krb5_err (context, 1, ret, "krb5_cc_new_unique");
|
||||||
|
|
||||||
|
ret = krb5_cc_initialize (context, tempccache, cred.client);
|
||||||
if (ret)
|
if (ret)
|
||||||
krb5_err (context, 1, ret, "krb5_cc_initialize");
|
krb5_err (context, 1, ret, "krb5_cc_initialize");
|
||||||
|
|
||||||
ret = krb5_cc_store_cred (context, ccache, &cred);
|
ret = krb5_cc_store_cred (context, tempccache, &cred);
|
||||||
if (ret)
|
if (ret)
|
||||||
krb5_err (context, 1, ret, "krb5_cc_store_cred");
|
krb5_err (context, 1, ret, "krb5_cc_store_cred");
|
||||||
|
|
||||||
krb5_free_cred_contents (context, &cred);
|
krb5_free_cred_contents (context, &cred);
|
||||||
|
|
||||||
|
ret = krb5_cc_move(context, tempccache, ccache);
|
||||||
|
if (ret)
|
||||||
|
krb5_err (context, 1, ret, "krb5_cc_move");
|
||||||
|
|
||||||
if (ntlm_domain && ntlmkey.data)
|
if (ntlm_domain && ntlmkey.data)
|
||||||
store_ntlmkey(context, ccache, ntlm_domain, principal, &ntlmkey);
|
store_ntlmkey(context, ccache, ntlm_domain, principal, &ntlmkey);
|
||||||
|
|
||||||
@@ -757,9 +767,12 @@ main (int argc, char **argv)
|
|||||||
krb4_cc_name = NULL;
|
krb4_cc_name = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
|
ret = krb5_cc_cache_match(context, principal, NULL, &ccache);
|
||||||
|
if (ret)
|
||||||
ret = krb5_cc_default (context, &ccache);
|
ret = krb5_cc_default (context, &ccache);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ret)
|
if (ret)
|
||||||
krb5_err (context, 1, ret, "resolving credentials cache");
|
krb5_err (context, 1, ret, "resolving credentials cache");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user