Commit Graph

249 Commits

Author SHA1 Message Date
Nicolas Williams
62176f07d9 kuser: Fix coverity issues 2022-01-20 13:28:39 -06:00
Nicolas Williams
554f375626 kinit: Use optimistic anon PKINIT armored FAST
Now that we can optimistically try FAST w/ anon PINIT armor, we should
do so in kinit whenever it makes sense.
2021-12-30 18:54:54 +11:00
Nicolas Williams
3da32ef699 Revert "kinit: Try anon PKINIT armored FAST when possible"
This reverts commit 313caed18a.
2021-12-15 10:18:39 -06:00
Nicolas Williams
313caed18a kinit: Try anon PKINIT armored FAST when possible 2021-12-14 17:32:20 +11:00
Luke Howard
22c7e85c57 kinit: add --kdc-hostname option 2021-12-14 09:03:42 +11:00
Luke Howard
9b55215a2a kdc: sync KDC FAST with Heimdal-597.121.1
Import KDC FAST from Apple's Heimdal-597.121.1, adding support for:

  - PA-ENC-CHALLENGE
  - reply key strengthening
  - FAST authentication in TGS

kuser: Apple sync (squash)

krb5_init_creds_store_config/krb5_init_creds_warn_user in kinit
2021-12-14 09:03:42 +11:00
Luke Howard
49f3f5bd99 kdc: support for GSS-API pre-authentication
Add support for GSS-API pre-authentication to the KDC, using a simplified
variation of draft-perez-krb-wg-gss-preauth-02 that encodes GSS-API context
tokens directly in PADATA, and uses FX-COOKIE for state management.

More information on the protocol and implementation may be found in
lib/gssapi/preauth/README.md.
2021-08-12 17:37:01 +10:00
Luke Howard
ef1d63a997 kinit: add --pk-anon-fast-armor option
Add the  --pk-anon-fast-armor option, which acquires a temporary anonymous
PKINIT TGT to use as a FAST armor key.
2021-08-10 15:30:45 +10:00
Nicolas Williams
be3a640b69 kinit: Fix --anonymous renewal bug
`kinit --anonymous ... some long running command here` will eventually
fail to renew the anon TGT.
2021-05-21 11:00:58 -05:00
Nicolas Williams
6b8487f44b kinit: Fix kinit -R crash 2021-03-31 22:59:38 -05:00
Nicolas Williams
afa1624682 kinit: Make --default-for behavior optional
Scripts that run kinit -k will break otherwise.
2021-03-31 22:59:38 -05:00
Nicolas Williams
b0e5c471f6 kinit: Do not switch cache when --default-for given
Unless --change-default is also given.
2021-03-31 22:59:38 -05:00
Nicolas Williams
f47e64bb5a kinit: Work again w/o -c or KRB5CCNAME 2020-08-27 23:54:03 -05:00
Nicolas Williams
261015c918 kinit: Restore get_switch_cache behavior from 5bbe7c8dc 2020-05-28 11:08:54 -04:00
Nicolas Williams
d1d900034f kinit: Make default-for-princ behavior optional
We can't just default to useing the krb5_cc_default_for() ccache for a
principal -- that breaks a number of uses of kinit.
2020-05-25 14:07:05 -05:00
Nicolas Williams
a8874a62bb krb5: Fix kinit harder
The previous fixes for using `krb5_cc_default_for()` weren't quite
correct.
2020-03-17 19:13:16 -05:00
Nicolas Williams
02db43a1ae kinit: Prefer the default ccache when user_realm
If using the new --cache-default-for option, use the real default if the
principal is the best principal for the user.

A principal is the best principal for a user when the principal has just
one component, the component is the user's username, and the realm is
the configured user_realm.
2020-03-12 21:02:09 -05:00
Nicolas Williams
7dae771eef kinit: Add --cache-default-for flag (fix check-cc) 2020-03-12 21:02:09 -05:00
Nicolas Williams
86bb80d7cf Revert cccol changes to kinit 2020-03-12 10:57:49 -05: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
Viktor Dukhovni
5bbe7c8dc6 Implement forwarding of leaf TGTs to selected realms.
Refactor and enhance TGT forwarding to allow forwarding of leaf
(destination) TGTs for selected destination realms.

Enhance kinit(1) to renew non-origin realm tickets

Document delegate-destination-tgt

Use the newly implemented _krb5_mk_1cred().
2019-10-30 16:20:58 -05:00
Viktor Dukhovni
fae8df3839 Optional backwards-compatible anon-pkinit behaviour
* Anonymous pkinit responses from the KDC where the name
  type is not well-known (as issued by 7.5 KDCs and earlier)
  are accepted by the client.  There is no need for the client
  to strictly enforce the name type.

* With historical_anon_pkinit = true, the kinit(1) client's
  "--anonymous" option only performs anon pkinit, and does
  not require an '@' prefix for the realm argument.

* With historical_anon_realm = true, the KDC issues anon
  pkinit tickets with the legacy pre-7.0 "real" realm.
2019-09-04 18:00:15 -04:00
Luke Howard
eacfcd5ce1 kuser: use anon_pkinit_realm instead of anon-pkinit-realm
MIT prefers underscores in ccache configuration file keys, so in the interest
of future interoperability use anon_pkinit_realm instead of anon-pkinit-realm
when storing the anonymous PKINIT TGS realm.
2019-05-22 14:42:55 +10:00
Luke Howard
3138c1836c kuser: plug leak in kinit anonymous PKINIT renew
Do not leak the result of krb5_cc_get_config() when determining anonymous
PKINIT start realm.
2019-05-22 14:04:22 +10:00
Luke Howard
d89b5cb966 kuser: allow kinit to renew anonymous PKINIT tickets
Anonymous PKINIT tickets discard the realm information used to locate the
issuing AS. Store the issuing realm in the credentials cache in order to locate
a KDC which can renew them.
2019-05-21 16:00:20 +10:00
Jeffrey Altman
bdcd7d2f3d krb5_principal_is_anonymous
_krb5_principal_is_anonymous() is used outside lib/krb5 and
therefore it needs to be properly exported and its flag macros
need to be in a public header: krb5.h not krb5_locl.h.

Including krb5_locl.h from within kuser_locl.h for instance
results in build failures on Solaris.

This change renames the function and makes it part of the public
api.

Change-Id: I130d1698b10bdbd150b95e8c7d32dfc362889ce6
2019-05-16 16:23:20 +10:00
Luke Howard
5ca229e0d9 krb5: krb5_get_init_creds_opt_set_pkinit flag names
Add macros to give symbolic names to the flags which can be passed to
krb5_get_init_creds_opt_set_pkinit(). Reserve flags for BTMM and not validating
KDC anchors.
2019-05-14 15:16:19 -04:00
Luke Howard
bcc90f1b87 krb5: _krb5_principal_is_anonymous() helper API
Add _krb5_principal_is_anonymous() private API for checking if a principal is
anonymous or not. The third argument determines whether to match authenticated
anonymous, unauthenticated anonymous, or both types of principal.
2019-05-14 15:16:19 -04:00
Luke Howard
3051db0d5d kuser: support authenticated anonymous AS-REQs in kinit
Allow kinit to request anonymous tickets with authenticated clients, not just
anonymous PKINIT.
2019-05-14 15:16:19 -04:00
Isaac Boukris
efb111e450 Separate enterprise and canonicalize flags
The meaning of the two is different and we should
not implicitly set both if one was requested (this
aligns the logic with MIT kinit -C/-E options).

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
2018-12-26 16:55:13 -06:00
Luke Howard
2e1304b9d5 kinit: don't leave dangling temporary ccaches
kinit does not destroy ccaches created with krb5_cc_new_unique() if ticket
acquisition fails. This was leaving dangling keyring entries with the keyring
ccache.
2018-12-24 01:06:01 -06:00
Daria Phoebe Brashear
6428136e18 kinit: use result of security framework test to enable its use
we already test for the security framework. use the result of it
to decide if we want to enable its use
2017-10-30 18:41:22 -04:00
Jeffrey Altman
93518bfab4 use memset_s
lib roken includes support for memset_s() but it was not applied
to the Heimdal source tree.

Change-Id: I8362ec97a9be50205bb2d398e65b629b88ce1acd
2017-04-29 01:05:59 -04:00
Jeffrey Altman
dcd3e45e02 kinit: fix 13c8a2c212
In 13c8a2c212 permits fclose() to
be issued on 'stdin' and forgets to use the N_() macro for text
strings.

Change-Id: I5e9ac1354da8dcff5277c39e4784a768ad76afdd
2017-04-24 17:46:52 -04:00
Nicolas Williams
bbaae5f43c Fix 32-bit time_t regression (#220) 2016-12-06 22:44:23 -06:00
Nicolas Williams
7fa85e6d6d Round #3 of scan-build warnings cleanup 2016-11-16 23:27:27 -06:00
Jeffrey Altman
a013e93e95 default life/renewlife time to KDC policy
Instead of imposing a default 10 hour ticket lifetime and 1 month renew
lifetime when requesting tickets, increase the default lifetime and
renew lifetime to 2147483647 seconds.  This ensures that in the absence
of any other configuration or command line parameters that the KDC will
determine the ticket lifetime and renew lifetime.

Change-Id: I52b6eeac1ee830a9bf4d0130e8f4ec7b70bc8694
Signed-off-by: Nicolas Williams <nico@twosigma.com>
2016-11-10 16:13:10 -06:00
Nicolas Williams
b4cf4de807 Fix warnings (clang 3.6) 2016-02-26 01:04:31 -06:00
Nicolas Williams
a449b7ef5e Store default NTLM domain cc config
This is needed so that the NTLM GSS mechanism can have a meaningful
concept of default credential (the NTLM key for the default domain found
in the ccache).
2015-04-17 10:51:51 -05:00
Nicolas Williams
333c6fe95d Fix leak in kinit 2015-03-24 11:50:03 -05:00
Love Hörnquist Åstrand
a84b572747 resurrect password change support again 2014-08-22 20:19:36 -07:00
Viktor Dukhovni
6501ba7e95 Avoid appearance of if if else ambiguity 2014-07-22 18:03:04 -04:00
Viktor Dukhovni
d75e74b2d7 Avoid kinit NPE when default cred not in keytab 2014-07-22 17:57:17 -04:00
Jeffrey Altman
69c2872dbd kinit: get_switched_ccache
Provide a new internal function called get_switched() to encapsulate
the algorithm for selecting a credential cache when the selected
ccache type supports switching.  There is no change in behavior for
UNIX which always calls krb5_cc_new_unique().  However, on Windows
alternate behavior is provided when the ccache type is API or MSLSA.

For the API ccache the default ccache name is stored in the Windows
registry which is shared across all logon sessions belonging to a
user.  For users that are members of the Administrators group this
includes both the UAC restricted and elevated sessions sharing the
same desktop.  It is very disconcerting when the elevated session obtains
credentials for the same client principal as the restricted session
and then all apps in the restricted session lose access to their
credential cache.   For Windows, the API credential caches are named
after the principal that is stored within them.  It provides for a
better end user experience.

For the MSLSA ccache tickets belonging to multiple principals are
all stored within the MSLSA ccache.  As a result, all attempts to
switch ccache names default back to the one and only one name.

Change-Id: I7865cd044cff01ff38ab107ec0961e42788fa073
2014-05-14 21:52:35 -04:00
Viktor Dukhovni
b09e1a137b Use defrealm in last-resort parse of kt principal 2013-10-11 20:54:46 -04:00
Love Hornquist Astrand
1b39c562d5 use STDERR_FILENO instead of 2 2013-09-27 08:24:51 -07:00
Viktor Dukhovni
2ccdebdacc Fix kinit renew vs. new strategy.
The previous code never obtained a new TGT when -l was not used.
2013-09-23 11:02:08 -04:00
Nicolas Williams
129b4f3720 Fix warning in ! NO_AFS case 2013-09-12 12:14:42 -05:00
Nicolas Williams
c9d390acac Don't use "if (!ret)" 2013-09-12 12:14:41 -05:00
Nicolas Williams
8696739102 Add SIGINFO support for kinit cmd
Use SIGUSR1 if there's no SIGINFO, so the code isn't dead.
2013-09-12 12:14:41 -05:00