Commit Graph

45 Commits

Author SHA1 Message Date
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
Luke Howard
803efebca5 krb5, kadm5: refactor plugin API
Refactor plugin framework to use a single list of loaded plugins; add a new
plugin API where DSOs export a load function that can declare dependencies and
export multiple plugins; refactor kadm5 hook API to use krb5 plugin framework.

More information in krb5-plugin(7).
2019-01-03 20:06:27 -06:00
Luke Howard
6ce1aa84c5 Remove rk_getpw*_r() functions 2018-12-25 22:11:19 -06: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
Viktor Dukhovni
bb895bdd90 Fix k5login_authoritative
In the previous implementation when .k5login or .k5login.d existed
and k5login_authoritative was false, no further plugins were tried.
Also when k5login_authoritative was true and .k5login did not match,
the directory was never tried.
2014-01-08 21:46:06 -05: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
Jeffrey Altman
8257cc2232 Plugin functions should be KRB5_LIB_CALL
Plugin functions should be KRB5_LIB_CALL for speed on Windows.

Change-Id: Iaa4dcf73fd2e29e3f95feede5217eac4eaded4e2
2012-03-13 23:56:11 -04:00
Nicolas Williams
6dd66df594 Make master build on Windows
Add strtoll()/strtoull() to lib/roken
    Add stdint.h to lib/roken (Windows only)
    Add logic to detect whether to use lib/roken's stdint.h based on
        Visual Studio version
    Add include of stdint.h in generated ASN.1 code
    Export missing symbols for 64-bit integers in lib/asn1
    Export missing symbols for FAST
    Add missing sources to kdc/NTMakefile
    Fix issue in kuserok
    Fix bsearch issues
2012-01-17 12:10:14 -06:00
Nicolas Williams
4630ef1bdc Fix kuserok.c:check_owner_file(), make tests/kdc/check-authz run 2011-12-14 18:01:35 -06:00
Love Hornquist Astrand
d453899462 split user and dir, use rk_getpwnam_r 2011-12-12 21:53:41 -08:00
Love Hornquist Astrand
167084b3e7 ident 2011-12-12 21:28:52 -08:00
Nicolas Williams
3109770484 Address code review comments (use _krb5_homedir_access()) 2011-12-10 14:06:09 -06:00
Nicolas Williams
b9f8e6d956 Add DENY rule for krb5_kuserok() and update manpage 2011-12-08 13:34:02 -06: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
1b88a3b6c7 Only does implicit matching for first component, reported by Harry Coin 2011-10-14 00:33:57 +02:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
aa7385ea96 propper quoting for doxygen 2010-06-14 20:39:40 -07:00
Asanka Herath
154de6b3a3 krb5_kuserok() only does the local principal test on Windows
Remove the other tests for now.  The file and directory access checks must be
made against the respective DACLs.
2010-05-26 10:38:39 -04:00
Love Hornquist Astrand
f3ea26c759 remove unused variable 2010-01-08 12:58:20 +01:00
Asanka Herath
a0ae9f5a0e Merge remote branch 'h-github/master' into win32-port2
* h-github/master: (64 commits)
  refix socket wrappers with rk_
  Patch from Secure Endpoints/Asanka Herath for windows support
  unset KRB5CCNAME
  its really just LIBADD more most of them
  correct quoting
  Use -lpthread for modern freebsd instead
  clean KRB5CCNAME and KRB5_CONFIG, require test to reset them
  more up ${env_setup}
  use PTHREADS_LIBADD for freebsd6 and newer
  add PTHREAD_LIBADD
  add PTHREAD_LIBADD
  add PTHREAD_LIBADD
  switch to PTHREADS_LIBADD
  log what the error string say too
  More debug logging
  sprinkle more 'echo "test failed"'
  sprinkle 'echo "test failed"'
  use calloc(), indent more prettier
  in sh, equal compare is really = for strings, not ==
  Check for duplicates, already loaded mechs
  ...

Conflicts (resolved):
	lib/krb5/auth_context.c
	lib/krb5/changepw.c
	lib/krb5/context.c
	lib/krb5/error_string.c
	lib/krb5/kuserok.c
	lib/krb5/libkrb5-exports.def.in
	lib/krb5/net_write.c
	lib/krb5/store_fd.c
	lib/krb5/test_cc.c
	lib/roken/strerror_r.c
2009-12-21 13:44:00 -05:00
Love Hornquist Astrand
687db64c56 Patch from Secure Endpoints/Asanka Herath for windows support 2009-12-21 08:45:28 +01:00
Love Hornquist Astrand
2204b852a7 Merge branch 'master' into wip/win32-port2 2009-11-24 21:46:10 -08:00
Asanka Herath
d00f9984a5 Make roken build on windows
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-11-24 21:42:02 -08:00
Asanka Herath
b1063ea8fc Initial Windows port 2009-11-24 10:11:14 -08:00
Love Hornquist Astrand
850f9be110 fix docxygen errors 2009-08-19 16:35:14 -07:00
Love Hornquist Astrand
90bbf03216 Document krb5_kuserok() 2009-08-18 13:25:30 +02:00
Love Hörnquist Åstrand
942a821fab remove RCSID
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25171 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-04 06:17:40 +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
ffd78392d3 close-on-exec
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23449 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-27 12:09:39 +00:00
Love Hörnquist Åstrand
326478ac32 (check_directory): use passed directory name
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16048 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-09-09 10:33:33 +00:00
Love Hörnquist Åstrand
23f6210e8f (krb5_kuserok): use POSIX_GETPWNAM_R instead of HAVE_GETPWNAM_R
From: Dave Love <d.love@dl.ac.uk>


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15103 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-05-09 15:41:45 +00:00
Johan Danielsson
67b2fd15f7 check the user's ~/.k5login.d directory for access files, all of which
is handled like the regular ~/.k5login


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15083 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-05-04 12:11:22 +00:00
Love Hörnquist Åstrand
dd3ec19f74 use asprintf to avoid truncating pathnames
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14856 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-04-19 18:59:46 +00:00
Love Hörnquist Åstrand
796e0562a0 use getpwnamn_r if it exists
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14842 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-04-19 05:23:42 +00:00
Johan Danielsson
8964d4ead4 if a .k5login file exist, don't give implicit rights to anyone; also
check owner/mode of .k5login


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14132 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-08-19 15:31:40 +00:00
Love Hörnquist Åstrand
91351971f7 add KRB5_LIB_FUNCTION to all exported functions
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13863 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-05-25 21:46:46 +00:00
Love Hörnquist Åstrand
175d6d3dbf (krb5_kuserok): preserve old behviour of function and return FALSE
when there isn't a local account for `luser'.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11707 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-03-13 19:53:43 +00:00
Jacques A. Vidrine
d29f4a9e27 Use strcspn to convert the newline to NUL in fgets results.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11462 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-09-16 17:32:11 +00:00
Johan Danielsson
c5b916ca6f remove advertising clause
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7464 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-12-02 17:05:13 +00:00
Assar Westerlund
0d3b242182 (krb5_kuserok): use `krb5_get_default_realms'
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7047 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-09-28 02:26:39 +00:00
Johan Danielsson
5a32a5c8e7 Add copyright notice.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2389 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-07-16 21:40:05 +00:00
Assar Westerlund
bf07fd8e27 something
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1983 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-07-06 21:36:45 +00:00
Assar Westerlund
e41b631fb9 new file
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1978 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-07-06 21:05:20 +00:00