An RFC 6113 KrbFastReq contains a padata sequence and a KDC-REQ-BODY,
neither of which contain the msg-type field found in a KDC-REQ. So
when we decode the FAST request, the resulting krb5_kdc_req structure
has a msg_type of 0. Copy msg_type from the outer body, since we make
use of it in further KDC processing.
Tom Yu [Wed, 10 Apr 2013 03:47:54 +0000 (23:47 -0400)]
Allow config of dh_min_bits < 2048
Allow configuration to override the default dh_min_bits of 2048 to
1024. Disallow configuration of dh_min_bits < 1024, but continue to
default to 2048.
Tom Yu [Fri, 29 Mar 2013 02:57:55 +0000 (22:57 -0400)]
Simplify pkinit_check_dh_params
Change pkinit_check_dh_params() to take two DH* parameters, and only
compare p and g, because q is fully determined by them and might be
missing.
Also refactor some parameter checks into check_dh_wellknown() that
were previously done separately in the pkinit_process_td_dh_params()
and server_check_dh().
Wait ten seconds for a TCP connection to succeed or fail before moving
on. During this wait time, other TCP connections will be serviced if
we already initiated them, but no new TCP connections will be created
and no UDP packets will be retransmitted.
[ghudson@mit.edu: minor adjustments; commit message]
Replace the end_time field of struct select_state with an endtime
argument to cm_select_or_poll, expressed in milliseconds since the
epoch. Add a helper function to get the current time in that format.
Use a millisecond interval argument to service_fds for consistency.
Since net-server.c now uses libverto, only sendto_kdc.c consumes cm.c.
Move stuff out of cm.c and cm.h into sendto_kdc.c and get rid of them.
Change the sendto_kdc callback (used by chpw.c) to receive the socket
descriptor instead of the entire conn_state structure, and move the
declarations into os-proto.h. struct remote_address also needs to be
in os-proto.h so that trace.c and t_trace.c can use it. k5_curtime
isn't needed since k5-platform.h now guarantees the presence of
gettimeofday().
In struct conn_state, collect together the fields for the remote
address and put them in a substructure. Pass this substructure to
trace logging macros instead of the entire conn_state structure, so
that trace.c doesn't have to know about the whole structure.
Since krb5 1.3, krb5_get_host_realm (and therefore
krb5_sname_to_principal) has refused hostnames which appear to be
numeric addresses--with the exception of 1.6, which was ignoring
errors from clean_hostname. In specialized environments, it may be
desirable to use IP addresses in service principal names, and there's
no compelling reason for us to get in the way of that.
Move the numeric address check out of k5_clean_hostname into a new
helper function, and simply skip the domain-based mechanisms if it
returns true. Factor out the [domain_realm] search into a second new
helper function to make it easier to skip.
After k5memdup0 was slightly modified in 31124ffb81e8c0935403a9fdc169dead5ecaa777, some older versions of gcc
complain about outpos being possibly used before it is initialized.
This can't actually happen, but we can silence the error and also
simplify how outpos is initialized.
By a strict reading of the C standard, memcpy and memcmp have
undefined behavior if their pointer arguments aren't valid object
pointers, even if the length argument is 0. Compilers are becoming
more aggressive about breaking code with undefined behavior, so we
should try to avoid it when possible.
In a krb5_data object, we frequently use NULL as the data value when
the length is 0. Accordingly, we should avoid copying from or
comparing the data field of a length-0 krb5_data object. Add checks
to our wrapper functions (like data_eq and k5_memdup) and to code
which works with possibly-empty krb5_data objects. In a few places,
use wrapper functions to simplify the code rather than adding checks.
Modify t_credstore.c to be more flexible and adjust t_gssapi.py
accordingly. Add a test to t_client_keytab.py which acquire creds
using a programmatically specified client keytab.
Simo Sorce [Thu, 28 Mar 2013 16:53:01 +0000 (12:53 -0400)]
Add support for client keytab from cred store
The new credential store extensions added support for specifying a
specific ccache name and also a specific keytab to be used for accepting
security contexts, but did not add a way to specify a client keytab
to be used in conjunction with the Keytab initiation support added also
in 1.11
This patch introduces a new URN named client_keytab through which a
specific client_keytab can be set when calling gss_acquire_cred_from()
and Keytab Initiation will use that keytab to initialize credentials.
Greg Hudson [Fri, 29 Mar 2013 06:22:12 +0000 (02:22 -0400)]
Fix errno hygiene in kadmind write_pid_file
fclose() might overwrite the errno value from fprintf, causing us to
return success when we shouldn't. Record the errno value at the time
of the fprintf failure.
Greg Hudson [Fri, 29 Mar 2013 06:13:04 +0000 (02:13 -0400)]
Simplify krb5_ldap_readpassword
There's no need to check whether the file exists and is readable
before opening it, and setting an extended error message which is just
strerror_r() of the errno value isn't useful.
Greg Hudson [Thu, 28 Mar 2013 20:43:30 +0000 (16:43 -0400)]
Using k5-int.h data helpers for some functions
Use empty_data(), alloc_data(), and make_data() in some appropriate
places. This has the side effect of initializing the krb5_data magic
field, which can placate debugging tools.
Greg Hudson [Mon, 25 Mar 2013 21:38:41 +0000 (17:38 -0400)]
Fix a trivial file leak writing kadmind pid file
If we fail to write the pid to the pid file, we should still close the
file before returning from write_pid_file(). The consequences of this
bug are trivial because kadmin is just going to exit regardless.
Reported by Will Fiveash <will.fiveash@oracle.com>.
Greg Hudson [Mon, 25 Mar 2013 16:42:49 +0000 (12:42 -0400)]
Export verto_set_flags from libverto
When the bundled libverto was updated from 0.2.2 to 0.2.5,
verto_set_flags should have been added to libverto.exports along with
the other new functions.
Simo Sorce [Sat, 16 Mar 2013 19:23:03 +0000 (15:23 -0400)]
Fix import_sec_context with interposers
The code was correctly selecting the mechanism to execute, but it was
improperly setting the mechanism type of the internal context when the
selected mechanism was that of an interposer and vice versa.
When an interposer is involved the internal context is that of the
interposer, so the mechanism type of the context needs to be the
interposer oid. Conversely, when an interposer re-enters gssapi and
presents a token with a special oid, the mechanism called is the real
mechanism, and the context returned is a real mechanism context. In
this case the mechanism type of the context needs to be that of the
real mechanism.
Greg Hudson [Sun, 24 Mar 2013 05:28:13 +0000 (01:28 -0400)]
Move a bunch of stuff out of k5-int.h
Move internal declarations from k5-int.h to more localized headers
(like int-proto.h) where appropriate. Rename many symbols whose
prototypes were moved to use the k5_ prefix instead of krb5int_.
Remove some unused declarations or move them to the single source file
they were needed in. Remove krb5_creds_compare since it isn't used
any more.
Ben Kaduk [Thu, 21 Mar 2013 15:49:49 +0000 (11:49 -0400)]
Rebuild NOTICE for 2013
Also exclude copyright.rst from the notice.txt build, as maintainer-mode
builds error out due to the "document isn't included in any toctree"
warning otherwise produced.
Ben Kaduk [Tue, 12 Mar 2013 02:57:06 +0000 (22:57 -0400)]
Update shlib.conf for FreeBSD
FreeBSD has not emitted a.out binaries by default for a very long
time; elf is the standard.
Take sparc64 conditional for PICFLAGS from downstream.
Enable "new" dtags (supported since FreeBSD 5.0) -- this
prevents rpath entries in libraries from taking precedence over
LD_LIBRARY_PATH, useful for testing.
Greg Hudson [Fri, 15 Mar 2013 17:03:26 +0000 (13:03 -0400)]
Reset ulog header if iprop load fails
If an iprop slave tries to load a dump from the master and it fails,
reset the ulog header so we take another full dump, instead of
reporting that the slave is current when it isn't. Reported by
Richard Basch <basch@alum.mit.edu>.
Nalin Dahyabhai [Fri, 15 Mar 2013 16:05:56 +0000 (12:05 -0400)]
Add PEM password prompter callback in PKINIT
Supply a callack to PEM_read_bio_PrivateKey() using the prompter to
request a password for encrypted PEM data. Otherwise OpenSSL will use
the controlling terminal.
[ghudson@mit.edu: minor style cleanup, commit message]
Greg Hudson [Fri, 15 Mar 2013 06:16:39 +0000 (02:16 -0400)]
Fix argument type in kg_unseal_v1
The caller of kg_unseal_v1 passes a gss_qop_t * for the qop_state
parameter, so make it use that type instead of an int *. Noted by
David Benjamin <davidben@mit.edu>.
Greg Hudson [Fri, 15 Mar 2013 06:13:22 +0000 (02:13 -0400)]
Fix kadmin_getpol format string
Commit 0780e46fc13dbafa177525164997cd204cc50b51 matched a %ld format
string with the integer 0, which is an int rather than a long. Just
put 0 in the format string instead. Noted by David Benjamin
<davidben@mit.edu>.
Greg Hudson [Fri, 15 Mar 2013 05:57:40 +0000 (01:57 -0400)]
Fix use-before-init in two test programs
If krb5_init_context fails, use a null context for getting the error
message, not a context we haven't yet initialized. Observed by David
Benjamin <davidben@mit.edu> using clang.
Greg Hudson [Mon, 11 Mar 2013 20:09:06 +0000 (16:09 -0400)]
Initialize status in krb5_ldap_parse_db_params
If db_args is non-null but empty, status could be returned without
being initialized; gcc with optimization correctly warns about this,
causing a build failure. (This bug was introduced by 0b1dc2f93da4c860dd27f1ac997617b712dff383 which was pushed after the
1.11 release branch, so it isn't in any release.)
Alex Dehnert [Sat, 9 Mar 2013 04:48:33 +0000 (23:48 -0500)]
Add support for k5srvutil -e keysalts
k5srvutil is a little more convenient to use for rolling keys than
kadmin is. When migrating off 1DES, though, it may be desirable to
explicitly specify the desired keysalts. This adds an option, -e, to
k5srvutil to specify desired keysalts.
[ghudson@mit.edu: style fix; make whitespace in keysalt list work]
Greg Hudson [Wed, 27 Feb 2013 20:00:37 +0000 (15:00 -0500)]
Add tests for localauth interface
Create a test module, program, and script to exercise the
krb5_aname_to_localname and krb5_k5userok functions as well as the
localauth pluggable interface.
Greg Hudson [Wed, 13 Feb 2013 20:29:48 +0000 (15:29 -0500)]
Add localauth pluggable interface
Add a new pluggable interface for local authorization, and replace the
existing krb5_aname_to_localname and krb5_kuserok implementations with
implementations based on the pluggable interface.
Ben Kaduk [Mon, 25 Feb 2013 18:12:33 +0000 (13:12 -0500)]
Fix windows build
Catch up to the split of preauth_plugin.h into client and
kdc specific portions. While here, use copy's /y flag to suppress
an override-confirmation prompt (though we do not list any dependencies
for this target at the moment, so no such prompt will be generated).
Greg Hudson [Thu, 21 Feb 2013 17:36:07 +0000 (12:36 -0500)]
Fix fd leak in DIR ccache cursor function
If dcc_ptcursor_next reached the end of a directory, it called free()
on the directory handle instead of closedir(), causing the directory
fd to be leaked. Call closedir() instead.
Greg Hudson [Wed, 20 Feb 2013 17:06:12 +0000 (12:06 -0500)]
Fix memory leak closing DIR ccaches
A ccache type's close function is supposed to free the cache container
as well as the type-specific data. dcc_close was not doing so,
causing a small memory leak each time a ccache is created or
destroyed.
Greg Hudson [Sun, 17 Feb 2013 17:44:45 +0000 (12:44 -0500)]
Allow multi-hop SAM-2 exchanges
Prior to 1.11, it was possible to do SAM-2 preauth exchanges with
multiple hops by sending repeated preauth-required errors with
different challenges (which is not the way multi-hop exchanges are
described in RFC 6113, but it can still work). This stopped working
when SAM-2 was converted to a built-in module. Make it work again.
Xi Wang [Thu, 14 Feb 2013 23:17:40 +0000 (18:17 -0500)]
PKINIT null pointer deref [CVE-2013-1415]
Don't dereference a null pointer when cleaning up.
The KDC plugin for PKINIT can dereference a null pointer when a
malformed packet causes processing to terminate early, leading to
a crash of the KDC process. An attacker would need to have a valid
PKINIT certificate or have observed a successful PKINIT authentication,
or an unauthenticated attacker could execute the attack if anonymous
PKINIT is enabled.
Jonathan Reams [Fri, 15 Feb 2013 07:11:57 +0000 (02:11 -0500)]
Convert success in krb5_chpw_result_code_string
Result code 0 used to be converted properly by krb5_set_password,
though not krb5_change_password; this changed in 1.10 when
krb5int_setpw_result_code_string was folded into
krb5_chpw_result_code_string. Restore the old behavior, and make it
apply to krb5_change_password as well, by making
krb5_chpw_result_code_string convert result code 0.
Greg Hudson [Tue, 30 Oct 2012 21:17:45 +0000 (17:17 -0400)]
Make internal JSON functions return error codes
Return error codes (0, ENOMEM, or EINVAL) from JSON support functions
instead of returning results directly. This makes error handling
simpler for functions which assemble JSON objects and then return a
krb5_error_code values. Adjust all callers. Use shims in
export_cred.c to minimize changes there; it will be redesigned
internally in a subsequent commit.
Greg Hudson [Tue, 12 Feb 2013 02:13:15 +0000 (21:13 -0500)]
Fix RFC 5587 const pointer typedefs
gss_const_ctx_id_t, gss_const_cred_id_t, and gss_const_name_t are
supposed to be const pointers to the appropriate structures, not the
structures themselves. These are not used by any prototypes yet, and
no application would have any reason to use them as they are, so it
should be safe to change them within the public header.
Greg Hudson [Sat, 9 Feb 2013 05:43:35 +0000 (00:43 -0500)]
Add and use k5memdup, k5memdup0 helpers
Add k5-int.h static functions to duplicate byte ranges, optionally
with a trailing zero byte, and set an error code like k5alloc does.
Use them where they would shorten existing code.
Greg Hudson [Fri, 8 Feb 2013 06:59:19 +0000 (01:59 -0500)]
Simplify TGS request construction
Move krb5int_make_tgs_request from gc_via_tkt.c into send_tgs.c,
combine it with krb5int_make_tgs_request_ext (which nothing else
called), and rename the combined function to k5_make_tgs_req. Also
use a typedef for the pacb callback.
Greg Hudson [Sun, 3 Feb 2013 17:25:10 +0000 (12:25 -0500)]
Add kprop Python tests
Create a K5Realm.kprop_port method so test scripts can invoke kprop
usefully, and create a simple Python test script exercising the same
kprop functionality as the dejagnu suite's kprop.exp.
Greg Hudson [Sun, 3 Feb 2013 18:21:34 +0000 (13:21 -0500)]
Make kprop/kpropd work with RC4 session key
In krb5_auth_con_initivector and mk_priv/rd_priv, stop assuming that
the enctype's block size is the size of the cipher state. Instead,
make and discard a cipher state to get the size.
Greg Hudson [Wed, 6 Feb 2013 19:49:09 +0000 (14:49 -0500)]
Refactor dump.c
When dumping, use a common iterator function to unpack the dump_args
structure, unparse and filter the principal name, and convert master
keys. Add helper functions to dump and load the "octets or -1" format
used for optional binary fields in the current dump format.
Greg Hudson [Tue, 5 Feb 2013 05:31:23 +0000 (00:31 -0500)]
Reorder dump.c
Without changing anything (except to make a few internal functions
static), reorder dump.c to bottom-up order so that forward function
declarations aren't needed.
Greg Hudson [Mon, 4 Feb 2013 23:21:45 +0000 (18:21 -0500)]
Add more tests for dump and load
Move the existing dump/load tests from t_general.py to a new script
t_dump.py. Add additional tests using pre-created dumpfiles, to
exercise the -r18, -r13, -b7, and -ov formats.
Greg Hudson [Mon, 4 Feb 2013 19:01:40 +0000 (14:01 -0500)]
Simplify kdb5_util create using a null password
kadm5_create_principal now uses a random key if passed a null
password, so we don't need a multi-step process to create admin
principals when creating a database any more.