]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
6 years agoUpdate README in src/man 861/head
Robbie Harwood [Mon, 15 Oct 2018 18:53:05 +0000 (14:53 -0400)] 
Update README in src/man

6 years agoUpdate man pages to reference kerberos(7)
Robbie Harwood [Mon, 15 Oct 2018 19:19:12 +0000 (15:19 -0400)] 
Update man pages to reference kerberos(7)

Remove broken references to old kerberos(1).  Reference kerberos(7)
from all man pages, and create/update their environment section so
that it references kerberos(7).

ticket: 8755

6 years agoModernize kerberos(7)
Robbie Harwood [Mon, 15 Oct 2018 17:20:30 +0000 (13:20 -0400)] 
Modernize kerberos(7)

Update environment variable descriptions, using env_variables.rst as a
guide.  Replace the content in env_variables.rst with a pointer to
documentation at kerberos(7) so that we don't break external links and
don't duplicate content.

Replace references to rlogin.  Clarify and modernize other language.

ticket: 8755

6 years agoBring back general kerberos man page
Robbie Harwood [Tue, 9 Oct 2018 21:05:10 +0000 (17:05 -0400)] 
Bring back general kerberos man page

Restore the content of kerberos(1) as it stood in
0f81e372a2830c9170f6e08dfa956841d0ebdfb1.  Convert to ReST to match
the other man pages, and install it as the more appropriate
kerberos(7).

Build kerberos(7) and check it in to avoid breaking the build.

ticket: 8755 (new)
tags: pullup
target_version: 1.16-next

6 years agoAdd GSS_KRB5_NT_ENTERPRISE_NAME name type 857/head
Isaac Boukris [Mon, 15 Oct 2018 15:33:15 +0000 (18:33 +0300)] 
Add GSS_KRB5_NT_ENTERPRISE_NAME name type

Add a new name-type OID which causes a string to be imported as an
enterprise name.  This is useful for authenticating and impersonating
users with their UPN names.

Resurrect t_imp_name test to exercise importing of the new name OID.
Also add a test using the new name in cross-realm protocol transition,
to exercise s4u_identify_user() with multiple realms.

[ghudson@mit.edu: added Windows export entry; adjusted comments and
test code; edited commit message]

ticket: 8756 (new)

6 years agoStart S4U2Self realm lookup at server realm
Isaac Boukris [Tue, 23 Oct 2018 09:52:41 +0000 (12:52 +0300)] 
Start S4U2Self realm lookup at server realm

When looking up the realm of an enterprise principal, start with the
realm of the server instead of the realm attached to the enterprise
name, as specified in [MS-SFU] 3.1.5.1.1.1.

[ghudson@mit.edu: simplified out client_data+client into just client;
edited commit message]

ticket: 8757 (new)

6 years agoDon't dump policies if principals are specified 862/head
Greg Hudson [Mon, 15 Oct 2018 22:32:31 +0000 (18:32 -0400)] 
Don't dump policies if principals are specified

If kdb5_util dump is asked to filter for specific principals, do not
dump the policy database.

ticket: 8752 (new)

6 years agoFix up kdb5_util documentation
Greg Hudson [Mon, 15 Oct 2018 22:00:35 +0000 (18:00 -0400)] 
Fix up kdb5_util documentation

In kdb5_util.rst, reorder the main option summary to match the order
they are documented in below, and document the -x option.  Remove the
kdb5_util create -h switch case as 'h' has never been in the getopt
string.  Add the -r18 option to the kdb5_util dump and load option
summaries.  Reword the kdb5_util load -hash option.  Remove the
nonexistent kdb5_util load dbname parameter.

In database.rst, alter the example for loading a single principal to
use the dump principal filtering functionality, as that functionality
does not currently exist for load.

In the kdb5_util usage error message, reorder the main options to
match the order in the documentation and to fit within 79 columns.
Also add the -P option.

ticket: 8751 (new)
tags: pullup
target_version: 1.16-next

6 years agoFix up some strings in recent t_pac.c tests 860/head
Isaac Boukris [Sat, 13 Oct 2018 13:36:55 +0000 (16:36 +0300)] 
Fix up some strings in recent t_pac.c tests

ticket: 8749

6 years agoAdd test for cross realm S4U2Self using referrals
Isaac Boukris [Sat, 13 Oct 2018 13:27:02 +0000 (16:27 +0300)] 
Add test for cross realm S4U2Self using referrals

[ghudson@mit.edu: factored out tgtname() in kdb_test.c; added trace
messages to tests and removed old redundant test]

ticket: 8747

6 years agoUse port-sockets.h macros in cc_kcm, sendto_kdc 859/head
Greg Hudson [Mon, 15 Oct 2018 23:12:45 +0000 (19:12 -0400)] 
Use port-sockets.h macros in cc_kcm, sendto_kdc

Use SOCKET_CONNECT in cc_kcm.c and sendto_kdc.c to prevent SIGPIPE on
BSD-like systems.  Use other port-sockets.h macros in cc_kcm.c in case
it is ever used on Windows.

ticket: 8753

6 years agoPrevent SIGPIPE from socket writes on UNIX-likes
Robbie Harwood [Fri, 12 Oct 2018 20:57:05 +0000 (16:57 -0400)] 
Prevent SIGPIPE from socket writes on UNIX-likes

When writing to a disconnected socket, try to only get EPIPE rather
than taking down the process with SIGPIPE.

On recent Linux and other systems which have it, switch from writev to
sendmsg and pass MSG_NOSIGNAL.

On BSD-likes, set SO_NOSIGPIPE at connect time.

ticket: 8753 (new)

6 years agoCorrect kpasswd_server description in krb5.conf(5) 864/head
Robbie Harwood [Tue, 16 Oct 2018 21:32:29 +0000 (17:32 -0400)] 
Correct kpasswd_server description in krb5.conf(5)

ticket: 8754 (new)
tags: pullup
target_version: 1.16-next

6 years agoFix 64-bit Windows socket write error handling 855/head
Greg Hudson [Thu, 4 Oct 2018 22:10:48 +0000 (18:10 -0400)] 
Fix 64-bit Windows socket write error handling

Add casts to ensure that the result type of SOCKET_WRITEV() on Windows
can represent -1.  Otherwise it will be treated as 2^32-1 when cast to
ssize_t on 64-bit Windows, which can lead to crashes in
krb5_sendto_kdc().  Reported by Puran Chand.

ticket: 8746 (new)
tags: pullup
target_version: 1.13-next

6 years agoAdd more constraints to S4U2Self processing 853/head
Isaac Boukris [Fri, 5 Oct 2018 11:43:51 +0000 (14:43 +0300)] 
Add more constraints to S4U2Self processing

Of the eight possible combinations of local or cross TGT, local or
non-local user, and local server or referral, four are valid.  The
previous commit rejects two of the invalid cases (local TGT and
referral, with local or non-local user).  Document the four valid
cases and reject the remaining two invalid combinations.

[ghudson@mit.edu: rewrote commit message; added comment documenting
valid combinations; adjusted style and comments]

ticket: 8748 (new)

6 years agoAllow referrals for cross-realm S4U2Self requests
Isaac Boukris [Fri, 5 Oct 2018 11:14:32 +0000 (14:14 +0300)] 
Allow referrals for cross-realm S4U2Self requests

According to MS-SFU 3.2.5.1.1, the KDC should issue a referral for
S4U2Self requests if the requesting service is not in the KDC's realm.
Commit 8a9909ff9ef6b51c5ed09ead6713888fbb34072f explicitly prevents
referrals for S4U2Self requests; on further analysis, this appears to
have been preserving a bug rather than applying a proper constraint.
However, we should not issue referrals for within-realm S4U2Self
requests.  (This should only come up if a server possesses a TGT but
its principal entry has been deleted.)

Remove the S4U2Self referral check in process_tgs_req().  Instead add
a more specific check in kdc_process_s4u2self_req(), adding new
parameters for the header server principal and a flag indicating
whether a referral is indicated.

[ghudson@mit.edu: rewrote commit message; adjusted style slightly]

ticket: 8747 (new)

6 years agoFix multiple leaks in ktutil addent 858/head
Greg Hudson [Thu, 11 Oct 2018 19:33:35 +0000 (15:33 -0400)] 
Fix multiple leaks in ktutil addent

In ktutil_add(), free allocations on success as well as failure.
Change all early returns to jumps to the cleanup label.  Free the
password buffer and unparsed principal name.  Do list manipulation as
the final step to simplify cleanup.  Reported by Bean Zhang.

ticket: 8750

6 years agoAdd tests for different kinds of S4U2Self PACs 852/head
Isaac Boukris [Tue, 2 Oct 2018 13:22:31 +0000 (16:22 +0300)] 
Add tests for different kinds of S4U2Self PACs

These new tests are based on PACs obtained from network captures.

[ghudson@mit.edu: adjusted style; added U() macro for nicer-looking
keyblock initializers]

ticket: 8749

6 years agoAdd PAC APIs which can include a client realm
Isaac Boukris [Sat, 29 Sep 2018 04:21:56 +0000 (07:21 +0300)] 
Add PAC APIs which can include a client realm

These APIs are needed for KDC handling of cross-realm S4U2Self
tickets; see [MS-SFU] 3.2.5.x.  Note that we currently do not allow
re-signing a PAC to include the realm; the caller must create a new
one.

[ghudson@mit.edu: added documentation; changed names and parameter
order; edited commit message]

ticket: 8749 (new)

6 years agoPrefer TCP to UDP for password changes 856/head
Robbie Harwood [Mon, 8 Oct 2018 20:02:12 +0000 (16:02 -0400)] 
Prefer TCP to UDP for password changes

When password changes are performed over UDP, spotty networks may
cause the client to retransmit.  This leads to replay errors if the
kpasswd server receives both requests, which hide the actual request
status and make it appear that the password has not been changed, when
it may in fact have been.  Use TCP instead with UDP fallback to avoid
this issue.

ticket: 7905

6 years agoAdd ktutil addent option to fetch salt from KDC 670/head
Greg Hudson [Thu, 27 Sep 2018 22:32:24 +0000 (18:32 -0400)] 
Add ktutil addent option to fetch salt from KDC

Add a -f flag to ktutil addent.  If specified, the enctype need not be
specified (although it can be) and ktutil will request etype-info from
the KDC to produce the string-to-key parameters.

ticket: 8587

6 years agoAdd API to retrieve etype-info from KDC
Mubashir Kazia [Sat, 24 Jun 2017 19:47:53 +0000 (19:47 +0000)] 
Add API to retrieve etype-info from KDC

Add the krb5_get_etype_info() API, which sends an initial ticket
request to the KDC and extracts an enctype, salt, and s2kparams value
from the first KDC reply.  This function will help ktutil use the
correct salt and s2kparams when creating keytabs.

[ghudson@mit.edu: renamed API to krb5_get_etype_info() and adjusted
behavior]

ticket: 8587

6 years agoDisable stdin buffering in libss dummy readline 854/head
Greg Hudson [Wed, 3 Oct 2018 22:45:56 +0000 (18:45 -0400)] 
Disable stdin buffering in libss dummy readline

readline() is careful not to read more bytes from fd 0 than it has to.
Do the same in the dummy libss readline() by disabling stdin
buffering.

ticket: 8745

6 years agoUse "replica" in iprop settings 851/head
Greg Hudson [Thu, 27 Sep 2018 16:14:25 +0000 (12:14 -0400)] 
Use "replica" in iprop settings

Change the default dump filename for iprop to "replica_datatrans", and
the iprop poll interval profile variable to "iprop_replica_poll",
preserving compatibility with the old name.

ticket: 8742 (new)

6 years agoUse the term "replica KDC" in source and docs
Greg Hudson [Mon, 17 Sep 2018 13:59:47 +0000 (09:59 -0400)] 
Use the term "replica KDC" in source and docs

ticket: 8738 (new)

6 years agoFix incorrect TRACE usages to use {str} 850/head
Robbie Harwood [Thu, 27 Sep 2018 21:45:59 +0000 (17:45 -0400)] 
Fix incorrect TRACE usages to use {str}

ticket: 8743 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

6 years agoClarify sign_authdata() KDB method comments 843/head
Isaac Boukris [Wed, 12 Sep 2018 13:32:57 +0000 (16:32 +0300)] 
Clarify sign_authdata() KDB method comments

6 years agoDon't rely on default realm in S4U2Self client
Isaac Boukris [Sat, 15 Sep 2018 07:28:48 +0000 (10:28 +0300)] 
Don't rely on default realm in S4U2Self client

When converting server principal to enterprise name (to be possibly
used for cross-realm), ignore the realm when reparsing, to avoid a
spurious error if a default realm isn't configured.

[ghudson@mit.edu: added rewritten test case; edited commit message]

ticket: 8741
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

6 years agoFix getdate.y compatability with POSIX yacc 849/head
Robbie Harwood [Tue, 25 Sep 2018 17:20:55 +0000 (13:20 -0400)] 
Fix getdate.y compatability with POSIX yacc

Commit 28fd0a934cdc7b3b42ce213c6d334d4edf1ab591 muted a warning from
bison about shift/reduce conflicts in the grammer.  However, the
extension for suppressing the warning is bison-only.  Revert that
portion of the change and live with the warning rather than adding
additional conditionalization.  Reported by Michael Osipov.

6 years agoRemove LDAP osa_princ_ent_rec XDR functions 848/head
Greg Hudson [Fri, 21 Sep 2018 19:00:11 +0000 (15:00 -0400)] 
Remove LDAP osa_princ_ent_rec XDR functions

The LDAP KDB module contained a duplicate set of functions to marshal
osa_princ_ent_ret structures, perhaps to avoid a circular dependency
on libkadm5srv before KDB modules were dynamically loaded.  We have
been using the libkadm5srv versions of those functions from the DB2
KDB module since release 1.8.  Use them from the LDAP KDB module as
well.

Since no rpcgen output remains in princ_xdr.c and princ_xdr.h, add
emacs mode lines for the krb5 C style to those files and make small
formatting adjustments to match.

6 years agoClarify documentation on pkinit_identities 841/head
Greg Hudson [Thu, 6 Sep 2018 17:20:56 +0000 (13:20 -0400)] 
Clarify documentation on pkinit_identities

The documentation for pkinit_identities implies that we try harder to
use each value before ignoring the rest, when in fact we only go as
far as the first successful parse.  Soften the language and describe
the most likely use case for multiple values under the current
semantics.

ticket: 8733
tags: pullup
target_version: 1.16-next

6 years agoFix null deref on some invalid PKINIT identities
Greg Hudson [Thu, 6 Sep 2018 15:47:56 +0000 (11:47 -0400)] 
Fix null deref on some invalid PKINIT identities

pkinit_identity.c:parse_fs_options() could crash if the first
strtok_r() call returns NULL, which happens when the residual string
begins with ','.  Fix this bug by checking for a leading comma and
checking the strtok_r() result, and add a test case.  Reported by Bean
Zhang.

Also return EINVAL rather than 0 on invalid input, and don't leave an
allocated value in idopts->cert_filename if we fail to copy the key
filename.

ticket: 8726

6 years agoAlways honor desired_name in gss_add_cred() 847/head
Greg Hudson [Sat, 15 Sep 2018 00:35:50 +0000 (20:35 -0400)] 
Always honor desired_name in gss_add_cred()

Remove the conditionalization around the desired_name processing in
gss_add_cred_from(), so that we always honor the requested name.

ticket: 8737
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

6 years agoFix misleading indentation in clnt_udp.c 846/head
Robbie Harwood [Tue, 18 Sep 2018 18:19:55 +0000 (14:19 -0400)] 
Fix misleading indentation in clnt_udp.c

gcc warns that the `if` statement doesn't guard the length
assignment, which is true.  However, it wouldn't make sense for the
length assignment to be guarded by the `if` clause anyway, since the
previous statement is a `goto`.  De-indent for clarity.

6 years agoFix memory bugs in gss_add_cred() extension case 845/head
Greg Hudson [Thu, 13 Sep 2018 20:31:36 +0000 (16:31 -0400)] 
Fix memory bugs in gss_add_cred() extension case

If gss_add_cred() is called with both an input_cred_handle and an
output_cred_handle, it creates a new credential with the elements of
the input credential plus the requested element.  Making a shallow
copy of mechs_array and cred_array from the old credential creates
aliased pointers which become invalid when one of the two credentials
is released, leading to use-after-free and double-free errors.

Instead, make a full copy of the input cred for this case.  Make this
copy at the beginning so that union_cred can always be modified in
place (and freed on error using gss_release_cred() if we created it),
removing the need for new_union_cred, new_mechs_array, and
new_cred_array.  Use a stack object for target_mechs to simplify
cleanup and reduce the number of failure cases.

GSSAPI provides no facility for copying a credential; since we mostly
use the GSSAPI as our SPI for mechanisms, we have no simple way to
copy mechanism creds when copying the union cred.  Use
gss_export_cred() and gss_import_cred() if the mechanism provides
them; otherwise fall back to gss_inquire_cred() and
gss_acquire_cred().

ticket: 8734
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

6 years agoFix memory leak in gss_add_cred() creation case 844/head
Greg Hudson [Thu, 13 Sep 2018 15:29:46 +0000 (11:29 -0400)] 
Fix memory leak in gss_add_cred() creation case

If gss_add_cred() is called with no input_cred_handle, it creates a
new credential with one element.  At the end of the function, use the
created credential as the output container, rather than creating a
second one and leaking the first.

Add a test program for gss_add_cred() and run it.

ticket: 8729
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

6 years agoCheck mech cred in gss_inquire_cred_by_mech() 842/head
Greg Hudson [Thu, 13 Sep 2018 21:03:36 +0000 (17:03 -0400)] 
Check mech cred in gss_inquire_cred_by_mech()

If gss_inquire_cred_by_mech() is called with a mechanism and there is
no corresponding mechanism credential in the union cred, return
GSS_S_NO_CRED (as Heimdal does) instead of interrogating the mechanism
about the default credential.

ticket: 8736 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

6 years agoRemove strftime() conditionalization 840/head
Greg Hudson [Wed, 5 Sep 2018 19:35:12 +0000 (15:35 -0400)] 
Remove strftime() conditionalization

strftime() is specified in C89.  The tree has not built without a
native strftime() at least as far back as 1.7 (because it is used
unconditionally in kdb5_mkey.c) and possibly for much longer.  Remove
the two copies of the NetBSD strftime.c and the fallback ctime() in
logger.c.

6 years agoCheck more time function results 838/head
Greg Hudson [Sat, 1 Sep 2018 21:30:33 +0000 (17:30 -0400)] 
Check more time function results

In logger.c:klog_vsyslog(), check the return value of localtime().  In
ldap_principal2.c:getstringtime(), check the strftime() result and
don't leak strtime on error.

6 years agoFix name of .pdb file in ccapi/test/Makefile.in 837/head
Greg Hudson [Fri, 31 Aug 2018 17:19:21 +0000 (13:19 -0400)] 
Fix name of .pdb file in ccapi/test/Makefile.in

The -Fd cl option specifies the location of the program database
filename, which should have the extension .pdb.  Using a .obj
extension causes a build failure with MSVC version 14.15.26726.

ticket: 8732 (new)

6 years agoCheck return values of time functions 834/head
Greg Hudson [Wed, 29 Aug 2018 19:04:13 +0000 (15:04 -0400)] 
Check return values of time functions

Where ctime(), localtime(), or localtime_r() is used, check for
failure even if it is unlikely (reported by Bean Zhang).  Constify the
strdate() return type in kdb5_mkey.c and kadmin.c and the
ctime_uint32() return type in kproplog.c.  Use localtime_r()
unconditionally in str_conv.c as there is already a wrapper in that
file for the case where the platform doesn't have it.  Remove an
inoperative localtime() call in ktutil.c.

6 years agoCheck malloc() result in ss_execute_command() 835/head
Greg Hudson [Wed, 29 Aug 2018 19:40:24 +0000 (15:40 -0400)] 
Check malloc() result in ss_execute_command()

Reported by Bean Zhang.

6 years agoCheck strdup return in kadm5_get_config_params() 832/head
Greg Hudson [Tue, 28 Aug 2018 01:10:53 +0000 (21:10 -0400)] 
Check strdup return in kadm5_get_config_params()

When copying the realm string, if strdup() returns NULL, fail out with
ENOMEM instead of pretending the realm wasn't specified.  When copying
KRB5_DEFAULT_SUPPORTED_ENCTYPES, if strdup() returns NULL, fail out
with ENOMEM instead of crashing.  Reported by Bean Zhang.

ticket: 8727
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

6 years agoDocument that DESTDIR must be an absolute path 833/head
Greg Hudson [Tue, 28 Aug 2018 16:11:35 +0000 (12:11 -0400)] 
Document that DESTDIR must be an absolute path

ticket: 8731 (new)
tags: pullup
target_version: 1.16-next

6 years agoModernize krb5int_cc_creds_match_request() style 823/head
Greg Hudson [Fri, 3 Aug 2018 04:45:43 +0000 (00:45 -0400)] 
Modernize krb5int_cc_creds_match_request() style

6 years agoLimit matching of user-to-user ccache credentials
Greg Hudson [Fri, 3 Aug 2018 04:36:10 +0000 (00:36 -0400)] 
Limit matching of user-to-user ccache credentials

In krb5int_cc_creds_match_request(), do not yield a user-to-user
credential if the caller is not looking for one; it would not be
useful when a normal service ticket (encrypted in the service key) is
required.  Reported by Todd Lubin.

ticket: 8718

6 years agoDon't tag S4U2Proxy result creds as user-to-user
Greg Hudson [Fri, 3 Aug 2018 15:07:03 +0000 (11:07 -0400)] 
Don't tag S4U2Proxy result creds as user-to-user

S4U2Proxy and user-to-user tickets are both obtained using a
second-ticket input, but only user-to-user tickets are encrypted in
the session key of the second ticket.  In gc_via_tkt.c, stop deducing
the is_skey flag from the presence of a second ticket and instead set
it based on the request KDC options.

ticket: 8721 (new)

6 years agoAdd kvno option for user-to-user 830/head
Greg Hudson [Fri, 24 Aug 2018 15:40:39 +0000 (11:40 -0400)] 
Add kvno option for user-to-user

Add a --u2u option to kvno, with an argument to specify a credential
cache containing a krbtgt for the server principal.  Move the
-allow_svr test from appl/user_to_user to a new test script and add
additional tests.  Suggested by Chris Hecker.

ticket: 8730 (new)

6 years agoUse a hash table for MEMORY ccache resolution 827/head
Greg Hudson [Sun, 5 Aug 2018 03:55:18 +0000 (23:55 -0400)] 
Use a hash table for MEMORY ccache resolution

In cc_memory.c, replace the linked list of caches with a hash table,
for better performance with large numbers of memory caches.

ticket: 8722 (new)

6 years agoUse k5_hashtab in KDC lookaside cache
Greg Hudson [Sun, 5 Aug 2018 00:23:11 +0000 (20:23 -0400)] 
Use k5_hashtab in KDC lookaside cache

6 years agoAdd a hash table implementation to libkrb5support
Greg Hudson [Sun, 5 Aug 2018 00:11:09 +0000 (20:11 -0400)] 
Add a hash table implementation to libkrb5support

6 years agoCheck public_oid in gss_export_cred() 828/head
Greg Hudson [Fri, 10 Aug 2018 15:58:11 +0000 (11:58 -0400)] 
Check public_oid in gss_export_cred()

In gss_export_cred(), check the gssint_get_public_oid() result as well
as the gssint_get_mechanism() result.  There are probably no cases
where the former returns NULL and the latter does not, but it is easy
to be more obviously correct.  Reported by Bean Zhang.

6 years agoFix a typo in the kswitch man page 829/head
Greg Hudson [Mon, 13 Aug 2018 02:53:29 +0000 (22:53 -0400)] 
Fix a typo in the kswitch man page

Fix a typo introduced by commit
fe44da52deea41483326debf2d9ad525f65e19f6.  Reported by Matthew
Krupcale.

ticket: 8728
tags: pullup
target_version: 1.16-next

6 years agoUpdate many documentation links to https 826/head
Greg Hudson [Wed, 8 Aug 2018 19:30:38 +0000 (15:30 -0400)] 
Update many documentation links to https

Use secure URLs in the documentation where possible.  The Sphinx web
site does not appear to have a valid server cert, but does have a more
official URL.

ticket: 8725 (new)
tags: pullup
target_version: 1.16-next

6 years agoFix memory leaks in test programs 824/head
Greg Hudson [Sun, 5 Aug 2018 23:00:33 +0000 (19:00 -0400)] 
Fix memory leaks in test programs

Fix additional memory leaks detected by a newer asan (clang version
6.0.0) in test programs.

6 years agoModernize krb5_read_password()
Greg Hudson [Sun, 5 Aug 2018 22:48:57 +0000 (18:48 -0400)] 
Modernize krb5_read_password()

In krb5_read_password(), don't reuse k5prompt for verification as we
will reference it later.  Also use make_data() and zap(), and clean up
formatting.

6 years agoAdd kdestroy -p option 825/head
Greg Hudson [Wed, 8 Aug 2018 15:45:28 +0000 (11:45 -0400)] 
Add kdestroy -p option

Add an option to destroy a cache within a collection by principal
name.  This option can be used together with -c to specify the
collection.  Also document that kdestroy -A and -c can be used
together (ticket 8602).

ticket: 8724 (new)

7 years agoUse PTHREAD_CFLAGS when testing for getpwnam_r() 817/head
sashan [Mon, 23 Jul 2018 12:56:15 +0000 (12:56 +0000)] 
Use PTHREAD_CFLAGS when testing for getpwnam_r()

On Solaris, AX_PTHREAD can include -D_POSIX_PTHREAD_SEMANTICS in
PTHREAD_CFLAGS, which affects which variants of getpwnam_r() and
getpwuid_r() are declared by system headers.  In configure.in, use
PTHREAD_CFLAGS when testing for those functions to make sure that the
tests see the same variants as the build will.

[ghudson@mit.edu: rewrote commit message and comment]

ticket: 8723 (new)

7 years agoDon't include all MEMORY ccaches in collection 822/head
Greg Hudson [Wed, 1 Aug 2018 19:53:12 +0000 (15:53 -0400)] 
Don't include all MEMORY ccaches in collection

In the MEMORY ccache implementation, only yield a cache in the
per-type cursor if it is the context default cache, matching the
behavior of FILE after commit 45360c9688ca963f75a2480f2cf818424fc3dc7b
(ticket 6955).

ticket: 8720 (new)

7 years agoExtend gss-sample timeout from 10s to 300s 821/head
Alejandro Perez [Wed, 1 Aug 2018 07:56:54 +0000 (09:56 +0200)] 
Extend gss-sample timeout from 10s to 300s

Some GSS mechanisms (such as GSS EAP - RFC 7055) require user
interaction, and ten seconds is too little to allow users to select
the identity they want to use or type their password.  Make gss-client
and gss-server more useful for testing these mechanisms by extending
its timeout to five minutes.

[ghudson@mit.edu: edited commit message]

ticket: 8719 (new)

7 years agoAllow u2u requests when -allow_svr is set 818/head
Chris Hecker [Wed, 25 Jul 2018 05:57:23 +0000 (00:57 -0500)] 
Allow u2u requests when -allow_svr is set

If KRB5_KDB_DISALLOW_SVR is set on the server principal, still allow
user-to-user tickets to be issued unless KRB5_KDB_DISALLOW_DUP_SKEY is
also set.  This change makes the KDC_ERR_MUST_USE_USER2USER error
message more appropriate.

ticket: 2641

[ghudson@mit.edu: added test case; updated documentation based on
suggestions by Patrick Moore; edited commit message]

7 years agoFix k5test prompts for Python 3 819/head
Greg Hudson [Wed, 25 Jul 2018 15:50:02 +0000 (11:50 -0400)] 
Fix k5test prompts for Python 3

With Python 3, sys.stdout.write() of a partial line followed by
sys.stdin.readline() does not display the partial line.  Add explicit
flushes to make prompts visible in k5test.py.

ticket: 8710

7 years agoRemove outdated note in krb5kdc man page 816/head
Greg Hudson [Tue, 17 Jul 2018 15:33:03 +0000 (11:33 -0400)] 
Remove outdated note in krb5kdc man page

Commit af5b77c887bfff24603715f8296c00d5eb839b0c (ticket 8348) removed
the interface-scanning workaround for platforms without pktinfo
support, so there is no longer an interaction between the krb5kdc -w
option and this workaround.

ticket: 8716 (new)
tags: pullup
target_version: 1.16-next

7 years agoMake krb5kdc -p affect TCP ports 815/head
Greg Hudson [Tue, 17 Jul 2018 15:29:19 +0000 (11:29 -0400)] 
Make krb5kdc -p affect TCP ports

Now that the KDC listens for TCP connections by default (ticket 6731),
the "-p" option should affect both UDP and TCP default listening
ports.

ticket: 8715 (new)

7 years agoEliminate preprocessor-disabled dead code 813/head
Robbie Harwood [Mon, 16 Jul 2018 19:35:15 +0000 (15:35 -0400)] 
Eliminate preprocessor-disabled dead code

It's been policy for a while now not to create "dead hunks" like
these.  A great deal of this code simply doesn't work because it
hasn't been kept up-to-date, and may never have worked.  Eliminate
these dead hunks along with the complexity to support them.

7 years agoFix some broken tests for Python 3 814/head
Robbie Harwood [Mon, 16 Jul 2018 20:44:01 +0000 (16:44 -0400)] 
Fix some broken tests for Python 3

Remove python2 dependencies in .travis.yml and add python3-paste.
Convert t_daemon.py and jsonwalker.py to python3.  csjon has no
python3 version, so replace it with python's built-in JSON module.

python3-pyrad isn't available for Trusty, so krad and OTP tests are
currently not exercised by Travis.

[ghudson@mit.edu: squashed commits; edited commit message]

ticket: 8710

7 years agoZap copy of secret in RC4 string-to-key
Dylan Gray [Fri, 13 Jul 2018 22:09:01 +0000 (15:09 -0700)] 
Zap copy of secret in RC4 string-to-key

Commit b8814745049b5f401e3ae39a81dc1e14598ae48c (ticket 8576) added a
zero-terminated copy of the input string in
krb5int_arcfour_string_to_key().  This copy should be zeroed when
freed as the input string typically contains a password.

[ghudson@mit.edu: rewrote commit message]

ticket: 8713 (new)

7 years agoUse SHA-256 instead of MD5 for audit ticket IDs 811/head
Greg Hudson [Tue, 10 Jul 2018 20:17:15 +0000 (16:17 -0400)] 
Use SHA-256 instead of MD5 for audit ticket IDs

ticket: 8711 (new)

7 years agoConvert Python tests to Python 3 810/head
Greg Hudson [Tue, 20 Feb 2018 02:10:09 +0000 (21:10 -0500)] 
Convert Python tests to Python 3

Look for python3 in configure.in and verify that we got it.  Convert
test code to conform to Python 3.

ticket: 8710 (new)

7 years agoFix bugs with concurrent use of MEMORY ccaches 804/head
Greg Hudson [Sun, 1 Jul 2018 04:12:25 +0000 (00:12 -0400)] 
Fix bugs with concurrent use of MEMORY ccaches

A memory ccache iterator stores an alias into the cache object's
linked list of credentials.  If the cache is reinitialized while the
iterator is active, the alias becomes invalid.  Also, multiple handles
referencing the same memory ccache all use aliases to the same data
object; if one of the handles is destroyed, the other contains a
dangling pointer.

Fix the first issue by adding a generation counter to the cache and to
cursors, incremented each time the cache is initialized or destroyed.
Check the generation on each cursor step and end the iteration if the
list was invalidated.  Fix the second issue by adding a reference
count to the cache object, counting one reference for the table slot
and one for each open handle.  Empty the cache object on each destroy
operation, but only release the object when the last handle to it is
destroyed or closed.

Add regression tests for the two issues to t_cc.c.

The first issue was reported by Sorin Manolache.

ticket: 8202
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoCheck distclean target in Travis build 809/head
Greg Hudson [Mon, 9 Jul 2018 15:32:57 +0000 (11:32 -0400)] 
Check distclean target in Travis build

Move the build commands to a shell script, run with the -e flag so any
failure causes the script to exit.  In the script, verify that "make
distclean" removes everything produced by "make" and "make check".

7 years agoExplicitly look for python2 in configure.in 806/head
Greg Hudson [Tue, 3 Jul 2018 05:20:50 +0000 (01:20 -0400)] 
Explicitly look for python2 in configure.in

The executable "python" has traditionally been Python 2, but is
becoming more ambiguous as operating systems transition towards Python
3.  Look for "python2" in the path in preference to "python", and
check that what we found isn't Python 3.

Remove the "#!/usr/bin/python" headers at the start of Python test
scripts since we run them explicitly under python, not as executables.
Execute paste-kdcproxy.py via sys.executable in t_proxy.py so that it
doesn't need a #!/usr/bin/python header.

ticket: 8709 (new)

7 years agoFix some omissions in make clean 808/head
Greg Hudson [Wed, 4 Jul 2018 14:58:35 +0000 (14:58 +0000)] 
Fix some omissions in make clean

7 years agoDisable canonicalization in ccselect tests 807/head
Greg Hudson [Wed, 4 Jul 2018 16:11:45 +0000 (16:11 +0000)] 
Disable canonicalization in ccselect tests

DNS canonicalization can interfere with the fallback tests by changing
"localhost" to have multiple components, or (less likely) changing the
parent domain of foo.krbtest.com or foo.krbtest2.com.

7 years agoImprove ulog memory hygiene 803/head
Greg Hudson [Thu, 28 Jun 2018 04:15:11 +0000 (00:15 -0400)] 
Improve ulog memory hygiene

Add a helper create_log_context() to initialize a krb5_context's
kdblog_context field, setting ulogfd to -1.  Use it in ulog_set_role()
and ulog_map().  In ulog_fini(), release ulogfd if it is not -1.

In ulog_map(), add a cleanup label and use it to finalize the log
context on failure, so that we don't (trivially) leak the mapped ulog.
To reduce the number of "retval = errno;" statements required for this
change, make extend_file_to() return a krb5_error_code.

The ulog leak on error was reported by Bean Zhang.

ticket: 8707

7 years agoFix OTP secret file leak and whitespace removal 802/head
Greg Hudson [Tue, 26 Jun 2018 16:47:10 +0000 (12:47 -0400)] 
Fix OTP secret file leak and whitespace removal

In read_secret_file() in the OTP kdcpreauth module, add a cleanup
label and free filename on exit.  Also fix the whitespace stripping
code to correctly find the end offset, and use size_t rather than int
offsets.  The leak was reported by Bean Zhang.

ticket: 8704
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoFix memory handling in main in user_user/client.c 800/head
Robbie Harwood [Wed, 20 Jun 2018 15:18:46 +0000 (11:18 -0400)] 
Fix memory handling in main in user_user/client.c

Static analyzers (here, clang) prefer explicit exit() calls rather
than return statements from main() when resources are not to be
released.

Also, eliminate dead call to krb5_recvauth() and close the
communication socket.

7 years agoDon't leak work queue items in gss-server
Robbie Harwood [Tue, 19 Jun 2018 15:32:44 +0000 (11:32 -0400)] 
Don't leak work queue items in gss-server

On accept() failure in gss-server.c, we would leak the freshly
allocated work item.

7 years agoFix garbage return in extract_cammacs()
Robbie Harwood [Mon, 18 Jun 2018 21:49:52 +0000 (17:49 -0400)] 
Fix garbage return in extract_cammacs()

If no cammacs were present, we would never initialize ret before
returning it.  (extract_cammcs() is currently never called with an
empty or null list, so this does not manifest as a bug.)

[ghudson@mit.edu: amended commit message]

7 years agoFix double free in kdc hammer
Robbie Harwood [Tue, 3 Oct 2017 19:01:55 +0000 (15:01 -0400)] 
Fix double free in kdc hammer

If kdc5_hammer.c:krb5_string_to_key() fails, we didn't NULL out key
before returning it, leading to potential double-free.

7 years agoCorrectly handle fallback in KDC OTP callback 801/head
Robbie Harwood [Tue, 3 Oct 2017 18:28:47 +0000 (14:28 -0400)] 
Correctly handle fallback in KDC OTP callback

In otp_state.c:callback(), avoid invoking the failure callback when we
fall back to the next token.  Since request_send() consumes the
request, don't try to free it.

[ghudson@mit.edu: added test case; edited commit message]

ticket: 8708
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

7 years agoClean up Windows build CPU detection 788/head
Greg Hudson [Sat, 19 May 2018 02:04:25 +0000 (22:04 -0400)] 
Clean up Windows build CPU detection

In the main build, set a variable BITS based on the detected CPU type,
and use it in library name expansions rather than repeatedly checking
for the same three 64-bit architectures.  Also remove an unused
variable WLIB, formerly used to name the winsock library.

In the installer build, detect the CPU type in the makefile and pass
it to candle with the -arch option.  This sets $(sys.BUILDARCH) in wix
scripts and also sets the default value of Win64 in components so we
don't have to set it for each one.

Update the build instructions and appveyor.yml to reflect that the
builder no longer needs to set CPU.

ticket: 8662

7 years agoFix minor leak in gssrpc UDP cache code 799/head
Greg Hudson [Tue, 19 Jun 2018 17:15:15 +0000 (13:15 -0400)] 
Fix minor leak in gssrpc UDP cache code

In svc_udp.c:cache_set(), if victim is allocated successfully but
allocation for newbuf fails, free victim before returning.  Reported
by Bean Zhang.

ticket: 8703

7 years agoFix minor leak in kdb5_util purge_mkeys 798/head
Greg Hudson [Tue, 19 Jun 2018 17:03:05 +0000 (13:03 -0400)] 
Fix minor leak in kdb5_util purge_mkeys

In kdb5_purge_mkeys(), if krb5_dbe_update_mkey_aux() fails, use the
cleanup label to free any allocated memory instead of returning
immediately.  Reported by Bean Zhang.

ticket: 8702

7 years agoAdd documentation on dictionary attacks 792/head
Greg Hudson [Thu, 14 Jun 2018 21:51:43 +0000 (17:51 -0400)] 
Add documentation on dictionary attacks

ticket: 8694 (new)

7 years agoFix minor leak in krb5_gss_inquire_cred() 796/head
Greg Hudson [Fri, 15 Jun 2018 15:40:13 +0000 (11:40 -0400)] 
Fix minor leak in krb5_gss_inquire_cred()

If mechs is created but one of the generic_gss_add_oid_set_member()
calls fails, it leaks.  Initialize mechs and free it in the fail
label.  Also null mechs when we transfer ownership of it to the
caller, in case we later unify the success and failure exit paths.
Reported by Bean Zhang.

ticket: 8697

7 years agoFix minor leak in localauth RULE handling 795/head
Greg Hudson [Fri, 15 Jun 2018 15:52:22 +0000 (11:52 -0400)] 
Fix minor leak in localauth RULE handling

In aname_replacer(), initialize current, null it when transferring
ownership to the caller, and free it on cleanup.  Otherwise it leaks
on failure.  Reported by Bean Zhang.

ticket: 8698

7 years agoFix minor leak in k5_os_hostaddr() 794/head
Greg Hudson [Fri, 15 Jun 2018 15:31:04 +0000 (11:31 -0400)] 
Fix minor leak in k5_os_hostaddr()

In k5_os_hostaddr(), if allocation of the result array fails, use the
cleanup handler so that the getaddrinfo() result is freed.  Also
initialize the pointers which are freed in the cleanup handler for
safety.  Reported by Bean Zhang.

ticket: 8699

7 years agoFix minor leaks in principal conversions 793/head
Greg Hudson [Fri, 15 Jun 2018 15:20:34 +0000 (11:20 -0400)] 
Fix minor leaks in principal conversions

In krb5_524_conv_principal(), if the realm we read from the profile is
too long for the result buffer, free the profile value before
returning.

In krb5_425_conv_principal(), if krb5_get_realm_domain() fails, still
free any leftover allocated data using a cleanup label.  The only one
that could be left over is dummy_value which we could address easily
enough within the loop, but we shouldn't sidestep the cleanup code.

Both bugs were reported by Bean Zhang.

ticket: 8695

7 years agoEliminate use of the 'register' keyword 797/head
Thomas Sondergaard [Sat, 16 Jun 2018 16:14:50 +0000 (18:14 +0200)] 
Eliminate use of the 'register' keyword

'register' is a reserved and unused keyword in C++17 so having it
present in the public headers presents a a compatibility issue. Also
in C the 'register' keyword is mostly obsolete, so remove all uses of
it.

[ghudson@mit.edu: adjusted style of some of the affected lines]

7 years agoFix minor leak in krb5_get_fallback_host_realm() 791/head
Greg Hudson [Thu, 14 Jun 2018 14:52:33 +0000 (10:52 -0400)] 
Fix minor leak in krb5_get_fallback_host_realm()

In domain_fallback_realm(), if profile_get_integer() fails, uhost is
leaked.  Fix this bug by using the cleanup handler instead of
returning immediately.  Reported by Bean Zhang.

ticket: 8693

7 years agoAdd flag to disable encrypted timestamp on client 789/head
Greg Hudson [Mon, 11 Jun 2018 17:53:27 +0000 (13:53 -0400)] 
Add flag to disable encrypted timestamp on client

ticket: 8655

7 years agoMake docs build python3-compatible 790/head
Robbie Harwood [Wed, 13 Jun 2018 19:07:48 +0000 (15:07 -0400)] 
Make docs build python3-compatible

python3 removed execfile(), which we use for loading version data and
paths information in docs.  Call exec() directly instead.

ticket: 8692 (new)

7 years agoRemove wshelper library 783/head
Greg Hudson [Sun, 3 Jun 2018 21:47:36 +0000 (17:47 -0400)] 
Remove wshelper library

ticket: 8687

7 years agoStop using wshelper for SRV/TXT lookups
Greg Hudson [Sun, 3 Jun 2018 20:41:18 +0000 (16:41 -0400)] 
Stop using wshelper for SRV/TXT lookups

Add Windows-specific versions of k5_try_realm_txt_rr(),
k5_make_uri_query(), and krb5int_make_srv_query_realm(), bypassing
wshelper and using DnsQuery_UTF8() directly.  Windows does not
currently know how to decode URI records and has no interface to allow
the caller to do so, so disable URI lookups on Windows for now.

Add a comment that dnsglue.h is not used on Windows (since DnsQuery
parses out and decodes SRV and TXT records for us), and remove the
header conditionals from it.

ticket: 8687

7 years agoReorganize internal DNS interfaces
Greg Hudson [Sat, 2 Jun 2018 22:25:43 +0000 (18:25 -0400)] 
Reorganize internal DNS interfaces

Move SRV lookup function declarations out of dnsglue.h into
os-proto.h, where the TXT lookup function is declared.  Only include
dnsglue.h within files which need to parse DNS records.

To avoid needing MAXDNAME, use dynamic allocation for the results of
DNS lookups (including hostname canonicalization) where we currently
use fixed buffers.  Remove clean_hostname from the accessor (nothing
uses it) and make it a static function within hostrealm.c.

7 years agoRequire Visual Studio 2013 in Windows README 780/head
Greg Hudson [Fri, 18 May 2018 05:05:46 +0000 (01:05 -0400)] 
Require Visual Studio 2013 in Windows README

The recently added SPAKE edwards25519 code, adapted from BoringSSL,
makes frequent use of mixed declarations and code, which is supported
by VS2013 but not VS2012 and earlier.  Require VS2013 as the minimum
version in the Windows README.  Add suport for VS2013 and VS2015 to
the installer.

ticket: 8662

7 years agoBuild and install SPAKE module for Windows
Greg Hudson [Wed, 16 May 2018 17:17:34 +0000 (10:17 -0700)] 
Build and install SPAKE module for Windows

For now only the edwards25519 group is supported, since we are not
adding an OpenSSL dependency.

ticket: 8657

7 years agoMake plugin auto-registration work on Windows
Greg Hudson [Wed, 16 May 2018 18:02:20 +0000 (11:02 -0700)] 
Make plugin auto-registration work on Windows

Make plugin_base_dir subject to parameter expansion, and set its
default to %{LIBDIR}\plugins on Windows (%{LIBDIR} expands to the
directory where the krb5 DLL lives).  For auto-registered modules,
assume that we will build 32-bit and 64-bit DLLs and name them
"modname32.dll" and "modname64.dll".  In k5_plugin_register_dyn(), use
k5_path_join() instead of assuming the path separator is "/".

ticket: 8685 (new)

7 years agoFix option parsing on Windows 778/head
Greg Hudson [Wed, 16 May 2018 04:52:08 +0000 (21:52 -0700)] 
Fix option parsing on Windows

Commit 8f9ade8ec50cde1176411085294f85ecfb2820a4 (ticket 8391) moved
the built-in getopt() and getopt_long() implementations from a static
library in util/windows to util/support, where (on Windows) it is
built into k5sprt32.dll or k5sprt64.dll.  The getopt() interface uses
global variables opterr, optind, optopt, and optarg, each renamed via
macro to have a k5_ prefix when we use the built-in implementation.
Data objects exported from DLLs need special handling in Windows; they
must be marked as DATA in the DLL .def file, and they must be declared
with "__declspec(dllimport)" in calling code.  Without this handling,
optind begins with a garbage value and getopt_long() returns -1
immediately, so client programs always behave as if they have no
arguments.

Stop unnecessarily declaring optind and optarg in client programs.
Declare the getopt() global variables with __declspec(dllimport) on
Windows, except when compiling getopt.c itself.  When creating
libkrb5support.exports on Windows (this file is later used by
lib/Makefile.in to create k5sprt32.def), add a DATA tag to the data
objects.

ticket: 8684 (new)
tags: pullup
target_version: 1.16-next
target_version: 1.15-next