asn/mit-krb5.git
10 years agoSimplify iprop update locking and avoid deadlock
Greg Hudson [Thu, 13 Feb 2014 00:13:43 +0000 (19:13 -0500)]
Simplify iprop update locking and avoid deadlock

Since we are no longer treating the update log like a journal (#7552),
we don't need two-stage update logging.  In kdb5.c, add an update log
entry after each DB change in one step, without getting an explicit
lock.  In kdb_log.c, combine ulog_add_update with ulog_finish_update,
and make ulog_add_update lock the ulog internally.

This change avoids deadlock by removing the only cases where the ulog
is locked before the DB.

ticket: 7861

10 years agoUse system dictionary for db2 tests again
Greg Hudson [Tue, 18 Feb 2014 06:14:01 +0000 (01:14 -0500)]
Use system dictionary for db2 tests again

The built-in word list is not long enough for all of the libdb2 tests
to run properly.  Revert d21a86e47a7cda29225013e08d060095b94b2ee7 and
go back to using the system dictionary if we find one.  However, omit
any lines from the chosen word list which contain non-alphabetical
characters.

ticket: 7860

10 years agoUse TAILQ macros instead of CIRCLEQ in libdb2
Greg Hudson [Mon, 17 Feb 2014 05:18:41 +0000 (00:18 -0500)]
Use TAILQ macros instead of CIRCLEQ in libdb2

The optimizer in gcc 4.8.1 (but not the current gcc head revision)
breaks the queue.h CIRCLEQ macros, apparently due to an overzealous
strict aliasing deduction.  Use TAILQ macros in the libdb2 mpool code
instead.

ticket: 7860

10 years agoDocument 1.12 changes in MIT Kerberos Features doc
Zhanna Tsitkov [Fri, 14 Feb 2014 21:17:47 +0000 (16:17 -0500)]
Document 1.12 changes in MIT Kerberos Features doc

ticket: 7857

10 years agoMake KDC "status" statements more homogeneous
Zhanna Tsitkov [Mon, 23 Dec 2013 14:23:54 +0000 (09:23 -0500)]
Make KDC "status" statements more homogeneous

Generally we want KDC status strings to be concise, informative and follow
some common rules:

- All letters in the status string should be capitalized;
- the words in the status phrase are separated by underscore;
- abbreviations should be avoided.  Some acceptable "standard" acronyms
  are AS_REQ, TGS_REP etc.
- since in almost all cases KDC status is set on error, no need
  to state this fact as part of the status string;
- KDC status string should be an imperative phrase.

For example, "DECRYPT_SERVER_KEY".

This commit is to modify some KDC status messages to follow this format.

Even though KDC status messages are not standardized, it is possible that some
administrators use them in the Kerberos log file processing. Hence, the vast
majority of them are left unchanged pending further investigation (mostly,
feedback from the administrators).

10 years agoSupport referrals from Windows Server 2003
Nate Rosenblum [Mon, 23 Dec 2013 21:21:44 +0000 (13:21 -0800)]
Support referrals from Windows Server 2003

Although RFC 6806 Section 7 requires servers to indicate a client
referral in a WRONG_REALM message, Microsoft Windows Server 2003
returns this information in a message with error code
PRINCIPAL_UNKNOWN.  Failure to follow the referral in these messages
prevents referral chasing in Windows Server 2003 forests.  Detect
referral messages of this type by checking for a non-empty
client.realm field in the response, and activate the referral logic in
these cases.

[tlyu@mit.edu: style, comments, and commit message]

ticket: 7856 (new)
target_version: 1.12.2
tags: pullup

10 years agoUpdate doc build instructions
Tom Yu [Fri, 14 Feb 2014 20:59:51 +0000 (15:59 -0500)]
Update doc build instructions

Documentation build instructions in doc/README were out of date.
Update them.

ticket: 7864 (new)
tags: pullup
target_version: 1.12.2

10 years agoGenerate dependencies for t_stringattr
Greg Hudson [Wed, 12 Feb 2014 04:19:36 +0000 (23:19 -0500)]
Generate dependencies for t_stringattr

When t_stringattr.c was introduced, it wasn't added to EXTRADEPSRCS,
so no dependencies were created for it.  Fix that now.

10 years agoDon't use system dictionary files for DB2 tests
Greg Hudson [Wed, 12 Feb 2014 03:16:56 +0000 (22:16 -0500)]
Don't use system dictionary files for DB2 tests

The system dictionary may contain entries with punctuation, which can
confuse the shell.  It's more predictable to always use the word list
from the source tree.

ticket: 7860
status: open

10 years agoFix SAM-2 preauth when password argument is used
Greg Hudson [Wed, 12 Feb 2014 01:00:51 +0000 (20:00 -0500)]
Fix SAM-2 preauth when password argument is used

sam2_process accesses gak_data to get the password, so that it can do
string-to-key with the etype in the SAM-2 challenge.  When #7642
changed gic_pwd.c to use struct gak_password instead of krb5_data,
sam2_process wasn't altered to match.  We don't see a problem when the
password is read through the prompter (as with kinit), because the
password winds up in the storage field at the beginning of the
gak_password structure.  But when a password is supplied as a
parameter (as with ksu), the storage field is empty and we get the
wrong answer from sam2_process.

ticket: 7862
target_version: 1.12.2
tags: pullup

10 years agoCorrectly get default realm in kdb5.c
Greg Hudson [Mon, 10 Feb 2014 20:26:34 +0000 (15:26 -0500)]
Correctly get default realm in kdb5.c

Call krb5_get_default_realm instead of directly accessing
context->default_realm, to remove the requirement that
krb5_get_default_realm or krb5_set_default_realm be used before
krb5_db_open.

10 years agoMove OTP sockets to KDC_RUN_DIR
Nathaniel McCallum [Wed, 5 Feb 2014 15:59:46 +0000 (10:59 -0500)]
Move OTP sockets to KDC_RUN_DIR

Some system configurations expect Unix-domain sockets to live under
/run or /var/run, and not other parts of /var where persistent
application state lives.  Define a new directory KDC_RUN_DIR using
$runstatedir (new in autoconf 2.70, so fall back to $localstatedir/run
if it's not set) and use that for the default socket path.

[ghudson@mit.edu: commit message, otp.rst formatting fix]

ticket: 7859 (new)

10 years agoTest SPNEGO acceptor response to MS krb5 mech OID
Greg Hudson [Tue, 4 Feb 2014 01:59:54 +0000 (20:59 -0500)]
Test SPNEGO acceptor response to MS krb5 mech OID

In t_spnego.c, add code to make a SPNEGO request with the erroneous
Microsoft OID value and examine the response to make sure that it uses
the same OID value as the request did.  The token and tmp variables
were unused, so rename them to itok and atok for the purpose of the
new test code.

ticket: 7858
target_version: 1.12.2
tags: pullup

10 years agoProperly reflect MS krb5 mech in SPNEGO acceptor
Greg Hudson [Tue, 4 Feb 2014 02:11:34 +0000 (21:11 -0500)]
Properly reflect MS krb5 mech in SPNEGO acceptor

r25590 changed negotiate_mech() to return an alias into the acceptor's
mech set, with the unfortunate side effect of transforming the
erroneous Microsoft krb5 mech OID into the correct krb5 mech OID,
meaning that we answer with a different OID than the requested one.
Return an alias into the initiator's mech set instead, and store that
in mech_set field the SPNEGO context.  The acceptor code only uses
mech_set to hold the allocated storage pointed into by internal_mech,
so this change is safe.

ticket: 7858
target_version: 1.12.2
tags: pullup

10 years agoDon't get KDB lock in ulog_get_entries
Greg Hudson [Thu, 30 Jan 2014 17:37:46 +0000 (12:37 -0500)]
Don't get KDB lock in ulog_get_entries

ulog_get_entries does not access the KDB, only the ulog, so it does
not need a KDB lock; its read lock on the ulog is sufficient to
prevent logged updates from happening while it is running.  There is
no reason to serialize against unlogged KDB updates such as those
performed by the KDC, as those do not affect the ulog.

10 years agoIn kdb5_util load, init ulog closer to promote
Greg Hudson [Thu, 23 Jan 2014 15:51:21 +0000 (10:51 -0500)]
In kdb5_util load, init ulog closer to promote

Always map the ulog with FKCOMMAND, not FKLOAD which reinitializes the
ulog.  Don't reinitialize the ulog until just before calling
krb5_db_promote().  Get rid of FKLOAD since it isn't needed any more;
we can just call ulog_init_header() manually.

10 years agoClean up ovsec_kadmd.c
Greg Hudson [Sun, 26 Jan 2014 21:42:50 +0000 (16:42 -0500)]
Clean up ovsec_kadmd.c

Fix code formatting issues.  Use static scope when possible, and put
all helper functions before main so that forward declarations aren't
needed.  Use GSS_KRB5_NT_PRINCIPAL_NAME instead of constructing it
with gss_str_to_oid, and get rid of display_status as that was the
only use.  Replace large verbose function comments with concise ones.
Factor out main loop setup and KDB keytab setup into helper functions.
Create a helper function fail_to_start for logging and exiting on
initialization failures, and use it instead of the large cleanup
blocks in main.

Some initialization error messages have changed; no other functional
changes.

10 years agoModernize iprop code
Greg Hudson [Thu, 23 Jan 2014 23:15:24 +0000 (18:15 -0500)]
Modernize iprop code

* Don't use "extern" for kdb_log.h prototypes.
* Avoid passing structures by value.
* Avoid the need to cast the result of the INDEX macro, and use char *
  instead of unsigned long for pointer arithmetic.
* Reorganize kdb_log.c so static helpers are at the top and don't use
  the "ulog_" prefix.
* Get rid of ulog_finish_update_slave since it's more concise to
  open-code it in ulog_replay.
* Get rid of ulog_delete_update.  In krb5_db_delete_principal, just
  call ulog_add_update with kdb_deleted set in upd.
* Modernize coding style of kproplog.c.  Use k5memdup0 instead of
  snprintf in print_str to convert a byte range to a C string.
  Remove an unnecesary textdomain call; libkrb5 takes care of calling
  bindtextdomain in the library initializer.
* Modernize coding style of kpropd.c and kprop.c.

No functional changes.

10 years agoFix kpropd -x
Greg Hudson [Sun, 26 Jan 2014 23:38:11 +0000 (18:38 -0500)]
Fix kpropd -x

A missing break in the switch statement caused kpropd -x to error out
with a usage message.

ticket: 7854 (new)
target_version: 1.12.2
tags: pullup

10 years agoRemove kdb5_util load iprop safety net
Greg Hudson [Fri, 24 Jan 2014 04:49:34 +0000 (23:49 -0500)]
Remove kdb5_util load iprop safety net

Revert the safety net added #7370.  As written it only applied to the
master KDC, where a normal load sometimes makes sense.  Even on a
slave, there are edge cases where it can make sense to do a normal
load.

ticket: 7850 (new)

10 years agoCheck for unstable ulog in ulog_get_entries
Greg Hudson [Sun, 26 Jan 2014 22:23:53 +0000 (17:23 -0500)]
Check for unstable ulog in ulog_get_entries

If a process terminates in the middle of a logged database update, it
will release its lock and leave the ulog in the KDB_UNSTABLE state.
kadmind should notice this when it calls ulog_get_entries, but right
now it only checks for the KDB_CORRUPT state (which is never set any
more) and does not recover.  Check for any state other than KDB_STABLE
and recover by resetting the ulog and forcing full resyncs to slaves.

ticket: 7853 (new)
target_version: 1.12.2
tags: pullup

10 years agoAdd test case for ulog serial number wrapping
Greg Hudson [Thu, 30 Jan 2014 17:26:09 +0000 (12:26 -0500)]
Add test case for ulog serial number wrapping

Add a unit test program named t_ulog.  Make it map a ulog file, set up
header state where kdb_last_sno is the last serial number, and then
add an empty update.  Check that the result is a ulog header with one
update at serial number 1.

ticket: 7839

10 years agoReinitialize ulog when wrapping serial number
Greg Hudson [Tue, 21 Jan 2014 15:58:04 +0000 (10:58 -0500)]
Reinitialize ulog when wrapping serial number

When we wrap the serial number, reinitialize the ulog so that kdb_num
starts counting from 1, instead of leaving the ulog in a weird state
where kdb_num == ulogentries but kdb_last_sno == 1 and the serial
numbers in the circular array aren't necessarily contiguous.

ticket: 7839 (new)
target_version: 1.12.2
tags: pullup

10 years agoRemove krb5-send-pr
Tom Yu [Wed, 22 Jan 2014 22:38:32 +0000 (17:38 -0500)]
Remove krb5-send-pr

Remove the GNATS-based krb5-send-pr script and replace it with a
script that instructs users to send email.

ticket: 7840 (new)

10 years agoAdd test coverage for gss_pseudo_random
Greg Hudson [Sat, 18 Jan 2014 18:25:56 +0000 (13:25 -0500)]
Add test coverage for gss_pseudo_random

Add a test program which compares gss_pseudo_random outputs against
expected values for each enctype.

10 years agoFix gss_pseudo_random leak on zero length output
Greg Hudson [Sat, 18 Jan 2014 18:03:32 +0000 (13:03 -0500)]
Fix gss_pseudo_random leak on zero length output

Nobody is likely to ever ask for zero bytes of output from
gss_pseudo_random, but if they do, just return an empty buffer without
allocating.  Otherwise we leak memory because gss_release_buffer
doesn't do anything to buffers with length 0.

ticket: 7838 (new)

10 years agoAdd test for gss_acquire_cred_from rcache feature
Greg Hudson [Thu, 16 Jan 2014 16:49:55 +0000 (11:49 -0500)]
Add test for gss_acquire_cred_from rcache feature

10 years agoAllow empty store in gss_acquire_cred_from
Greg Hudson [Thu, 16 Jan 2014 16:49:04 +0000 (11:49 -0500)]
Allow empty store in gss_acquire_cred_from

There is no reason to deny a zero-length cred store, so don't check
for it in val_acq_cred_args or val_add_cred_args.

ticket: 7836 (new)
target_version: 1.12.2
tags: pullup

10 years agoAvoid assertion failure in error_message
Greg Hudson [Thu, 16 Jan 2014 16:32:10 +0000 (11:32 -0500)]
Avoid assertion failure in error_message

r17942 added a call to get_thread_buffer in the first part of
error_message, prior to the call to com_err_initialize.  This can
cause an assertion failure from k5_getspecific if error_message is
called on a system error before any other com_err functions are
called.  Move the initialization call earlier to prevent this.

ticket: 7822 (new)
target_version: 1.12.2
tags: pullup

10 years agoAdd rcache feature to gss_acquire_cred_from
Simo Sorce [Fri, 27 Dec 2013 00:05:34 +0000 (19:05 -0500)]
Add rcache feature to gss_acquire_cred_from

The "rcache" cred store entry can specify a replay cache type and name
to be used with the credentials being acquired.

[ghudson@mit.edu: split up, simplified, and altered to fit preparatory
commits]

ticket: 7819 (new)

10 years agoClean up rcache if GSS krb5 acquire_cred fails
Greg Hudson [Wed, 15 Jan 2014 19:41:54 +0000 (14:41 -0500)]
Clean up rcache if GSS krb5 acquire_cred fails

The error handler in acquire_cred_context didn't release the rcache,
which would cause it to leak if we failed after acquire_accept_cred.

ticket: 7818 (new)
target_version: 1.12.2
tags: pullup

10 years agoClean up GSS krb5 acquire_accept_cred
Greg Hudson [Wed, 15 Jan 2014 17:51:42 +0000 (12:51 -0500)]
Clean up GSS krb5 acquire_accept_cred

Use a cleanup handler instead of releasing kt in multiple error
clauses.  Wrap a long line and fix a comment with a missing word.
Rewrap the function arguments to use fewer lines.

10 years agoMake rcache resolve functions take const char *
Greg Hudson [Wed, 15 Jan 2014 17:31:41 +0000 (12:31 -0500)]
Make rcache resolve functions take const char *

10 years agoUpdate copyright years and acknowledgments
Tom Yu [Fri, 17 Jan 2014 18:58:19 +0000 (13:58 -0500)]
Update copyright years and acknowledgments

10 years agoGet time offsets for all keyring ccaches
Greg Hudson [Thu, 16 Jan 2014 22:48:54 +0000 (17:48 -0500)]
Get time offsets for all keyring ccaches

Move the time offset lookup from krb5_krcc_resolve to make_cache, so
that we fetch time offsets for caches created by
krb5_krcc_ptcursor_next.

ticket: 7820
target_version: 1.12.2
tags: pullup

10 years agoUpdate copyright years
Tom Yu [Thu, 16 Jan 2014 01:42:08 +0000 (20:42 -0500)]
Update copyright years

10 years agomake update-po
Tom Yu [Wed, 15 Jan 2014 23:54:40 +0000 (18:54 -0500)]
make update-po

10 years agoSort file list for msgfmt
Tom Yu [Wed, 15 Jan 2014 23:40:57 +0000 (18:40 -0500)]
Sort file list for msgfmt

The list of input files for msgfmt was unsorted find output, resulting
in excessively large changes when running "make update-po".

ticket: 7821 (new)
target_version: 1.12.1
tags: pullup

10 years agoRemove mentions of krb5-send-pr
Tom Yu [Tue, 14 Jan 2014 20:43:35 +0000 (15:43 -0500)]
Remove mentions of krb5-send-pr

Start the process of deprecating krb5-send-pr.  In practice, it causes
frustration for some users, and free-form email is good enough for
most bug reports.

Continue to install krb5-send-pr for now, but plan to remove it from
the tree in the future, probably replaced by a script that instructs
the user to send email manually.

ticket: 5566
target_version: 1.12.1
tags: pullup

10 years agoFix typo in sphinx manpage output
Tom Yu [Tue, 14 Jan 2014 21:13:44 +0000 (16:13 -0500)]
Fix typo in sphinx manpage output

Some versions of the sphinx manpage writer have a typo in the name
'reStructuredText' written into the comments.  Add a sed command to
fix this.

ticket: 7817 (new)
target_version: 1.12.1
tags: pullup

10 years agoDon't produce context deletion token in krb5 mech
Greg Hudson [Mon, 13 Jan 2014 17:02:09 +0000 (12:02 -0500)]
Don't produce context deletion token in krb5 mech

RFCs 2743 and 4121 recommend that implementations produce empty tokens
from gss_delete_sec_context, and trying to produce one can cause
gss_delete_sec_context to fail on a partially established context.
Patch from Tomas Kuthan.

ticket: 7816 (new)

10 years agoRestrict AES-NI support to ELF platforms for now
Greg Hudson [Fri, 10 Jan 2014 16:54:13 +0000 (11:54 -0500)]
Restrict AES-NI support to ELF platforms for now

Since we explicitly specify the ELF object format when building
iaesx86.s or iaesx64.s, we need to restrict it to operating systems we
know to be ELF platforms.  Otherwise we can break the build on OS X,
which uses the Mach-O object format.

ticket: 7812
target_version: 1.12.1
tags: pullup

10 years agoClean up AES-NI code
Tom Yu [Fri, 10 Jan 2014 20:45:45 +0000 (15:45 -0500)]
Clean up AES-NI code

Items in .data other than shuffle_mask are unused; delete them.
Delete the unused macro load_and_inc4.  Move shuffle_mask to .rodata.

10 years agoAvoid text relocations in iaesx86.s
Tom Yu [Fri, 10 Jan 2014 20:04:32 +0000 (15:04 -0500)]
Avoid text relocations in iaesx86.s

Use PC-relative addressing to avoid runtime text relocations on i386.

Adapted patch from Nalin Dahyabhai.

ticket: 7815
target_version: 1.12.1
tags: pullup

10 years agoWork around Linux session keyring write behavior
Greg Hudson [Thu, 9 Jan 2014 05:18:44 +0000 (00:18 -0500)]
Work around Linux session keyring write behavior

If the session keyring matches the user session keyring, write
explicitly to the user session keyring.  Otherwise the kernel might
create a new session keyring for the process, making the resulting
cache collection invisible to other processes.

ticket: 7814
target_version: 1.12.1
tags: pullup

10 years agoRefactor krb5_string_to_keysalts()
Tom Yu [Tue, 7 Jan 2014 21:37:46 +0000 (16:37 -0500)]
Refactor krb5_string_to_keysalts()

Use various standard C library functions rather than rolling our own.
Previous code spent many lines reimplementing realloc(), strpbrk(),
strtok_r(), etc.

Make a separate string_to_keysalt() parser for an individual keysalt
pair, which for now is private and destructive.

10 years agoAdd test for salttype defaulting
Tom Yu [Mon, 6 Jan 2014 22:36:02 +0000 (17:36 -0500)]
Add test for salttype defaulting

ticket: 884

10 years agoMake salt defaulting work for keysalts
Tom Yu [Mon, 6 Jan 2014 22:17:02 +0000 (17:17 -0500)]
Make salt defaulting work for keysalts

Make krb5_string_to_keysalts() default to only ":" as a key:salt
separator character.  Change most of its callers to pass NULL so they
get the default separators.

Adapted from a patch proposed by Jon Looney.

ticket: 884

10 years agoDefault to normal salt instead of "ignore"
Tom Yu [Mon, 6 Jan 2014 21:32:50 +0000 (16:32 -0500)]
Default to normal salt instead of "ignore"

krb5_string_to_keysalts() treats an empty salt field as -1 ("ignore"),
rather than as the normal salttype.  Default to normal instead, so
that omitting a salttype works as expected.

ticket: 6042

10 years agoMark AESNI files as not needing executable stacks
Greg Hudson [Fri, 3 Jan 2014 18:50:48 +0000 (13:50 -0500)]
Mark AESNI files as not needing executable stacks

Some Linux systems now come with facilities to mark the stack as
non-executable, making it more difficult to exploit buffer overrun
bugs.  For this to work, object files built from assembly need a
section added to note whether they require an executable stack.

Patch from Dhiru Kholia with comments added.  More information at:
https://bugzilla.redhat.com/show_bug.cgi?id=1045699
https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart

ticket: 7813
target_version: 1.12.1
tags: pullup

10 years agoTest bogus KDC-REQs
Tom Yu [Wed, 1 Jan 2014 00:43:28 +0000 (19:43 -0500)]
Test bogus KDC-REQs

Send encodings that are invalid KDC-REQs, but pass krb5_is_as_req()
and krb5_is_tgs_req(), to make sure that the KDC recovers correctly
from failures in decode_krb5_as_req() and decode_krb5_tgs_req().  Also
send an encoding that isn't a valid KDC-REQ.

ticket: 7811 (new)
target_version: 1.12.1
tags: pullup

10 years agoFix possible null deref in previous
Tom Yu [Wed, 1 Jan 2014 00:41:12 +0000 (19:41 -0500)]
Fix possible null deref in previous

My rework of the do_tgs_req.c patch introduced a null deref if
decode_krb5_tgs_req() failed.

ticket: 7802

10 years agoLog service princ in KDC more reliably
rbasch [Mon, 16 Dec 2013 15:54:41 +0000 (10:54 -0500)]
Log service princ in KDC more reliably

Under some error conditions, the KDC would log "<unknown server>" for
the service principal because service principal information is not yet
available to the logging functions.  Set the appropriate variables
earlier.

do_as_req.c: After unparsing the client, immediately unparse the
server before searching for the client principal in the KDB.

do_tgs_req.c: Save a pointer to the client-requested service
principal, to make sure it gets logged if an error happens before
search_sprinc() successfully completes.

[tlyu@mit.edu: commit message; fix TGS to catch more error cases]

ticket: 7802
target_version: 1.12.1
tags: pullup

10 years agoFix uninitialized warning in client_init.c
Greg Hudson [Sat, 21 Dec 2013 15:08:06 +0000 (10:08 -0500)]
Fix uninitialized warning in client_init.c

ticket: 7800

10 years agoAllow realm in kadm5_init service names
Greg Hudson [Thu, 19 Dec 2013 18:33:33 +0000 (13:33 -0500)]
Allow realm in kadm5_init service names

Previously, if you passed a service name with a realm part to a
kadm5_init function, you would get a KRB5_PARSE_MALFORMED error
because the code would internally append its own '@realm' suffix
before parsing the name.  Fix this as follows:

Change gic_iter so instead of producing a full service name, it
produces a krb5_principal which is taken from the cred it acquires.
Pass the client and full service name around as principals, rather
than strings, and use the gss_nt_krb5_principal name type to import
them in setup_gss().  Don't append a realm to the input service name;
instead, pass the input service name directly to the gic functions
(which do not need a realm in the service name and will ignore the
realm if one is present).  For the INIT_CREDS case, parse the input
service name with KRB5_PRINCIPAL_PARSE_IGNORE_REALM and then set the
realm.

ticket: 7800

10 years agoSimplify libkadm5 client realm initialization
Greg Hudson [Thu, 19 Dec 2013 17:22:47 +0000 (12:22 -0500)]
Simplify libkadm5 client realm initialization

The "realm" variable in init_any is used only to fill in the realm of
the service principal in gic_iter().  The service principal realm
should always be the realm we looked up config parameters for, so we
can supply that realm to get_init_creds() unconditionally and
eliminate the case where we use the client principal realm.

Also get rid of an outdated comment and an #if 0 block we will never
need again, and use SNPRINTF_OVERFLOW to check the snprintf result.

10 years agomake depend
Greg Hudson [Sat, 21 Dec 2013 04:13:57 +0000 (23:13 -0500)]
make depend

10 years agoRequire built-in verto for make depend
Greg Hudson [Fri, 20 Dec 2013 23:42:04 +0000 (18:42 -0500)]
Require built-in verto for make depend

A tree configured to use the system libverto will be missing
$(VERTO_DEPS) in dependencies, so disallow make depend.

10 years agoAvoid keyctl purge in keyring ccache tests
Greg Hudson [Fri, 20 Dec 2013 20:19:06 +0000 (15:19 -0500)]
Avoid keyctl purge in keyring ccache tests

keyctl purge was added in keyutils 1.5 (released in March 2011).  Use
keyctl unlink to clean up keys instead, as it is more universal.

ticket: 7810
target_version: 1.12.1
tags: pullup

10 years agoUse an extended com_err hook in klist
Greg Hudson [Fri, 20 Dec 2013 16:06:52 +0000 (11:06 -0500)]
Use an extended com_err hook in klist

Add an adapted version of extended_com_err_fn from kinit to klist and
use it.  In do_ccache(), rely on the ccache type to set a reasonable
message if krb5_cc_set_flags() or krb5_cc_get_principal() fails due to
a nonexistent or unreadable ccache, and don't confuse the user with
the name of the ccache operation that failed.

ticket: 7809

10 years agoSet an error message when keyring get_princ fails
Nalin Dahyabhai [Thu, 5 Dec 2013 18:54:09 +0000 (13:54 -0500)]
Set an error message when keyring get_princ fails

When attempting to use a keyring cache that doesn't exist, set an error
message when we fail to read a principal name, as we do when we return
the same error code when using a file ccache.

[ghudson: removed unnecessary check for d->name nullity.]

ticket: 7809
target_version: 1.12.1
tags: pullup

10 years agoTest for verto_set_flags in system libverto
Greg Hudson [Fri, 20 Dec 2013 04:47:22 +0000 (23:47 -0500)]
Test for verto_set_flags in system libverto

libkrad relies on verto_set_flags, which was added to libverto in
release 0.2.4.  Make sure the system libverto has this function before
choosing it over the built-in version.

ticket: 7808 (new)
target_version: 1.12.1
tags: pullup

10 years agoMove kdc log routines into a separate file
Zhanna Tsitkov [Sat, 21 Dec 2013 00:18:57 +0000 (19:18 -0500)]
Move kdc log routines into a separate file

Their previous location - kdc_util.c - seems to be overloaded with
various helper functions. No code changes.

10 years agoFix typo that broke 'make clean'
Zhanna Tsitkov [Fri, 20 Dec 2013 16:06:19 +0000 (11:06 -0500)]
Fix typo that broke 'make clean'

Missing $

10 years agoMove kprop error explanation into Troubleshooting
Zhanna Tsitkov [Thu, 19 Dec 2013 18:08:56 +0000 (13:08 -0500)]
Move kprop error explanation into Troubleshooting

The plan is to make Troubleshooting section of the documentation a
one-stop-shop place for all error diagnostics, explanations and possible
solutions.  The relocation of kprop error messages descriptions is part of
this consolidation effort.

10 years agoAdd a test program for krb5_copy_context
Greg Hudson [Wed, 18 Dec 2013 18:08:25 +0000 (13:08 -0500)]
Add a test program for krb5_copy_context

This test program isn't completely proof against the kind of mistakes
we've made with krb5_copy_context in the past, but it at least
exercises krb5_copy_context and can detect some kinds of bugs.

ticket: 7807

10 years agoFix krb5_copy_context
Greg Hudson [Wed, 18 Dec 2013 20:03:03 +0000 (15:03 -0500)]
Fix krb5_copy_context

krb5_copy_context has been broken since 1.8 (it broke in r22456)
because k5_copy_etypes crashes on null enctype lists.  Subsequent
additions to the context structure were not reflected in
krb5_copy_context, creating double-free bugs.  Make k5_copy_etypes
handle null input and account for all new fields in krb5_copy_context.
Reported by Arran Cudbard-Bell.

ticket: 7807 (new)
target_version: 1.12.1
tags: pullup

10 years agoTest SPNEGO error message in t_s4u.py
Greg Hudson [Wed, 18 Dec 2013 21:03:16 +0000 (16:03 -0500)]
Test SPNEGO error message in t_s4u.py

Now that #7045 is fixed, we can check for the correct error message
from t_s4u2proxy_krb5 with --spnego.

ticket: 7045

10 years agoLet SPNEGO display mechanism errors
Simo Sorce [Tue, 17 Dec 2013 21:15:14 +0000 (16:15 -0500)]
Let SPNEGO display mechanism errors

To avoid potential recursion we use a thread local variable that tells
us whether the ancestor was called via spnego_gss_display_name().  If
we detect recursion, we assume that we returned a com_err code like
ENOMEM and call error_message(); in the worst case that will result in
an "Unknown error" message.

[ghudson@mit.edu: Edited comments and commit message; removed an
unneeded line of code.]

ticket: 7045
target_version: 1.12.1
tags: pullup

10 years agoRemove unused krb5_context fields
Greg Hudson [Wed, 18 Dec 2013 16:59:56 +0000 (11:59 -0500)]
Remove unused krb5_context fields

The vtbl and locate_fptrs fields were ostensibly related to the locate
pluggable interface, but weren't actually used.

10 years agoClarify klist -s documentation
Greg Hudson [Tue, 17 Dec 2013 21:56:41 +0000 (16:56 -0500)]
Clarify klist -s documentation

The documentation for klist -s erroneously suggests that it doesn't
affect the exit status behavior and that it merely checks for the
existence of the ccache (only mentioning the expired ticket check at
the end).  Make it clearer and simpler, but avoid going into a lot of
detail about the nature of the expiration check.

ticket: 7806 (new)
target_version: 1.12.1
tags: pullup

10 years agoRemove BADSYMS
Greg Hudson [Mon, 16 Dec 2013 22:09:31 +0000 (17:09 -0500)]
Remove BADSYMS

We haven't been using it or keeping it up to date, and there's no
need to keep it checked in.

10 years agoDon't require krb5.conf without KRB5_DNS_LOOKUP
Greg Hudson [Mon, 16 Dec 2013 22:09:00 +0000 (17:09 -0500)]
Don't require krb5.conf without KRB5_DNS_LOOKUP

For a long time we have allowed krb5 contexts to be initialized in the
absence of krb5.conf--but only if KRB5_DNS_LOOKUP is defined,
presumably on the theory that no KDCs could be contacted without
either DNS support or profile configuration.  But locate plugins could
provide the ability to find KDCs, and some libkrb5 operations (such as
IAKERB initiation) could succeed without needing to locate KDCs.

Also get rid of the profile_in_memory context flag, since we don't use
it any more.

10 years agoFix GSS krb5 acceptor acquire_cred error handling
Greg Hudson [Mon, 16 Dec 2013 20:37:56 +0000 (15:37 -0500)]
Fix GSS krb5 acceptor acquire_cred error handling

When acquiring acceptor creds with a specified name, if we fail to
open a replay cache, we leak the keytab handle.  If there is no
specified name and we discover that there is no content in the keytab,
we leak the keytab handle and return the wrong major code.  Memory
leak reported by Andrea Campi.

ticket: 7805
target_version: 1.12.1
tags: pullup

10 years agoFix memory leak in SPNEGO initiator
Simo Sorce [Fri, 13 Dec 2013 17:00:41 +0000 (12:00 -0500)]
Fix memory leak in SPNEGO initiator

If we eliminate a mechanism from the initiator list because
gss_init_sec_context fails, free the memory for that mech OID before
removing it from the list.

[ghudson@mit.edu: clarified commit message]

ticket: 7803 (new)
target_version: 1.12.1
tags: pullup

10 years agoRemove unneeded check in SPNEGO initiator
Greg Hudson [Mon, 16 Dec 2013 16:35:42 +0000 (11:35 -0500)]
Remove unneeded check in SPNEGO initiator

In init_ctx_cont, if the response token contains no fields, we set a
return value but don't actually quit out of the function.  We do not
need this check (we will fail later on if a piece of required
information isn't present), so just remove it.  Reported by
simo@redhat.com.

10 years agoFix SPNEGO one-hop interop against old IIS
Greg Hudson [Tue, 10 Dec 2013 17:04:18 +0000 (12:04 -0500)]
Fix SPNEGO one-hop interop against old IIS

IIS 6.0 and similar return a zero length reponse buffer in the last
SPNEGO packet when context initiation is performed without mutual
authentication.  In this case the underlying Kerberos mechanism has
already completed successfully on the first invocation, and SPNEGO
does not expect a mech response token in the answer.  If we get an
empty mech response token when the mech is complete during
negotiation, ignore it.

[ghudson@mit.edu: small code style and commit message changes]

ticket: 7797 (new)
target_version: 1.12.1
tags: pullup

10 years agoFix up tests directory ignores, deps, cleanup
Greg Hudson [Thu, 12 Dec 2013 05:23:02 +0000 (00:23 -0500)]
Fix up tests directory ignores, deps, cleanup

A few test programs didn't make it into .gitignore, OBJS, or
EXTRADEPSRCS.

10 years agoAdd tests for krb5_sname_to_principal
Greg Hudson [Mon, 9 Dec 2013 05:45:08 +0000 (00:45 -0500)]
Add tests for krb5_sname_to_principal

10 years agoAllow ":port" suffixes in sn2princ hostnames
Greg Hudson [Sun, 8 Dec 2013 23:05:26 +0000 (18:05 -0500)]
Allow ":port" suffixes in sn2princ hostnames

MSSQLSvc principal names can contain a ":port" or ":instance" trailer
on the hostname part.  If we see that in the hostname argument of
krb5_sname_to_principal(), remove it before canonicalizing the
hostname and put it back on afterwards.

ticket: 7795 (new)

10 years agoModernize sn2princ.c
Greg Hudson [Tue, 3 Dec 2013 21:19:35 +0000 (16:19 -0500)]
Modernize sn2princ.c

Refactor and edit sn2princ.c to match current coding style.  No
behavior changes, except to be less chatty in trace logs.

10 years agoUpdate man pages
Tom Yu [Wed, 11 Dec 2013 03:26:17 +0000 (22:26 -0500)]
Update man pages

10 years agomake depend
Tom Yu [Wed, 11 Dec 2013 03:24:03 +0000 (22:24 -0500)]
make depend

10 years agoBetter keysalt docs
Tom Yu [Mon, 9 Dec 2013 20:48:02 +0000 (15:48 -0500)]
Better keysalt docs

Add a new section to kdc_conf.rst to describe keysalt lists, and
update other documentation to better distinguish enctype lists from
keysalt lists.

ticket: 7608
target_version: 1.12
tags: pullup

10 years agoAvoid malloc(0) in SPNEGO get_input_token
Greg Hudson [Fri, 6 Dec 2013 23:56:56 +0000 (18:56 -0500)]
Avoid malloc(0) in SPNEGO get_input_token

If we read a zero-length token in spnego_mech.c's get_input_token(),
set the value pointer to NULL instead of calling malloc(0).

ticket: 7794 (new)

10 years agoFix S4U2Self against non-FAST KDCs
Greg Hudson [Fri, 6 Dec 2013 01:32:05 +0000 (20:32 -0500)]
Fix S4U2Self against non-FAST KDCs

When we added FAST TGS support in 1.11, we broke S4U2Self against KDCs
which don't support FAST, because the S4U2Self padata is only present
within the FAST request.  For now, duplicate that padata in the outer
request so that both FAST and non-FAST KDCs can see it.

ticket: 7791
target_version: 1.11.5
tags: pullup

10 years agoFix error message quotations in install_kdc.rst
Tom Yu [Tue, 3 Dec 2013 19:47:51 +0000 (14:47 -0500)]
Fix error message quotations in install_kdc.rst

Some error messages that kprop could print were quoted incorrectly in
install_kdc.rst.

Also fix minor typos.

ticket: 7785 (new)
target_version: 1.12
tags: pullup

10 years agoEdit README.asn1
Greg Hudson [Tue, 3 Dec 2013 07:05:46 +0000 (02:05 -0500)]
Edit README.asn1

Add another blank line before section headers.  Avoid contractions.
Change some whiches to thats where it seems appropriate.  Fix some
missing or extra words.

10 years agoBump libgssrpc minor version
Tom Yu [Wed, 27 Nov 2013 20:15:14 +0000 (15:15 -0500)]
Bump libgssrpc minor version

Bump minor version for the new log_badauth2 interfaces.

ticket: 7770

10 years agoCorrectly log IPv6 addresses in kadmind
Greg Hudson [Mon, 25 Nov 2013 16:46:47 +0000 (11:46 -0500)]
Correctly log IPv6 addresses in kadmind

Define client_addr() in server_stubs.c and use it consistently in that
file and ipropd_svc.c to get the client address from a transport
handle.  In it, call getpeername() on the client socket and use
inet_ntop() on the result, instead of using inet_ntoa() on the IPv4
socket address.  Provide a log_badauth2 callback to GSSRPC, so that we
get a transport handle instead of an IPv4 socket address, and use
client_addr() within it instead of inet_ntoa().

ticket: 7770
target_version: 1.12
tags: pullup

10 years agoAdd new versions of log_badauth gssrpc callbacks
Greg Hudson [Mon, 25 Nov 2013 16:33:35 +0000 (11:33 -0500)]
Add new versions of log_badauth gssrpc callbacks

libgssrpc supports two callbacks for gss_accept_sec_context failures
on servers (one for AUTH_GSS and one for AUTH_GSSAPI), which are
IPv4-specific.  Provide an alternate version which supplies the
transport handle instead of the address, so that we can get the
address via the file descriptor for TCP connections.

ticket: 7770

10 years agoRemove inet_ntoa() prototype from getrpcent.c
Ben Kaduk [Mon, 25 Nov 2013 18:36:34 +0000 (13:36 -0500)]
Remove inet_ntoa() prototype from getrpcent.c

It is not needed.

In general, we shouldn't be using inet_ntoa(), anyway, as it is
IPv4-specific and we have IPv6 support almost everywhere.

10 years agoUpdate doc for current kdb5_util dump version
Tom Yu [Fri, 22 Nov 2013 23:23:52 +0000 (18:23 -0500)]
Update doc for current kdb5_util dump version

kdb5_util.rst incorrectly describes the current default dump format
version as 6 when it should be 7.  Reported by Jeff D'Angelo.

ticket: 7777
target_version: 1.12
tags: pullup

10 years agoEdit ccache_def.rst
Greg Hudson [Fri, 22 Nov 2013 21:53:35 +0000 (16:53 -0500)]
Edit ccache_def.rst

Re-fill to 70 columns.  Replace non-ascii apostrophes with ASCII ones.
Edit wording slightly.

ticket: 7776

10 years agoAdded a new ccache doc to "Kerberos V5 concepts"
Zhanna Tsitkov [Fri, 22 Nov 2013 19:02:57 +0000 (14:02 -0500)]
Added a new ccache doc to "Kerberos V5 concepts"

This is to add a short introductory document on credential
caches to the Concepts section of Kerberos documentation.

ticket: 7776 (new)
target_version: 1.12
tags: pullup

10 years agoImprove default ccache name API documentation
Greg Hudson [Thu, 21 Nov 2013 22:30:54 +0000 (17:30 -0500)]
Improve default ccache name API documentation

Document the lifetime and caching behavior of the
krb5_cc_default_name() return value.  Document that
krb5_cc_set_default_name() may be called with NULL to purge the cached
value.  Correct a typo in the krb5_cc_default() summary and explicitly
reference krb5_cc_default_name().

ticket: 7775 (new)
target_version: 1.12
tags: pullup

10 years agoCorrect kadm5.acl back-reference documentation
Greg Hudson [Thu, 21 Nov 2013 21:22:48 +0000 (16:22 -0500)]
Correct kadm5.acl back-reference documentation

In kadm5.acl, *N in the target principal name refers to the Nth
wildcard in the acting principal pattern, not the Nth component.

ticket: 7774 (new)
target_version: 1.12
tags: pullup

10 years agoAdd another kadmin ACL test for backreferences
Greg Hudson [Thu, 21 Nov 2013 21:18:27 +0000 (16:18 -0500)]
Add another kadmin ACL test for backreferences

Add a test using backreferences which don't correspond directly to
principal components, to verify that *N refers to the Nth wildcard and
not the Nth component.

10 years agoClarify lockout replication issues in docs
Greg Hudson [Mon, 18 Nov 2013 23:59:17 +0000 (18:59 -0500)]
Clarify lockout replication issues in docs

In the "KDC replication and account lockout" section of lockout.rst,
specifically call out kprop and incremental propagation as the
mechanisms which do not replicate account lockout state, and add a
note that KDCs using LDAP may not be affected by that section's
concerns.

ticket: 7773 (new)
target_version: 1.12
tags: pullup

10 years agoRemove dangling --with-kdc-kdb-update references
Greg Hudson [Sun, 17 Nov 2013 17:37:09 +0000 (12:37 -0500)]
Remove dangling --with-kdc-kdb-update references

This configure option hasn't done anything since 1.8, so don't mention
it in configure --help or the documentation.  The disable_last_success
and disable_lockout DB options are now used to turn it off.