Commit Graph

194 Commits

Author SHA1 Message Date
Roland C. Dowdeswell
e65db603bf Issue 282: fix tolower_ascii in lib/krb5/principal.c. 2017-05-16 11:51:33 -05:00
Jeffrey Altman
ec39b832ff kdc: fix kx509 service principal match
Each KDC is a kx509 server.  The service principal must be of the
form

  kca_service/<localhost.domain>@<DEFAULT_REALM>

where localhost.domain is the hostname returned by gethostname()
and <DEFAULT_REALM> is one of the realms for which the KDC has a service
principal "kca_service/<localhost.domain>".

The matching code was broken by a5e77c578e
when krb5_sname_to_principal() began to always return a referral
principal.

Since the second component is a host name update the default principal
type for service "kca_service" to be KRB5_NT_SRV_HST.

Change-Id: I6bd5f90b674ebb7220d8efafa6d339fdc21e1a07
2017-01-27 00:37:08 -05:00
Nicolas Williams
1c81ddf4e2 Round #2 of scan-build warnings cleanup 2016-11-16 17:03:14 -06:00
Jeffrey Altman
961f543a27 Set princ type to NT-SMTP-NAME when parsing
In krb5_parse_name_flags(), if the principal name is not an enterprise
name, is one component in length and contains an '@', set the principal
type to NT-SMTP-NAME as specified by RFC 4120.
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
Jeffrey Altman
6234073499 add missing principal types
Add the WELLKNOWN and NT-HST-DOMAIN principal types to the nametype
table and asn.1

Change-Id: Ife9c3860f375bac1a06152b0d261c63ec071a763
2016-07-17 00:44:50 -04:00
Viktor Dukhovni
840dc40574 Refine name canonicalization
When storing credentials whose ticket principal is not equal to the
requested principal, store the ticket under both names not only when
the original realm is the referral realm, but more generally for any
difference at all.  This matches MIT behaviour.

Allow explicit name_canon rules to specify a realm to go with the
canonicalized hostname, if that realm is empty the effect is the
same "use-referrals"

Also fix segfault when no creds and debugging
2016-06-09 01:13:15 -04:00
Jeffrey Altman
1953b0bd39 krb5: pricipal -> principal
fix the spelling errors

Change-Id: I6769ecc50009c11a296766961c1873f4836f33a7
2016-04-10 17:05:07 -05:00
Santosh Kumar Pradhan
e5144acab0 heimdal: Use krb5_free_default_realm() for free()
The resource allocated by krb5_default_default_realm() should be
free()'d by krb5_free_default_realm() instead of plain free()
for better readability.

Signed-off-by: Santosh Kumar Pradhan <spradhan@redhat.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2015-06-17 17:41:26 -05:00
Nicolas Williams
e7b5efb103 coverity 1164091 2015-04-18 23:19:26 -05:00
Nicolas Williams
febe23a399 Improve and export krb5_principal_set_comp_string 2015-04-13 16:59:20 -05:00
Nicolas Williams
b48bed5f42 Daemons detach atomically to avoid having to wait
Tests that start daemons have to "wait" for them to start.

This commit makes Heimdal daemons prep to detach (when requested) by
forking early, then having the child signal readiness to the parent when
the child really is ready.  The parent exits only which the child is
ready.  This means that tests will no longer need to wait for daemons.

However, tests will still need a pidfile or such so they can stop the
daemons.

Note that the --detach options should not be used on OS X from launchd,
only from tests.
2015-03-24 11:49:59 -05:00
Nicolas Williams
a7587b08e2 Support hostname:port svc princs 2015-03-24 11:49:59 -05:00
Nicolas Williams
5fffc4061f Don't use canon rules in principal name comparison 2015-03-24 11:49:59 -05:00
Nicolas Williams
487b6820f6 Revamp name canonicalization code 2015-03-24 11:49:58 -05:00
Viktor Dukhovni
cfdf6d5cbe gsskrb5: Make krb5 mech use referrals
Modify the gss krb5 mech to always use referrals unless the
KRB5_NCRO_NO_REFERRALS flag is set.

Change-Id: I7efd873ac922a43adafa2c492703b576847a885f
2015-03-14 16:08:32 -04:00
Viktor Dukhovni
d4fda7e4f0 LLVM unused variable warning 2015-03-04 19:52:58 -05:00
Jeffrey Altman
c07aaee128 krb5_get_name_canon_rules: fix profile location
[realms] <realm> { name_canon_rules = <strings> }

not

[libdefaults] <realm> { name_canon_rules = <strings> }

Change-Id: I770c2250333d2649f983f015de94f30740c9771d
2014-02-14 22:32:15 -05:00
Jeffrey Altman
c1f822f7af rename struct krb5_name_canon_* name collisions
C++ does not permit struct names and typedef names to be the same.
Rename

  struct krb5_name_canon_rule to struct krb5_name_canon_rule_data

and

  struct krb5_name_canon_iterator to struct krb5_name_canon_iterator_data

Change-Id: I92766e0878bf0beef92de1649baf9e5cafbf86aa
2013-10-06 16:42:05 -04:00
Viktor Dukhovni
2433496ea6 Simplify user_realm support by removing krb5_parse_name_flags_realm()
and setting the realm as necessary in the caller.
2013-05-16 23:15:00 -04:00
Viktor Dukhovni
4ce879c938 Fix: double free 2013-05-16 00:34:24 -04:00
Viktor Dukhovni
4fcad71a3a Two new flags for krb5_parse_name_flags_realm():
- KRB5_PRINCIPAL_PARSE_IGNORE_REALM: MIT compatible

    - KRB5_PRINCIPAL_PARSE_NO_DEF_REALM: Don't default the realm

The first ignores the realm if present.

The second does not impute the default realm if no realm is given and
leaves the realm NULL.  This will be used in kinit to determine whether
the user provided a realm or not, and if not we may use the user_realm,
or find the realm via the keytab.
2013-05-16 00:32:08 -04:00
Viktor Dukhovni
a2127d091d New krb5_parse_name_flags_realm supports explicit default realm.
Set the realm argument to NULL to get the usual default realm.

The krb5_parse_name_flags() function is now a wrapper around
krb5_parse_name_flags_realm().
2013-05-16 00:32:08 -04:00
Viktor Dukhovni
01fff2ca9c Allow krb5_principal_set_realm to set the realm to NULL. 2013-05-16 00:32:06 -04:00
Love Hornquist Astrand
55e5bfdfe0 add krb5_principal_is_root_krbtgt 2013-05-07 13:10:02 -07:00
Viktor Dukhovni
bf40b8cc63 Comment wordsmithing 2013-05-02 01:31:01 -04:00
Love Hornquist Astrand
dfaedb7847 plug a memory leak, don't use strcpy/strcat 2013-05-01 13:55:21 -07:00
Viktor Dukhovni
9ca0a2b62f More consistent error checks in build_principal()
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2013-04-24 16:26:23 -07:00
Viktor Dukhovni
5903031630 Don't SEGV on as-is rules without realm=
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2013-04-24 16:23:36 -07:00
Love Hornquist Astrand
58ff480763 rewrite send to kdc to be more agressive, try kdcs in paralell and easier to configure behavior 2013-02-10 19:02:52 -08:00
Love Hornquist Astrand
c979a356f7 uninited memory free 2012-11-27 21:58:05 -08:00
Love Hornquist Astrand
b0ed05395a tell coverity that principal returns an allocated pointer 2012-11-27 21:58:05 -08:00
Love Hornquist Astrand
c12dc3fa9d tell coverity that ret_princ returns an allocated pointer 2012-11-27 21:58:05 -08:00
Love Hörnquist Åstrand
9c830f5237 indent 2011-10-31 22:10:09 -07:00
Love Hörnquist Åstrand
877df213eb make sure we don't use stack content, don't count on that unsigned value can be negative 2011-10-31 22:05:42 -07:00
Nicolas Williams
c353962428 Oops, mismerge in principal.c 2011-10-31 00:29:36 -05:00
Nicolas Williams
7da9d7d75f Fix memory leak in name canon rule iterator 2011-10-31 00:15:07 -05:00
Nicolas Williams
1192120b86 Fix 64-bit warnings in name canon rules code 2011-10-29 16:48:56 -05:00
Love Hörnquist Åstrand
a57988153e indent 2011-10-28 20:08:08 -07:00
Nicolas Williams
3a393427e9 krb5_principal_compare() can't return errors... 2011-10-27 22:57:02 -05:00
Nicolas Williams
c433fefb23 Fix contributewd by Roland Dowdeswell for 64-bit bug in name canon patches 2011-10-27 17:34:57 -05:00
Nicolas Williams
5c54736678 Removed "weak" option and implemented use-referrals/no-referrals 2011-10-22 14:54:26 -05:00
Nicolas Williams
f4471b11d6 Call krb5_set_error_message() and don't clobber ret in debug code 2011-10-22 14:54:25 -05:00
Nicolas Williams
248e1eb772 Cleanups: s/\<assert\>/heim_assert/ 2011-10-22 14:54:25 -05:00
Nicolas Williams
9f5a43084c Cleanups: s/ENOMEM/krb5_enomem(context)/ 2011-10-22 14:54:25 -05:00
Nicolas Williams
2f03603d6b Cleanups: s/krb5int_/_krb5_/ and moved priv stuff from krb5.h 2011-10-22 14:54:25 -05:00
Nicolas Williams
001fc24102 Removed vestiges of no-reverse-lookup/reverse-lookup option that was never implemented 2011-10-22 14:54:24 -05:00
Nicolas Williams
a5e77c578e Deferred hostname canon using name canon rules 2011-10-22 14:54:13 -05:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00