122 Commits

Author SHA1 Message Date
Jeffrey Altman
07ee8fd3f4 base|krb5: struct krb5_config_binding is public
ea90ca8666
("Move some infra bits of lib/krb5/ to lib/base/ (2)") introduced
struct heim_config_binding to heimbase.h and removed the
struct krb5_config_binding definition from krb5.h.  It changed
the krb5_config_binding typedef to be based upon the heim_config_binding
typedef.

These changes broke out of tree callers of krb5_config_get_list()
and krb5_config_vget_list().  The internals of struct krb5_config_binding
are required by callers of krb5_config_get_list() and krb5_config_vget_list()
and the names must remain the same.

This change restores struct krb5_config_binding to krb5.h.  The
structure cannot be changed because it is public and leaves struct
heim_config_binding as an independent structure definition within
heimbase.h.  As a result struct heim_config_binding in heimbase.h must
remain binary compatible until such time as krb5_config_get_list() and
krb5_config_vget_list() are no longer supported.

Change-Id: I69b4fda3f656cc8daa8f5fcd0c7151cee222fc8c
2020-05-31 00:02:34 -05:00
Nicolas Williams
ea90ca8666 Move some infra bits of lib/krb5/ to lib/base/ (2)
This is the second of two commits in a series that must be picked together.

This series of two commits moves parts of lib/krb5/ infrastructure
functionality to lib/base/, leaving behind wrappers.

Some parts of libkrb5 are entirely generic or easily made so, and could
be useful in various parts of Heimdal that are not specific to the krb5
API, such as:

 - lib/gssapi/  (especially since the integration of NegoEx)
 - lib/hx509/
 - bx509d       (which should really move out of kdc/)

For the above we need to move these bits of lib/krb5/:

 - lib/krb5/config_file.c   (all of it, leaving forwardings behind)
 - lib/krb5/config_reg.c    (all of it)
 - lib/krb5/plugin.c        (all of it, leaving forwardings behind)
 - lib/krb5/log.c           (all of it, ditto)
 - lib/krb5/heim_err.et     (all of it)

And because of those two, these too must also move:

 - lib/krb5/expand_path.c   (all of it, leaving forwardings behind)
 - lib/krb5/warn.c          (just the warning functions, ditto)

The changes to the moved files are mostly quite straightforward and are
best reviewed with --word-diff=color.

We're also creating a heim_context and a heim API to go with it.  But
it's as thin as possible, with as little state as necessary to enable
this move.  Functions for dealing with error messages use callbacks.

Moving plugin.c does have one knock-on effect on all users of the old
krb5 plugin API (which remains), which is that a global search and
replace of struct krb5_plugin_data to struct heim_plugin_data was
needed, though the layout and size of that structure doesn't change, so
the ABI doesn't either.

As well, we now build lib/vers/ and lib/com_err/ before lib/base/ so as
to be able to move lib/krb5/heim_err.et to lib/base/ so that we can make
use of HEIM_ERR_* in lib/base/, specifically in the files that moved.

Once this is all done we'll be able to use config files and plugins in
lib/hx509/, we'll be able to move bx509d out of kdc/, and so on.

Most if not all of the new functions in lib/base/ are Heimdal-private,
thus calling conventions for them are not declared.

Status:

 - builds and passes CIs (Travis, Appveyor)
 - ran make check-valgrind and no new leaks or other memory errors
 - ready for review

HOW TO REVIEW:

     $ # Review file moves:
     $ git log --stat -n1 HEAD^
     $
     $ # Review changes to moved files using --word-diff=color
     $ git log -p -b -w --word-diff=color HEAD^..HEAD   \
               lib/base/config_file.c                   \
               lib/base/config_reg.c                    \
               lib/base/expand_path.c                   \
               lib/base/warn.c                          \
               lib/krb5/config_file.c                   \
               lib/krb5/config_reg.c                    \
               lib/krb5/expand_path.c                   \
               lib/krb5/warn.c
     $
     $ # Review the whole thing, possibly adding -b and/or -w, and
     $ # maybe --word-diff=color:
     $ git log -p origin/master..HEAD
     $ git log -p -b -w origin/master..HEAD
     $ git log -p -b -w --word-diff=color origin/master..HEAD

TBD (future commits):

 - make lib/gssapi use the new heimbase functions
 - move kx509/bx509d common code to lib/hx509/ or other approp. location
 - move bx509d out of kdc/
2020-03-02 10:56:13 -06:00
Nicolas Williams
b2823cbd74 Move some infra bits of lib/krb5/ to lib/base/ (1)
This is the first of two commits in a series that must be picked
together.

This series of two commits moves parts of lib/krb5/ infrastructure
functionality to lib/base/, leaving behind wrappers.

This commit only renames files to enable git log/diff/blame to follow
the renames: to help future code archeology, and to make reviewing these
two commits easier.

The next commit in this series ensures that the moved files have the
correct content (i.e., defining heim APIs instead of krb5 APIs), and
will create files in lib/krb5 with the same names and krb5 API wrappers
around the new heim API functions.

The next commit also explains the motivation, which, briefly, is to:

 - remove krb5 API usage from lib/gssapi/,
 - enable the use of configuration and plugins in lib/hx509/
   (as well as lib/gssapi/ and future projects),

and

 - enable the further disentanglement of bx509d from kdc/.
2020-03-02 10:56:13 -06:00
Nicolas Williams
620862049e Use roken_get_*() instead of getpwuuid()
Using non-reentrant getpwuid() (or getpwnam(), or getspnam())  can be
dangerous.  We had a report of a login application / PAM that calls
those, and Heimdal, by calling them too, clobbered the cached struct
passwd used by the login app / PAM.
2018-12-25 22:11:19 -06:00
Andreas Schneider
ce2df481b7 Fix size types
This fixes compilation with -Wstrict-overflow=2

with CFLAGS="-O3 -Werror=strict-overflow -Wstrict-overflow=2"
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) gives:

config_file.c: In function ‘krb5_config_vget_strings’:
config_file.c:1122:10: warning: assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow]
     while(nstr--)
          ^

Upstream pull request:
https://github.com/heimdal/heimdal/pull/354

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(similar to Samba commit 72979d1d60ca2eab1e7903c2e77b8cca69667691,
cut down to just the config_file.c and keytab_any.c changes reproduced
above by abartlet)
2018-12-20 12:52:12 +11:00
Daria Phoebe Brashear
0f5486eafc krb5: don't include plist support unless CoreFoundation is present
depending what's available when you compile for iOS it's possible to
be __APPLE__ and not have CF; actually test for it instead of blythely
assuming it can be used
2017-10-30 18:41:22 -04:00
Nicolas Williams
7dfad1ab0b Use secure_getenv() instead of issuid() 2017-04-17 18:02:30 -04:00
Jeffrey Altman
23ee804e9d lib/krb5: krb5_config_parse_file_multi use after free
If the file is not a regular file, the 'fname' buffer will be freed
before it is passed to the krb5_set_error_message() routine.  That
this is true is not obvious from code inspection but 'newfname'
and 'fname' refer to the same memory.

Change-Id: I7780eae9ceaf01b245df488a2f7d7f406770864f
2017-03-18 15:22:33 -04:00
Nicolas Williams
0259f1c449 Fix CR comments on include/includedir 2017-03-10 17:33:12 -05:00
Nicolas Williams
fe43be8558 Add include/includedir directives for krb5.conf 2017-02-27 18:15:59 -06:00
Jeffrey Altman
b7cf5e7caf lib/krb5: do not fail set_config_files due to parse error
Follow Apple's lead and do not fail krb5_set_config_files() simply
because one of the files in the profile list fails to parse correctly.
Doing so can lead to hard to find failures and could lead to an end
user shooting themselves in the foot and no longer be able to login
to their system to fix it.

Parse as many of the files as we can.  Only fail krb5_set_config_files()
if init_context_from_config_file() fails.

Change-Id: I122664c6d707a5f926643808ba414bf4f681f8b8
2016-06-16 16:38:17 -04:00
Jeffrey Altman
832ee39994 YFS Coverity 11034
Change-Id: I5037b7e6d804e6a61e02258927f06d24cc0b2051
2015-04-21 22:18:09 -04:00
Jeffrey Altman
ef8e4da010 only perform dir separator normalization for file paths
Commit ad7e54d698 introduced the use
of _krb5_expand_path_tokens() to expand tokens (and on Windows convert
path delimiters) within credential cache names.  This is safe to do
for the path based credential cache types FILE, DIR and SCC but on
Windows is unsafe for the non-path types.

For example on Windows, the API credential cache names are often based
on the principal name and the principal name is parsed from the ccname.
This practice was introduced with the version v2 ccapi when there was
no method of enumerating the caches from the krb5 library.

This change adds a "filepath" boolean parameter to _krb5_expand_path_tokens()
which is set to TRUE (non-zero) when the input is a file path and FALSE
(zero) when the input is not a file path.  _krb5_expand_path_tokens() will
only perform directory separator normalization on Windows when the
"filepath" parameter is TRUE.

This change is not the preferred solution because it requires that the
library be aware of all credential cache types that use path based
residuals.  The preferred solution would require that the credential cache
implementation indicate whether or not it uses a path based residual.

This change has been implemented using a prefix test and not a change to
struct krb5_cc_ops because existing ccache plugins will not know how to
advertise their use of path based residuals and that path expansion is
safe.

Change-Id: I8135991e8ce69fc5273d381ea9c2078bc2bcd19a
2015-01-07 14:43:19 -05:00
Jeffrey Altman
31a00d6647 ISPATHSEP and ISTILDE macros; Windows portability
Windows treats '\\' and '/' equivalently but we cannot control
the form that will be used by end users.  Introduce ISPATHSEP()
macro which tests only for '/' on UNIX and both on Windows.
Introduce ISTILDE() macro to test for '~'.   When testing for
'/' with strchr() or strrchr() add conditional checks for '\\' on
Windows.

Change-Id: Ia85e698fc88f15a6a71db649db5417f02ef7e5fe
2013-09-10 22:31:38 -04:00
Jeffrey Altman
5f138a16ef libkrb5: Add missing KRB5_LIB_FUNCTION/KRB5_LIB_CALL
KRB5_LIB_FUNCTION and KRB5_LIB_CALL are necessary even on private
functions that are exported.

Change-Id: Iccd0cfe87ff0a9d851e29890e9cb55b3ae517ce1
2013-06-22 21:17:32 -04:00
Roland C. Dowdeswell
f0f07ff408 Use krb5_enomem() more consistently in lib/krb5. 2013-02-13 16:15:00 +08:00
Roland C. Dowdeswell
cc47c8fa7b Turn on -Wextra -Wno-sign-compare -Wno-unused-paramter and fix issues.
We turn on a few extra warnings and fix the fallout that occurs
when building with --enable-developer.  Note that we get different
warnings on different machines and so this will be a work in
progress.  So far, we have built on NetBSD/amd64 5.99.64 (which
uses gcc 4.5.3) and Ubuntu 10.04.3 LTS (which uses gcc 4.4.3).

Notably, we fixed

	1.  a lot of missing structure initialisers,

	2.  unchecked return values for functions that glibc
	    marks as __attribute__((warn-unused-result)),

	3.  made minor modifications to slc and asn1_compile
	    which can generate code which generates warnings,
	    and

	4.  a few stragglers here and there.

We turned off the extended warnings for many programs in appl/ as
they are nearing the end of their useful lifetime, e.g.  rsh, rcp,
popper, ftp and telnet.

Interestingly, glibc's strncmp() macro needed to be worked around
whereas the function calls did not.

We have not yet tried this on 32 bit platforms, so there will be
a few more warnings when we do.
2012-02-20 19:45:41 +00:00
Nicolas Williams
ad7e54d698 Generalize token expansion to allow for context-specific tokens 2011-12-08 13:33:37 -06:00
Nicolas Williams
6aec02f979 Make krb5_kuserok() pluggable and add features (including MIT config compat) 2011-12-08 13:33:36 -06:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
305596d9ad Rename subsystem_DEPRECATED to subsystem_DEPRECATED_FUNCTION(X)
Start to explain what the replacement function is.
Generate the #define/#undef logic in generated header files.
Use gcc style where the deprecation warning is after the prototype.
2011-05-17 23:12:51 -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
Asanka C. Herath
e0e746b1ca Revert use of backslash as an escape for double quote in config strings 2010-12-03 01:12:31 -05:00
Asanka C. Herath
f974c34580 Deal with backslash escaped quotes 2010-11-26 00:35:31 -05:00
Asanka C. Herath
5b91a397f8 Increase KBR5_BUFSIZ to 2048 and use it in config_file.c 2010-11-24 15:33:19 -05:00
Asanka C. Herath
0f853405fe Add missing export and calling convention annotations 2010-11-24 15:32:49 -05:00
Asanka C. Herath
f44925e8a6 Deal with quoted strings when reading lists of config strings 2010-11-24 15:32:12 -05:00
Asanka C. Herath
f159cef78a Rename get_entry() -> _krb5_config_get_entry() 2010-11-24 15:32:11 -05:00
Asanka C. Herath
d247242f63 Windows: Registry based configuration
Load configuration data in the registry into a krb5_config_section.
Each registry key corresponds to a krb5_config_section and each
registry value becomes a bound string value.

The set of values contained in the root Heimdal registry key is
treated as if they were defined in the [libdefaults] section.

E.g. the configuration file:

[libdefaults]
foo = bar

[Foo]
x = y
y = {
  baz = quux
}

is equivalent to the registry keys:

[HKEY_CURRENT_USER\Software\Heimdal]
"foo"="bar"

[HKEY_CURRENT_USER\Software\Heimdal\Foo]
"x"="y"

[HKEY_CURRENT_USER\Software\Heimdal\Foo\y]
"baz"="quux"
2010-11-24 15:32:08 -05:00
Andrew Tridgell
157d60a0eb heimdal: fixed a shadowed variable warning for error_message
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-11-08 22:27:32 -08:00
Love Hornquist Astrand
3798647400 Define HAVE_CFPROPERTYLISTCREATEWITHSTREAM if this is 10.6 or newer 2010-09-08 12:22:12 -07:00
Love Hornquist Astrand
788189805c catch error from as.*printf 2010-05-30 13:28:49 -07:00
Asanka Herath
6d132f1d7d Remove spurious slash when expanding path tokens
Path tokens that expand to directories are expected to end in a slash.
2010-05-26 10:38:42 -04:00
Asanka Herath
67c3295fcb KRB5_DEPRECATED should be prefixed to the declaration 2009-11-26 01:41:57 -05:00
Love Hornquist Astrand
86f4c66efd Merge branch 'master' into wip/win32-port2 2009-11-25 05:41:14 -08:00
Asanka Herath
93445a8133 Don't use Windows specific path tokens in lib/krb5/config_file.c 2009-11-24 10:19:49 -08:00
Asanka Herath
77fee77d0e Use path tokens in krb5_config_parse_file_multi() 2009-11-24 10:16:22 -08:00
Asanka Herath
9d42b10027 (krb5_config_parse_file_multi) Don't leak memory when the path tokens can't be expanded 2009-11-24 10:11:15 -08:00
Asanka Herath
b1063ea8fc Initial Windows port 2009-11-24 10:11:14 -08:00
Love Hornquist Astrand
7f628a0733 deprecated warning 2009-11-22 16:11:25 -08:00
Love Hornquist Astrand
a882971606 remove unused vars 2009-11-22 13:58:42 -08:00
Love Hornquist Astrand
afe4f3129b Read configuration plist on macs 2009-11-22 12:31:56 -08:00
Love Hornquist Astrand
4bcc97bd09 doxygen fix vget_time uses args 2009-09-01 12:44:23 -07:00
Love Hornquist Astrand
30f13f0d5b doxygen fix get_strings uses ... 2009-09-01 12:43:50 -07:00
Love Hornquist Astrand
31871b4990 deifne KRB5_DEPRECATED 2009-08-25 14:35:42 -07:00
Love Hornquist Astrand
400cc459fa deprecate krb5_config_parse_string_multi 2009-08-24 20:24:41 -07:00
Love Hornquist Astrand
46b48bc3e7 Document time function, krb5_config_parse_string_multi is not used 2009-08-24 19:52:10 -07:00
Love Hornquist Astrand
850f9be110 fix docxygen errors 2009-08-19 16:35:14 -07:00
Love Hornquist Astrand
bb381aaebf document krb5_config_*_{list,bool} 2009-08-18 18:35:05 +02:00
Love Hornquist Astrand
0c5eeab318 move functions to private space that have no external consumers 2009-08-18 16:29:28 +02:00