Commit Graph

27779 Commits

Author SHA1 Message Date
Nicolas Williams
edb6c1b075 kadmin: del_enctype whitespace
Fix whitespace and bracing in del_enctype().

No functional change.

Change-Id: I4e70b381aa54a6b0965c88713fbfb4d29bc4495e
2015-03-14 16:08:36 -04:00
Nicolas Williams
6683650337 kadmin: add_enctype fix whitespace
Correct whitespace in add_enctype()

Change-Id: Iebc1df46496b0340c418d7a44a6071b48f44f828
2015-03-14 16:08:35 -04:00
Nicolas Williams
db72e66eb9 kadm5: Add functions to check for bogus keys
Introduce kadm5_all_keys_are_bogus() and kadm5_some_keys_are_bogus()
which will be used in later changes.

Change-Id: I3a07ffe07bee7d6eb17c3d2eae91c107e0bac255
2015-03-14 16:08:34 -04: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
d9e3e376a3 tests: Add simple key history test for kdc
Use kadmin cpw with the --keepold parameter to create a history list.

Change-Id: I21811c840be0bd1b8dd8dc66e63f88f8da6fac7e
2015-03-14 16:08:23 -04:00
Nicolas Williams
95e56fa3ae hdb: fix hdb_unseal_keys_kvno return when no history
Prior to this change hdb_unseal_keys_kvno() could return successfully (0)
if the choice_HDB_extension_data_hist_keys extension was found but the
hist_keys list was empty.  As a side effect callers would believe that the
provide hdb_entry keys were unsealed when they weren't.  This could cause
the KDC or kadmin to report invalid key size errors.

If the extension is present and the history list is empty attempt to
unseal the provided hdb_entry using hdb_unseal_keys_mkey().

Change-Id: I9218b02bccdbcf22133a9464a677374db53ade85
2015-03-14 16:08:22 -04:00
Jeffrey Altman
83011252d7 kdc: adjust flags passed to hdb_fetch_kvno()
The KDC's _kdc_db_fetch() cals the database's hdb_fetch_kvno() to obtain
one or more decrypted versioned key sets.  The KDC either requires one
specific key set if a non-zero key version number is provided or all key sets.
The key version zero indicates that the latest key version should be used.

Prior to this change the KDC called hdb_fetch_kvno() with the
HDB_F_KVNO_SPECIFIED flag when the kvno is zero breaking cross-realm
with Active Directory.

As of this change, HDB_F_KVNO_SPECIFIED is set for a non-zero kvno and
HDB_F_ALL_KVNOS is set otherwise.

Change-Id: I32f4d8da9b601d7bbec7d80cc34d0ff94f6670be
2015-03-14 16:08:20 -04:00
Viktor Dukhovni
fca6363307 Drop delegated creds when target is NULL
In gsskrb5_accept_delegated_token() it is wrong to store the delegated
credentials in the default ccache by default.  When the caller does not
provide a target credential handle, we just do nothing and return success.

Test the return value of gsskrb5_accept_delegated_token() against
GSS_S_COMPLETE, rather than 0.
2015-03-10 03:07:29 +00:00
Viktor Dukhovni
ca052eadd5 Fix gss_inquire_cred_by_mech.
Delegated or other explicit credentials were mishandled, the code only
worked correctly when processing default credentials.  In particular
this caused root's default credential cache to be accessed when accepting
delegated credentials in SSH:

    ssh_gssapi_accept_ctx() ->
        ssh_gssapi_getclient() ->
	    gss_inquire_cred_by_mech()

When /tmp/krb5cc_0 contained expired tickets, cascaded credentials
stopped working for non-root users!
2015-03-10 03:07:29 +00:00
Simon Wilkinson
8485250989 roken: Add memset_s implementation
Add an implementation of memset_s to roken.

Some optimising compilers may remove the memset() instruction when it
is used immediately before a free, which defeats its purpose if the
intention is to zero memory before returning it to the heap or stack.

C11 added memset_s, provide a fallback in roken so that memset_s can
be used on all platforms.
2015-03-05 17:06:20 +00:00
Viktor Dukhovni
745eeb1252 Ensure DER form of hxtool ca random serial numbers 2015-03-05 03:57:30 -05:00
Viktor Dukhovni
b7ca6bbc7a Revert "make sure that serial number is valid DER when done ..."
A simpler fix will be the next commit.

This reverts commit 35add96d37.
2015-03-05 03:56:04 -05:00
Love Hörnquist Åstrand
35add96d37 make sure that serial number is valid DER when done (found by Viktor Dukhovni) 2015-03-05 00:26:03 -08:00
Love Hörnquist Åstrand
920eccc59e X11 tools have outlived their usefulness, use SSH and pam with native locker 2015-03-04 19:18:00 -08:00
Viktor Dukhovni
d4fda7e4f0 LLVM unused variable warning 2015-03-04 19:52:58 -05:00
Viktor Dukhovni
0d52fd607f LLVM enum range warning 2015-03-04 19:52:26 -05:00
Viktor Dukhovni
ba39f42b81 TBS vs Certificate sigalg consistency for RSA 2015-03-04 19:51:11 -05:00
Viktor Dukhovni
08c628b240 BN_is_negative is no longer a macro in OpenSSL master 2015-03-04 19:49:40 -05:00
Viktor Dukhovni
529f17bbec OpenSSL master requires more explicit #includes 2015-03-04 19:46:54 -05:00
Viktor Dukhovni
a71fa7b04d Silence LLVM compiler warnings
Should we simply drop FTP from the source at some point?
2015-03-04 19:44:20 -05:00
Viktor Dukhovni
c3ddece8d4 Name canon kdc config breaks iprop 2015-03-04 17:04:20 -05:00
Viktor Dukhovni
e4a8571434 Fix DB: prefix check 2015-03-04 16:58:36 -05:00
Luke Howard
238392809b wincng: Remove trailing space 2015-02-11 20:12:53 +11:00
Luke Howard
5023f55208 Add Windows CNG (BCrypt) support to HCrypto EVP API 2015-02-11 16:00:32 +11:00
Viktor Dukhovni
49861eb2c5 Delay KRB5_KTNAME lookup until keytab resolution.
Previously getenv("KRB5_KTNAME") happened in

    init_context_from_config_file()

which would capture the environment value as an override without
using strdup() to get a private copy, so it would get trashed in
applications that dynamically update the environment (e.g. Perl
code that has a tied %ENV).

The patch delays getenv("KRB5_KTNAME") until the context's value
of default_keytab is actually needed, and the environment can preempt
the context's default at that time.

[ Do we need to worry about issuid() being true initially when the
  context is created, but not later, because the application changes
  both the real and effective uid?  If so the issuid() state should
  be saved when the context is created and the saved value queried. ]
2015-02-06 23:17:50 -05:00
Jeffrey Altman
c1564e2cdb Merge pull request #119 from ktdreyer/ipv6-loopback
ipv6 loopbacks fix
2015-01-25 16:19:05 -05:00
Rok Papež, ARNES
59b8f4ff84 ipv6 loopbacks fix for GNU libc getaddrinfo()
On any OS with a properly implemented getaddrinfo() this change is a
no-op. Passing NULL for the hint is supposed to be the same as an
addrinfo structure with all fields set to 0. There is no need to set
ai_family to AF_UNSPEC because that value is already 0.

GNU libc doesn't follow standard behaviour. Quoting from
http://man7.org/linux/man-pages/man3/getaddrinfo.3.html :

  "Specifying hints as NULL is equivalent to setting ai_socktype and
  ai_protocol to 0; ai_family to AF_UNSPEC; and ai_flags to
  (AI_V4MAPPED | AI_ADDRCONFIG). (POSIX specifies different defaults for
  ai_flags; see NOTES.)"

The NOTES section says:

  "According to POSIX.1-2001, specifying hints as NULL should cause
  ai_flags to be assumed as 0. The GNU C library instead assumes a value
  of (AI_V4MAPPED | AI_ADDRCONFIG) for this case, since this value is
  considered an improvement on the specification."

The patch makes sure that krb5_parse_address works consistently on both
GNU libc and systems that follow POSIX.1-2001 to the letter. Some
incorrect Fedora 17 patches managed to break IPv6 connectivity and were
later backed out (see discussion at https://bugzilla.redhat.com/808147).
This patch resolves the incompatibility.

Signed-off-by: Ken Dreyer <ktdreyer@ktdreyer.com>
2015-01-25 13:51:41 -07:00
Jeffrey Altman
ef8e4da010 only perform dir separator normalization for file paths
Commit ad7e54d698 introduced the use
of _krb5_expand_path_tokens() to expand tokens (and on Windows convert
path delimiters) within credential cache names.  This is safe to do
for the path based credential cache types FILE, DIR and SCC but on
Windows is unsafe for the non-path types.

For example on Windows, the API credential cache names are often based
on the principal name and the principal name is parsed from the ccname.
This practice was introduced with the version v2 ccapi when there was
no method of enumerating the caches from the krb5 library.

This change adds a "filepath" boolean parameter to _krb5_expand_path_tokens()
which is set to TRUE (non-zero) when the input is a file path and FALSE
(zero) when the input is not a file path.  _krb5_expand_path_tokens() will
only perform directory separator normalization on Windows when the
"filepath" parameter is TRUE.

This change is not the preferred solution because it requires that the
library be aware of all credential cache types that use path based
residuals.  The preferred solution would require that the credential cache
implementation indicate whether or not it uses a path based residual.

This change has been implemented using a prefix test and not a change to
struct krb5_cc_ops because existing ccache plugins will not know how to
advertise their use of path based residuals and that path expansion is
safe.

Change-Id: I8135991e8ce69fc5273d381ea9c2078bc2bcd19a
2015-01-07 14:43:19 -05:00
Jeffrey Altman
b3f29170a3 hcrypto: w32crypto crypt provider handle leak
_hc_CryptProvider() returns a global handle to a Win32 Crypt Provider.
If the global handle is NULL, then a handle is allocated.  Unfortunately,
due to a coding mistake the global handle variable, g_cryptprovider, was
never set and a new handle was allocated with each call.

Refactor the function to ensure that the global handle is the value
that is returned.  Use NULL instead of 0 for pointer assignment.

Change-Id: If1ef3aa19cbd1d51860370db24c086e86922ff0d
2014-12-24 15:49:31 -05:00
Love Hörnquist Åstrand
0e93a04c01 arcfour-hmac-md5 is weak 2014-12-01 15:41:12 -08:00
Roland C. Dowdeswell
92aad0fa3d Fix kinit.1's synopsis w.r.t. -f and -F. 2014-12-01 12:40:54 -05:00
Love Hörnquist Åstrand
5aca37ae55 revert 31be932fe8 2014-09-09 18:50:22 +02:00
Love Hörnquist Åstrand
a220ed39eb try using as-is name_canon_rules 2014-09-09 18:36:57 +02:00
Love Hörnquist Åstrand
24c8bac3b8 In all_etypes prefer des3-cbc-sha1 over arcfour-hmac-md5 2014-09-09 18:15:08 +02:00
Love Hörnquist Åstrand
44ba0bcd24 no need to make chmod quiet, it supposed to be already because of \ 2014-08-23 19:29:04 -07:00
Love Hörnquist Åstrand
c68ab04304 update (c) 2014-08-23 19:14:10 -07:00
Love Hörnquist Åstrand
a7a6771538 merge in changes from #79
fixes #79
2014-08-23 19:08:00 -07:00
Love Hörnquist Åstrand
394a8567fb Merge pull request #87 from jelmer/travis
Add travis config.
2014-08-23 19:04:05 -07:00
Love Hörnquist Åstrand
4b0121f545 release pool when done 2014-08-23 18:54:05 -07:00
Love Hörnquist Åstrand
d1cee9a14b now that use used up more then 16 flags and we have been using the right bit order for many years, lets stop dealing with broken bit fields from ticket flags 2014-08-23 18:48:34 -07:00
Love Hörnquist Åstrand
f05236b202 hush autoconf 2014-08-22 21:52:27 -07:00
Love Hörnquist Åstrand
e6ed2bc9df use LT_INIT only, fixes #95 2014-08-22 21:52:10 -07:00
Love Hörnquist Åstrand
c10e99bead Merge pull request #109 from cg2v/dist-kadmin-version-script
version-script-client.map needs to be in dist
2014-08-22 21:38:55 -07:00
Love Hörnquist Åstrand
4569c07522 Merge pull request #110 from cg2v/anonymous-pkinit
Anonymous pkinit improvements
2014-08-22 21:35:22 -07:00
Love Hörnquist Åstrand
42d4c2b44b Merge pull request #105 from jelmer/compatibility-symlinks
Install compatibility symlinks for kadmin and ktutil.
2014-08-22 21:33:14 -07:00