Commit Graph

215 Commits

Author SHA1 Message Date
Nicolas Williams
5f63215d0d Always perform == or != operation on cmp function result
Although not required to address bad code generation in
some versions of gcc 9 and 10, a coding style that requires
explicit comparison of the result to zero before use is
both clearer and would have avoided the generation of bad
code.

This change converts all use of cmp function usage from

```
    if (strcmp(a, b) || !strcmp(c, d)) ...
```

to

```
    if (strcmp(a, b) != 0 || strcmp(c, d)) == 0
```

for all C library cmp functions and related:

 - strcmp(), strncmp()
 - strcasecmp(), strncasecmp()
 - stricmp(), strnicmp()
 - memcmp()

Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
2021-11-24 22:30:44 -05:00
Isaac Boukris
3e466caf10 krb5: skip cache check in S4U2Proxy requests 2021-09-28 10:19:08 +10:00
Luke Howard
57a1a66348 krb5: default to client realm in _krb5_get_krbtgt
If _krb5_get_krbtgt() is called with a NULL realm, use the realm of the ccache
client
2021-08-09 21:46:32 +10:00
Jeffrey Altman
739f7e0484 krb5: not_found must free krb5_get_error_message string
Even though krb5_get_error_message() returns 'const char *' the
C-string is allocated and must be freed using krb5_free_error_message().

Change-Id: I8d4ef6fce12f113617443d15abadf51f1e04cf1a
2020-05-27 09:01:22 -04:00
Jeffrey Altman
fde95037a8 lib/krb5: not_found() do not substitute the error text
not_found() is called internally with error code KRB5_CC_NOTFOUND
from find_cred() and get_cred_kdc_capath_worker() where a hard
coded error string "Matching credential not found" makes sense.
However, it is also called from krb5_get_creds() and
krb5_get_credentials_with_flags() with error codes that are
returned from the KDC where hiding the true error string
confuses the end user and hampers debugging.

This change replaces the hard coded string with the result
of krb5_get_error_message() and appends the service ticket
name.

Change-Id: I275c66c7b5783ae25029dce5b851cb389b118bcc
2020-05-26 11:48:45 -05:00
Luke Howard
cf940e15f4 krb5: rename constrained-delegatiom to cname-in-addl-tkt
For consistency with [MS-SFU] rename the constrained-delegation KDC option to
cname-in-addl-tkt (client name in additional ticket).
2019-06-02 14:44:11 +10:00
Isaac Boukris
ea7615ade3 Do not set anonymous flag in S4U2Proxy request
It is not specified in MS-SFU, Apple dropped it as well and
it now breaks master branch.

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
2019-06-01 11:14:27 -04:00
Luke Howard
014e318d6b krb5: check KDC supports anonymous if requested
Verify the KDC recognized the request-anonymous flag by validating the returned
client principal name.
2019-05-18 20:31:52 -04:00
Luke Howard
55ee6c1282 krb5: support for anonymous TGS requests
Add support to krb5_get_creds() for requesting anonymous service tickets using
a TGT, using the flag KRB5_GC_ANONYMOUS.
2019-05-14 15:16:19 -04:00
Isaac Boukris
2ee4169dd1 Avoid shadowing KDC returned error code
The referral function does not handle short names,
so avoid falling over it in case capath fails, in
order to preserve the error code returned by the
KDC (it wasn't a problem before the order between
the two functions has changed).

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
2018-12-26 16:55:13 -06:00
Viktor Dukhovni
5b39bd7c1d New KRB5_NO_TICKET_STORE env var 2017-05-26 10:53:37 -05:00
Viktor Dukhovni
c7f54ae85a Fix error in last-minute tgt referral tweak 2017-04-14 15:26:26 -04:00
Viktor Dukhovni
1c6e1d5b1a Improve referral processing for TGTs
When using referrals to obtain krbtgt/A@B we're really looking for a
path to krbtgt/B first, and only then a ticket for krbtgt/A.
2017-04-13 18:11:52 -05:00
Viktor Dukhovni
a4fb8984dd Do not ignore realm when checking for expected ticket or referral 2017-04-13 18:11:52 -05:00
Viktor Dukhovni
10f3ab0f2a Never store TGT "aliases"
When obtaining a remote TGT krbtgt/REALM2@REALM2, an intermediate
cross-realm TGT obtained for krbtgt/REALM2@REALM1 is not equivalent
to the TGT we seek, and must not be stored under its name.
2017-04-13 18:11:52 -05:00
Jeffrey Altman
6a1db3fb1c princ type NT-UNKNOWN + "host" == NT-SRV-HST
Treat principals of type NT-UNKNOWN as NT-SRV-HST if the first component
of the principal name is "host".

Change-Id: I28fb619379daac827436040e701d4ab7b279852b
2016-11-14 21:29:47 -06:00
Viktor Dukhovni
840dc40574 Refine name canonicalization
When storing credentials whose ticket principal is not equal to the
requested principal, store the ticket under both names not only when
the original realm is the referral realm, but more generally for any
difference at all.  This matches MIT behaviour.

Allow explicit name_canon rules to specify a realm to go with the
canonicalized hostname, if that realm is empty the effect is the
same "use-referrals"

Also fix segfault when no creds and debugging
2016-06-09 01:13:15 -04:00
Nicolas Williams
7da08a658b Try capaths first, then referrals
When looking for a ticket, use the capath codepath first when we know
the service's realm: because we might have local policy as to how to get
there.

Then, if that doesn't work, try referrals.  (For now unconditionally.)
2015-04-14 11:27:24 -05:00
Viktor Dukhovni
bfc78d11dc Only use KDC offset when we have it 2015-04-14 11:27:24 -05:00
Viktor Dukhovni
d09430d68b Fetch forwardable TGT without GC_CACHED
Just in case it is not the start TGT, in which case it is generally,
but not always, already cached.  Just in case get it again, if lost.
2015-04-14 11:27:23 -05:00
Nicolas Williams
629eeb811a Add start_realm cc config 2015-04-14 11:27:21 -05:00
Nicolas Williams
c5e91cf462 Add debug messages to krb5_get_creds 2015-04-13 16:59:19 -05:00
Nicolas Williams
487b6820f6 Revamp name canonicalization code 2015-03-24 11:49:58 -05:00
Nicolas Williams
9fbbc4cf85 Refactor capath_worker() a bit more 2015-03-16 10:40:10 -05:00
Viktor Dukhovni
cfdf6d5cbe gsskrb5: Make krb5 mech use referrals
Modify the gss krb5 mech to always use referrals unless the
KRB5_NCRO_NO_REFERRALS flag is set.

Change-Id: I7efd873ac922a43adafa2c492703b576847a885f
2015-03-14 16:08:32 -04:00
Nicolas Williams
8a5d50a328 krb5: do not store TGTs if GC_NO_STORE
krb5_get_credentials_with_flags() and krb5_get_creds() do not store
obtained TGTs if the KRB5_GC_NO_STORE flag is set.

Change-Id: Ie999ec4e985463ff60e9d499c3e870880033dfa7
2015-03-14 16:08:31 -04:00
Nicolas Williams
b84bdf213d krb5: improve comments in get_cred_kdc_capath_worker
Change-Id: I0d47ada32fdc9f7938d69d93022f1daac80d4e88
2015-03-14 16:08:29 -04:00
Nicolas Williams
4f074487b4 krb5: reject referrals in capath code paths
In get_cred_kdc_capath_worker() if the credentials obtained by
get_cred_kdc_address() does not exactly match the requested service
principal discard them and return KRB5KC_ERR_S_PRINCIPAL_UNKNOWN.

Change-Id: Iaeacd07f87374f64e3a7bb860adfeb2dc9550fd1
2015-03-14 16:08:28 -04:00
Jeffrey Altman
e13c0946f6 krb5: refactor get_cred_kdc_capath_worker
This change adds a common out: path for all cleanup.

It also adjusts whitespace for consistency.

Change-Id: Ic90d6568a44aebc0c0adb64fad641e5420ea8e27
2015-03-14 16:08:26 -04:00
Nicolas Williams
c37f1b3e4f krb5: Don't cache/reuse referral TGTs
Prior to this change _krb5_get_cred_kdc_any() would include TGTs obtained
via KDC referrals in the "*ret_tgts" array returned to the caller.  The
caller typically stores these TGTs in the active credential cache.

However, referrals TGTs must not be cached or reused for any request
beyond the one it was issued for.  The referral is for a specific service
principal and the resulting TGT could include service specific AuthData.
The referral might also direct the client along a transitive path that
is specific to this service and not applicable in the general case.

This change removes the *ret_tgts parameter from get_cred_kdc_referral()
so that the obtained TGTs are never returned to its caller.   This also
prevents these TGTs from being used by any subsequent call to
get_cred_kdc_capath().

Change-Id: Iacc76c5b1639af3cf6bf277966cfd1535dd1e84d
2015-03-14 16:08:25 -04:00
Nicolas Williams
0f1ae2d101 Use KRB5_TC_MATCH_TIMES when looking for creds 2013-09-12 12:14:39 -05:00
Jeffrey Altman
5f138a16ef libkrb5: Add missing KRB5_LIB_FUNCTION/KRB5_LIB_CALL
KRB5_LIB_FUNCTION and KRB5_LIB_CALL are necessary even on private
functions that are exported.

Change-Id: Iccd0cfe87ff0a9d851e29890e9cb55b3ae517ce1
2013-06-22 21:17:32 -04:00
Roland C. Dowdeswell
27dd8621fb Remove a couple of NULL deferences in lib/krb5/get_cred.c. 2012-12-03 14:10:12 +08:00
Love Hörnquist Åstrand
1c17814e6f fix memset 2012-11-17 14:12:22 -08:00
Nicolas Williams
3f86831c6c Fix earlier fix for not passing forwardable and friends in TGS-REQs 2012-03-14 23:45:31 -05:00
Nicolas Williams
f13924f267 Fix TGS client to request renewable/forwardable/proxiable if possible
This is necessary because some applications actually need or run
    better with renewable service tickets.  kca is an example
    application; AFS tokens are also another example.
2012-02-16 18:47:58 -06:00
Love Hörnquist Åstrand
1a1bd736c0 merge support for FAST in as-req codepath 2011-10-28 19:25:48 -07:00
Nicolas Williams
ce04492b36 Fix silly bug in krb5_get_credentials_with_flags() 2011-10-22 14:54:27 -05:00
Nicolas Williams
5c54736678 Removed "weak" option and implemented use-referrals/no-referrals 2011-10-22 14:54:26 -05:00
Nicolas Williams
f4471b11d6 Call krb5_set_error_message() and don't clobber ret in debug code 2011-10-22 14:54:25 -05:00
Nicolas Williams
9f5a43084c Cleanups: s/ENOMEM/krb5_enomem(context)/ 2011-10-22 14:54:25 -05:00
Nicolas Williams
a5e77c578e Deferred hostname canon using name canon rules 2011-10-22 14:54:13 -05:00
Love Hornquist Astrand
aaf9594429 new use of _krb5_extract_ticket 2011-07-24 20:24:38 -07:00
Love Hörnquist Åstrand
0f489b7b28 unexport krb5_init_etype, remove duplicate code 2011-06-14 21:08:52 -07:00
Nicolas Williams
2fbad6432b Initial support for default_{as, tgs}_etypes.
Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2011-06-14 20:35:19 -07:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Jeffrey Altman
6850d6a65f avoid uninit variable and unreachable code warnings
most of these warnings are not problems because of ample
use of abort() calls.  However, the large number of warnings
makes it difficult to identify real problems.  Initialize
the variables to shut up the compilers.

Change-Id: I8477c11b17c7b6a7d9074c721fdd2d7303b186a8
2011-05-17 12:02:16 -04:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00
Love Hornquist Astrand
42f9c644cf Also try key usage 8 for tgs-rep subkey
If the is Windows 2000 DC, we need to retry with key usage 8 when doing ARCFOUR.

Thanks to Andrew and Tridge that helped me debug this using their systems.
2010-11-29 11:19:24 -08:00
Love Hornquist Astrand
c6d0dea6be remove dup prototype, fix the ok_as_delegate protocol 2010-11-25 11:21:05 -08:00