51 Commits

Author SHA1 Message Date
Ralph Boehme
a2a765f88e lib/krb5: initialize kdc_offset in the memory ccache from the krb5_context
This ensures we inherit the clock skew adjustment from the AS-REQ/REP into the
memory ccache in a similar way done for the file ccache.

This means krb5_cc_get_kdc_offset() will return the correct value and
_krb5_get_cred_kdc_any() uses the adjusted time in the authenticator of
subsequent TGS-REQ.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15676

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-07-06 16:07:17 -04:00
Minsoo Choo
aff90c322e Fix spelling 2024-06-16 23:30:48 -04:00
Nicolas Williams
fb553dde1d krb5: Fix warnings 2022-01-14 17:10:16 -06:00
Jeffrey Altman
d84512b8d2 krb5: krb5_cc_ops backward compatibility and extensibility
The krb5_cc_ops structure is an extensible structure to which new
functionality has been added over the years.

Version zero was the original.  It included all functions up to
and including get_default_name().

Version one added set_default().

Version two added lastchange().

Version three added set_kdc_offset() and get_kdc_offset().

Version four broke compatibility by modifying the signatures
of get_name() and resolve().   This was in change
7bf4d76e75 ("krb5: Improve cccol sub
naming; add gss_store_cred_into2()").

Version five restores the original signatures of get_name()
and resolve() and introduces get_name_2() and resolve_2() that
provide the additional cccol functionality.

This change

 * introduces version five
 * documents which functions are part of each version
 * replaces KRB5_CC_OPS_VERSION with KRB5_CC_OPS_VERSION_0,
   KRB5_CC_OPS_VERSION_1, KRB5_CC_OPS_VERSION_2, KRB5_CC_OPS_VERSION_3,
   and KRB5_CC_OPS_VERSION_5.  KRB5_CC_OPS_VERSION_4 is skipped
   because of the aforementioned breakage.
 * compatibility logic is added to permit ccache plugins to implement
   any of version one, two, three, five or a future version.
 * all in-tree krb5_cc_ops implementations are updated to version 5.

Change-Id: Iadfce01d10834bc6151939e4d9d196f03001626e
2020-05-27 23:22:40 -05:00
Nicolas Williams
c6b891556e krb5: Init mutex of anon MEMORY ccaches 2020-03-04 14:11:52 -06:00
Nicolas Williams
7bf4d76e75 krb5: Improve cccol sub naming; add gss_store_cred_into2()
- Formalize the TYPE:collection_name:subsidiary_name naming scheme for
   ccaches in ccache collections
    - KEYRING: ccaches are weird because they have one more optional field: the
      "anchor", so rather than just assume a naming convention everywhere, we
      add new functions as well
 - Add krb5_cc_{resolve,default}_sub() that allows one to specify a
   "subsidiary" ccache name in a collection separately from the
   collection name
 - Add krb5_cc_{resolve,default}_for() which take a principal name,
   unparse it, and use it as the subsidiary ccache name (with colons
   replaced)
 - Make kinit use the new interfaces
 - Add missing DIR ccache iteration functionality
 - Revamps test_cc
 - Add krb5_cc_get_collection() and krb5_cc_get_subsidiary()
 - Bump the ccops SPI version number
 - Add gss_store_cred_into2()
 - Make MEMORY:anonymous not linked into the global MEMORY ccache
   collection, and uses this for delegated cred handles

TBD:

 - Split this up into a krb5 change and gss mech_krb5 change?
 - Add krb5_cc_init_and_store() utility, per Greg's suggestion?
2020-03-02 17:48:04 -06:00
Nicolas Williams
ec84667763 Fix krb5_cc_move() issues
Move init/copy/destroy fallback sequence from fcc_move() to
krb5_cc_move().

Make sure all backends's move() method calls krb5_cc_destroy() on the
source on success (and only on success).

In text_cc make sure that we can find in the destination the cred
stored into the source.
2019-10-03 13:09:18 -05:00
YASUOKA Masahiko
becb0b03ae Deadlock in lib/krb5/mcache.c 2018-12-26 12:03:25 -06:00
Stefan Metzmacher
0ff40e2f4c lib/krb5: destroy a memory ccache on reinit
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12369

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>

(Bases on Samba commit 2abc3710a8a63327a769ba0482c553ed274b2113)
2016-11-08 15:36:14 -05:00
Roland C. Dowdeswell
f0f07ff408 Use krb5_enomem() more consistently in lib/krb5. 2013-02-13 16:15:00 +08:00
Jeffrey Altman
8e2762f907 Fix Windows build of mcache.c
Commit c04aa9e082 specified the
mutex type, pthread_mutex_t, directly instead of using the
abstraction, HEIMDAL_MUTEX.

Change-Id: Iedfc46163140cf23014d357cc8ccc9f0e6224327
2012-04-10 15:41:23 -04:00
Love Hörnquist Åstrand
c04aa9e082 more mutex locking from Jaudeep Padhye 2012-04-05 23:10:33 -07:00
Love Hörnquist Åstrand
a20fe9b0ad assert refcount != 0 2012-03-06 19:50:15 -08:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Asanka Herath
5dcc605f6b Fix calling conventions for Windows 2010-08-20 13:14:10 -04:00
Love Hornquist Astrand
788189805c catch error from as.*printf 2010-05-30 13:28:49 -07:00
Love Hornquist Astrand
e5d2b6f6ad support kdc offset 2009-11-22 00:18:54 -08:00
Love Hörnquist Åstrand
942a821fab remove RCSID
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25171 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-04 06:17:40 +00:00
Love Hörnquist Åstrand
7811db9c1f add lastmodified
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23923 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-10-18 21:14:54 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
23110f2f11 N_()ify
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23788 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-07 21:28:48 +00:00
Love Hörnquist Åstrand
7fcd266fdd use krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23316 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 04:32:32 +00:00
Love Hörnquist Åstrand
e8c4c04d65 use krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23296 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 03:28:45 +00:00
Love Hörnquist Åstrand
3b7ff465c1 Add declspec for Windows
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23026 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-04-17 10:02:03 +00:00
Love Hörnquist Åstrand
331b920fdc Add version number to krb5_cc_ops
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22845 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-04-07 11:48:51 +00:00
Love Hörnquist Åstrand
296b56abe8 (mcc_default_name): Remove const
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22107 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-03 17:22:51 +00:00
Love Hörnquist Åstrand
ce853485de Implement krb5_cc_ops->default_name.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22102 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-03 17:15:57 +00:00
Love Hörnquist Åstrand
b7ccda14c6 Implement the move operation.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22097 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-03 13:12:57 +00:00
Love Hörnquist Åstrand
e337d4b168 doxygen documentation
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22031 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-11-10 10:38:32 +00:00
Love Hörnquist Åstrand
aa188989ed MCC_CURSOR not used, remove.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19834 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-11 09:26:21 +00:00
Love Hörnquist Åstrand
5cfc8bd58c Implement the cache iteration functions.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16109 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-09-30 11:16:04 +00:00
Johan Danielsson
26457b7135 replace krb5_free_creds_contents by krb5_free_cred_contents
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13790 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-04-25 19:25:35 +00:00
Love Hörnquist Åstrand
188cabf477 (mcc_get_principal): also check for primary_principal == NULL now that
that isn't used as dead flag


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13418 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-03-03 21:06:36 +00:00
Love Hörnquist Åstrand
bd852f759c don't overload the primary_principal == NULL as dead since that
doesn't always work
Based on patch from Jeffrey Hutzelman <jhutz@cmu.edu>, but tweek by me


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13417 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-03-03 20:49:34 +00:00
Love Hörnquist Åstrand
3064229aaf protect the mcc_head with a mutex
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12304 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-05-16 20:43:36 +00:00
Johan Danielsson
b5f3966af8 (mcc_get_name): constify return type
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10918 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-04-18 09:40:33 +00:00
Assar Westerlund
3a0a810bc5 (mcc_remove_cred): use krb5_free_creds_contents
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10081 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-06-17 23:13:02 +00:00
Assar Westerlund
d27aa3b62e add some krb5_{set,clear}_error_string
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9937 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-05-14 06:14:52 +00:00
Assar Westerlund
cd3d6b4191 (mcc_close): free data
(mcc_destroy): don't free data


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9166 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-11-15 02:12:51 +00:00
Johan Danielsson
5f30519a1d implement resolve
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8987 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-08-23 09:52:46 +00:00
Johan Danielsson
c5b916ca6f remove advertising clause
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7464 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-12-02 17:05:13 +00:00
Johan Danielsson
cbc6d8e2ed fix past-o
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6203 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-05-11 12:06:15 +00:00
Assar Westerlund
17b23dc3b6 (mcc_get_next): get the current cursor correctly
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6057 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-04-27 23:52:06 +00:00
Johan Danielsson
43fdcecc6d cleanup
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6032 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-04-24 16:38:23 +00:00
Johan Danielsson
2e9d2687a2 (mcc_store_cred): restore linked list if copy_creds fails.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4297 ec53bebd-3082-4978-b11e-865c3cabbd6b
1998-01-18 00:41:19 +00:00
Assar Westerlund
d5b19415c7 const-ize
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@3758 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-11-02 04:13:42 +00:00
Johan Danielsson
8eb312128d fix warnings
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@3588 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-10-13 16:30:09 +00:00
Johan Danielsson
e7a1ea7ef7 mcc_ops -> krb5_mcc_ops
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@3262 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-08-29 00:46:48 +00:00
Assar Westerlund
3b39a9fb9c fix some bugs
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2794 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-08-08 03:53:42 +00:00