Commit Graph

24 Commits

Author SHA1 Message Date
Nicolas Williams
5f63215d0d Always perform == or != operation on cmp function result
Although not required to address bad code generation in
some versions of gcc 9 and 10, a coding style that requires
explicit comparison of the result to zero before use is
both clearer and would have avoided the generation of bad
code.

This change converts all use of cmp function usage from

```
    if (strcmp(a, b) || !strcmp(c, d)) ...
```

to

```
    if (strcmp(a, b) != 0 || strcmp(c, d)) == 0
```

for all C library cmp functions and related:

 - strcmp(), strncmp()
 - strcasecmp(), strncasecmp()
 - stricmp(), strnicmp()
 - memcmp()

Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
2021-11-24 22:30:44 -05:00
Viktor Dukhovni
d2130e3312 Handle long lines in dump files 2017-10-11 17:13:07 -05:00
Nicolas Williams
9e084ca1d7 Fix MIT dump entry parsing bug that forced 2048 sz 2013-11-20 01:08:22 -06:00
Nicolas Williams
a3947acb38 Fix segfault in MIT dump entry parsing code 2012-05-19 21:57:53 -05:00
Nicolas Williams
57f1545a46 Add support for writing to KDB and dumping HDB to MIT KDB dump format
Before this change Heimdal could read KDBs.  Now it can write to
    them too.

    Heimdal can now also dump HDBs (including KDBs) in MIT format, which
    can then be imported with kdb5_util load.

    This is intended to help in migrations from MIT to Heimdal by
    allowing migrations from Heimdal to MIT so that it is possible
    to rollback from Heimdal to MIT should there be any issues.  The
    idea is to allow a) running Heimdal kdc/kadmind with a KDB, or
    b) running Heimdal with an HDB converted from a KDB and then
    rollback by dumping the HDB and loading a KDB.

    Note that not all TL data types are supported, only two: last
    password change and modify-by.  This is the minimum necessary.
    PKINIT users may need to add support for KRB5_TL_USER_CERTIFICATE,
    and for databases with K/M history we may need to add KRB5_TL_MKVNO
    support.

    Support for additional TL data types can be added in
    lib/hdb/hdb-mitdb.c:_hdb_mdb_value2entry() and
    lib/hdb/print.c:entry2mit_string_int().
2012-05-03 14:24:18 -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
Love Hornquist Astrand
dde9ae659b drop RCSID 2010-03-16 12:50:09 -07:00
Russ Allbery
5230b2f8f5 Discard old keys in MIT dump files in hprop
An MIT dump file may contain multiple key sets for one principal, with
different kvnos.  The Heimdal database can only represent a single
kvno, and previously the kvno was set to the last key found in the entry
and all keys were added to the entry.  Since kvnos are given from high
to low in the database dump, this would result in the principal getting
the kvno of the oldest key and all keys stored without regard for kvno.

Instead, ignore all keys with kvnos lower than the first kvno we see and
only store keys with a kvno matching it.  If we see a key with a kvno
higher than the first kvno we see, exit with an error since that case is
not currently handled (and should not happen in a typical MIT database
dump).

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-03-16 11:48:15 -07:00
Russ Allbery
20c65310ea Support MIT dump formats 5 and 6 in hprop
Dump formats 5 and 6 differ from the supported version 4 dump format
only in that they include policy information for each principal in an
extension that the dump parsing code already knows how to ignore and
that they include policy lines.  Ignore the policy information, since
there isn't a corresponding concept in Heimdal, and accept the new
dump format versions.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-02-02 13:27:36 -08:00
Russ Allbery
73d0fc23a4 Store last password change date when parsing MIT dumps in hprop
If the MIT dump file includes a last password change date, allocate
a database extension structure to hold that information and include
it in the corresponding Heimdal database entry.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-02-02 13:27:10 -08:00
Love Hornquist Astrand
b02039ae30 have require_hwauth 2009-11-22 00:25:31 -08:00
Love Hörnquist Åstrand
9eedf9e4f3 don't set unused variables
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24873 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-27 03:34:06 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
8d40c2994b check return value of alloc functions, from Charles Longeau
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21745 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-07-31 16:11:25 +00:00
Love Hörnquist Åstrand
e3a5114857 (mit_prop_dump): close fd when done processing
Coverity NetBSD CID#1955


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17011 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-07 18:53:45 +00:00
Love Hörnquist Åstrand
0c2369acd0 Wrap hdb_entry with hdb_entry_ex, patch originally from Andrew Bartlet
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16378 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-12-12 12:40:12 +00:00
Love Hörnquist Åstrand
7132a9b084 Merge in the libkdc/kdc configuration split from Andrew Bartlet <abartlet@samba.org>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15529 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-30 01:03:35 +00:00
Love Hörnquist Åstrand
683bbc3149 (mit_prop_dump): cast argument to krb5_parse_principal to avoid warning
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15346 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-02 09:55:43 +00:00
Love Hörnquist Åstrand
6e8d98b9be rename KRB5_TL_MOD_PRINC to mit_KRB5_TL_MOD_PRINC to hint its a
constant originating from mit codebase


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15344 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-02 08:16:17 +00:00
Johan Danielsson
fe0b167c46 handle all sorts of weird MIT salt types
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8916 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-08-09 09:57:37 +00:00
Johan Danielsson
b50c8c78a8 set initial master key version number to 0 instead of 1; if we lated
bump the mkvno we don't risk using the wrong key to decrypt


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8556 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-07-05 19:44:34 +00:00
Johan Danielsson
d3c2873bcf read MIT krb5 dump files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8554 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-07-05 19:30:46 +00:00