Commit Graph

853 Commits

Author SHA1 Message Date
Nicolas Williams
09f0a25fda kdc --builtin-hdb should list loadable backends
This fixes the following problems from #210:

 - hdb_ldap doesn't load even when installed correctly
 - loadable hdb backends not listed by kdc --builtin-hdb

Not fixed:

 - hdb_ldap.so not installed in plugin dir
2016-11-15 11:34:54 -06:00
Nicolas Williams
22790e4508 Test RODC interop fix 2016-11-14 21:29:47 -06:00
Nicolas Williams
a59bb7132f When building a princ name pick a sane def type
This is part of the fix to #173.  MSFT RODCs insist on the name type for
krbtgt principals be set to KRB5_NT_SRV_INST.

Commentary from Jeffrey Altman <jaltman@secure-endpoints.com>

As reported by David Mulder of Dell's Quest, Active Directory will
return a BAD_INTEGRITY error when a request for a krbtgt service
ticket is received with principal type NT-PRINCIPAL instead of NT-SRV-INST
as required by RFC 4120.

[Nico: RFC4120 does not require this.  See the description of the
       name-type field of PrincipalName on page 55.]

  ERROR: VAS_ERR_KRB5: Failed to obtain credentials.
  Client: SLED10-32$@F.QAS,
  Service: SLED10-32$@F.QAS, Server: ad2-f.f.qas
  Caused by: KRB5KRB_AP_ERR_BAD_INTEGRITY (-1765328353): Decrypt integrity check failed

Microsoft began enforcing principal type checking for RODCs in 2008R2.
Microsoft does state that ALL krgtgt/REALM tickets SHOULD be sent using
principal name type of KRB5_NT_SRV_INST instead of KRB5_NT_PRINCIPAL.

From Microsoft:

  "I believe we discovered the problem. There isn't a bug in Windows.
  There's been a code change to address another issue which puts in additional
  checks for Kerberos tickets. The problem is with the Unix clients when the
  client request a TGT. The Unix clients are using Name-type Principal
  [KRB_NT_PRINCIPAL (1)] instead of using Name-type Service and Instance
  [KRB_NT_SRV_INST (2)]...."

This change assigns the NT-SRV-INST principal type each time a krbtgt
service principal is created.  Unlike Microsoft, the Heimdal mostly does
not care about the name-type of any principals, with the exception of
referrals, where the name type is needed to decide how to find a
next-hop realm.
2016-11-14 21:29:47 -06:00
Viktor Dukhovni
4b4036c9a6 Implement hierarchical referrals 2016-08-08 16:29:29 -05:00
Viktor Dukhovni
1501740952 Fix transit path validation
Also implement KDC hierarchical transit policy checks.  The "hier_capaths"
parameter defaults to "yes" in [libdefaults] or can be set explicitly in
[realms] per-realm.
2016-08-08 16:29:18 -05:00
Viktor Dukhovni
c3eb3341c2 Implement and test referrals for host:port 2016-02-26 15:43:13 -05:00
Nicolas Williams
8343733562 kadmind: check ACLs for aliases CVE-2016-2400
CVE-2016-2400

kadmind(8) was not checking for 'add' permission to aliases added via
kadm5_modify_principal().  This is a security vulnerability.  The impact
of this vulnerability is mostly minor because most sites that use
kadmind(8) generally grant roughly the same level of permissions to all
administrators.  However, the impact will be higher for sites that grant
modify privileges to large numbers of less-privileged users.

From what we know of existing deployments of Heimdal, it seems very
likely that the impact of this vulnerability will be minor for most
sites.
2016-02-26 01:04:32 -06:00
Nicolas Williams
dbf9750989 Tests: set db-dir so tests don't use /var/heimdal 2016-02-26 01:04:31 -06:00
Nicolas Williams
20df2c8706 Two-phase HDB commit via iprop log, + GC for log
We used to update the iprop log and HDB in different orders depending on
the kadm5 operation, which then led to various race conditions.

The iprop log now functions as a two-phase commit (with roll forward)
log for HDB changes.  The log is auto-truncated, keeping the latest
entries that fit in a configurable maximum number of bytes (defaults to
50MB).  See the log-max-size parameter description in krb5.conf(5).

The iprop log format and the protocol remain backwards-compatible with
earlier versions of Heimdal.  This is NOT a flag-day; there is NO need
to update all the slaves at once with the master, though it is advisable
in general.  Rolling upgrades and downgrades should work.

The sequence of updates is now (with HDB and log open and locked):

a) check that the HDB operation will succeed if attempted,
b) append to iprop log and fsync() it,
c) write to HDB (which should fsync()),
d) mark last log record committed (no fsync in this case).

Every kadm5 write operation recover transactions not yet confirmed as
committed, thus there can be at most one unconfirmed commit on a master
KDC.

Reads via kadm5_get_principal() also attempt to lock the log, and if
successful, recover unconfirmed transactions; readers must have write
access and must win any race to lock the iprop log.

The ipropd-master daemon also attempts to recover unconfirmed
transactions when idle.

The log now starts with a nop record whose payload records the offset of
the logical end of the log: the end of the last confirmed committed
transaction.  This is kown as the "uber record".  Its purpose is
two-fold: act as the confirmation of committed transactions, and provide
an O(1) method of finding the end of the log (i.e., without having to
traverse the entire log front to back).

Two-phase commit makes all kadm5 writes single-operation atomic
transactions (though some kadm5 operations, such as renames of
principals, and changes to principals' aliases, use multiple low-level
HDB write operations, but still all in one transaction).  One can still
hold a lock on the HDB across many operations (e.g., by using the lock
command in a kadmin -l or calling kadm5_lock()) in order to push
multiple transactions in sequence, but this sequence will not be atomic
if the process or host crashes in the middle.

As before, HDB writes which do not go through the kadm5 API are excluded
from all of this, but there should be no such writes.

Lastly, the iprop-log(1) command is enhanced as follows:

 - The dump, last-version, truncate, and replay sub-commands now have an
   option to not lock the log.  This is useful for inspecting a running
   system's log file, especially on slave KDCs.

 - The dump, last-version, truncate, and replay sub-commands now take an
   optional iprop log file positional argument, so that they may be used
   to inspect log files other than the running system's
   configured/default log file.

Extensive code review and some re-writing for clarity by Viktor Dukhovni.
2016-02-26 00:55:33 -06:00
Nicolas Williams
a94dc50114 Add --with-db-type-preference config param 2016-02-26 00:55:32 -06:00
Nicolas Williams
c6f24e99f0 Revamp cf/db.m4; test LMDB 2016-02-26 00:55:32 -06:00
Andrew Bartlett
960fa481be Add test for incorrect password
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2015-06-17 17:41:25 -05:00
Nicolas Williams
05a919b94b iprop slave: try incremental after complete xfer
The following sequence of events results in slave B having a stale HDB:

 - slave A connects to master, master dumps HDB for the slave
 - kadm5 operations
 - slave B connects to master, master sends previously dumped HDB

slave B won't discover any updates until the next transaction.

The fix is simple: the slave should immediately call ihave() after
receiving a complete HDB.
2015-05-20 10:07:52 -05:00
Love Hörnquist Åstrand
4c98e27eda call hdb_auth_status when password is wrong in the ENC-CHAL case too, thanks Andrew Bartlett for pointing this out 2015-04-28 08:54:24 -07:00
Nicolas Williams
feb245f741 Undo workaround for NTLM and mechglue bugs 2015-04-17 10:55:47 -05:00
Nicolas Williams
5d50d06845 Better test workaround for NTLM bug 2015-04-16 19:53:22 -05:00
Nicolas Williams
d6a7d14fc5 Workaround bugs exposed by test_context changes
Bugs exposed by 61720a0:

 - test_context --client-name=... --mech-type=ntlm ... fails;

 - gss_acquire_cred() with desired_mech=NTLM and
   desired_name==GSS_C_NO_NAME fails;

 - gss_init_sec_context() with non-default cred handle calls the
   mechanism even when the given cred handle has no element for the
   requencet mechanism.

tests/gss/check-ntlm works by accident: gss_acquire_cred() with
desired_mechs==GSS_C_NO_OID_SET succeeds mostly because there are
Kerberos credentials available, and then the subsequent
gss_init_sec_context() call works because of the third bug described
above.
2015-04-16 18:42:51 -05:00
Nicolas Williams
95a2ba6aea Test gss_acquire_cred_with_password() 2015-04-15 12:37:51 -05:00
Nicolas Williams
a318ac86f5 Run tests/gss/check-basic 2015-03-24 11:50:01 -05:00
Nicolas Williams
f73c4edf69 Fix gss_store_cred() 2015-03-24 11:50:01 -05:00
Nicolas Williams
3021258f60 Add tests/bin/intr
This utility, inspired by the old SunOS 4.x intr(8) utility, will be
used to start daemons with --detach and a timeout, like this:

    intr -t 5 kdc --detach || { echo failed to start kdc; exit 1 }

This will allow tests to stop having to sleep poll for "started" output
from the daemons they start, allowing them to run faster and to impose a
reasonable timeout on daemon startup.

The default timeout is 3 seconds.
2015-03-24 11:50:00 -05:00
Nicolas Williams
487b6820f6 Revamp name canonicalization code 2015-03-24 11:49:58 -05:00
Nicolas Williams
d9e3e376a3 tests: Add simple key history test for kdc
Use kadmin cpw with the --keepold parameter to create a history list.

Change-Id: I21811c840be0bd1b8dd8dc66e63f88f8da6fac7e
2015-03-14 16:08:23 -04:00
Viktor Dukhovni
c3ddece8d4 Name canon kdc config breaks iprop 2015-03-04 17:04:20 -05:00
Love Hörnquist Åstrand
a220ed39eb try using as-is name_canon_rules 2014-09-09 18:36:57 +02:00
Love Hörnquist Åstrand
44ba0bcd24 no need to make chmod quiet, it supposed to be already because of \ 2014-08-23 19:29:04 -07:00
Love Hörnquist Åstrand
8504dce265 make quiet 2014-08-22 21:26:15 -07:00
Love Hörnquist Åstrand
a84b572747 resurrect password change support again 2014-08-22 20:19:36 -07:00
Jelmer Vernooij
70e43e9808 Fix some typos. 2014-04-25 02:42:17 +02:00
Love Hörnquist Åstrand
62b413b5df make quiet 2014-02-18 08:27:00 -08:00
Love Hörnquist Åstrand
a6e136c739 make quiet 2014-02-18 08:27:00 -08:00
Love Hörnquist Åstrand
6a192f0dce clean files 2014-02-16 11:53:56 -08:00
Love Hörnquist Åstrand
54378de6b4 add an2ln-db.txt 2014-02-16 10:05:24 -08:00
Nicolas Williams
2f7eec7d2c Add very large MIT KDB princ entry for testing
Constructed by doing repeated kadmin.local cpw commands with a policy
with -history 9.
2013-11-20 01:08:22 -06:00
Love Hornquist Astrand
1881980d44 spelling 2013-10-18 10:45:59 +02:00
Love Hornquist Astrand
10f3c8b56e add possible to set rules on what enctypes to use based on glob matching on principal 2013-10-18 10:01:55 +02:00
Love Hornquist Astrand
499affd8fa tet setting policy 2013-10-18 09:06:52 +02:00
Nicolas Williams
36f22356c5 Add [manual] test of kinit cmd
It's not ready to always be run.  First, it's slow.  Second, it tortures
the system.  Third, it doesn't look for signs of failure.  Fourth, if it
did it'd fail: because something about the racing is causing the KDC to
think that the foo principal doesn't exist.
2013-09-12 12:14:41 -05:00
Love Hornquist Astrand
3484432cc5 clean log between test, dump log on failure 2013-07-19 14:53:22 +02:00
Love Hornquist Astrand
fdfe696821 if no db, don't check FAST 2013-06-05 20:33:29 -07:00
Love Hornquist Astrand
81263bc94c update leaks check 2013-04-24 17:59:25 -07:00
Viktor Dukhovni
a825143e73 The k5login_directory parameter and SYSTEM-K5LOGIN[:directory] are supposed to be directories, not path templates with %{luser} substitution
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2013-04-24 16:25:59 -07:00
Love Hornquist Astrand
edae63418e client logging too 2013-02-10 23:20:56 -08:00
Love Hornquist Astrand
da42d01d54 x 2013-02-10 21:12:34 -08:00
Love Hornquist Astrand
1adb5de80d fix logging to be sync 2013-02-10 21:11:53 -08:00
Love Hornquist Astrand
0c2e3d94bf default to open/write/close logging 2012-12-27 13:07:13 +01:00
Love Hornquist Astrand
ee068eaf21 note about = 2012-12-27 12:03:17 +01:00
Love Hornquist Astrand
4ebfd6b818 make sure logs are truncated 2012-10-07 11:11:17 -07:00
Love Hornquist Astrand
c707016669 scan whole logfile 2012-10-07 11:06:29 -07:00
Love Hornquist Astrand
703ae0e22d add db-dir 2012-10-01 09:50:32 -07:00