Commit Graph

72 Commits

Author SHA1 Message Date
Luke Howard
c953bc5e79 krb5: reintroduce deprecated krb5_addlog_func()
krb5_addlog_func() is used by Samba to obtain Kerberos log messages
and place them into the Samba logs.

Providing a hook down to the heim_addlog_func() is less disruptive
than needing to call multiple different APIs as Samba compiles
both with an included copy of Heimdal and against a system
Heimdal (when not an AD DC).

This API was deprecated and stubbed out in March 2020 by ea90ca8 and was
previously stable until 0c86917 (which looks like it should have been part of
e44c680).

Despite the need for the extra argument, which we add a test for, Samba would
prefer to keep the krb5_addlog_func() facility, so this adds it back.

Signed-off-by: Andrew Bartlett abartlet@samba.org
2021-08-09 23:27:22 +10:00
Nicolas Williams
2036b431dc krb5: Expose trace functions 2020-10-27 13:30:57 -05:00
Nicolas Williams
983ed75295 krb5: Add krb5_set_log_dest() 2020-09-07 22:04:59 -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
Roland C. Dowdeswell
fb9a78223c We stop strnvisx(3)ing logs to FILE: by default.
Our logging framework used to strnvisx(3) each and every line
iff it is written to a FILE.  This is often unhelpful because
the line usually contains a number of elements that have already
been quoted and it makes the logs much more difficult to read in
this case.  An example if krb5_unparse_name() which will already
quote most characters that one cares about.

We change the behaviour to simply drop unprintable characters
rather than encoding them.  We thus rely on the rest of the
code to properly encode data elements written into the logs.
2019-12-05 00:05:56 -05:00
Roland C. Dowdeswell
84ffa22c93 Add an "EFILE:" target for logging.
This target will write to a file IFF it exists.
2019-11-10 17:47:36 -05:00
Roland C. Dowdeswell
e44c680d8e Make logging path definitions subject to token expansion. 2019-11-10 17:47:36 -05:00
Roland C. Dowdeswell
c7d4682aed Define log levels in docs and change default to 0-3.
We define the meaning of the various log levels in the man page
for krb5_openlog(3).  If logging configured and levels are not
specified, we change the default levels to 0-3 which should exclude
debugging messages which are generally only desired in exceptional
circumstances.

We also go through the KDC and adjust the levels to be appropriate.
2019-10-21 13:43:01 +01:00
Nicolas Williams
6a0f45c4d7 Use __attribute__ ((__name__)) form
Protect against macros named noreturn and so on.
2017-03-13 18:39:41 -04:00
Nicolas Williams
0306d70a91 Add --debug option to kgetcred 2015-04-13 16:59:20 -05:00
Jelmer Vernooij
70e43e9808 Fix some typos. 2014-04-25 02:42:17 +02: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
Love Hornquist Astrand
124ab6957c plug memory leak 2013-04-24 20:17:01 -07:00
Roland C. Dowdeswell
f0f07ff408 Use krb5_enomem() more consistently in lib/krb5. 2013-02-13 16:15:00 +08:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Asanka Herath
5dcc605f6b Fix calling conventions for Windows 2010-08-20 13:14:10 -04:00
Love Hornquist Astrand
0b2b9d9834 catch error from as.*printf 2010-05-30 14:12:39 -07: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
926583be1e add _krb5_have_debug 2009-11-22 00:14:33 -08:00
Love Hornquist Astrand
5a3630ba00 Add _krb5_log() used for internal logging 2009-09-07 20:22:14 -07:00
Love Hornquist Astrand
51fbbf93e3 (log_file): use strvisx rightly 2009-07-19 17:52:53 -07:00
Love Hörnquist Åstrand
2b54af87e9 Add paranoid printing using strvisx.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25332 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-07-15 23:31:55 +00: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
dddee52c0d N_()ify
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23787 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-07 21:28:19 +00:00
Love Hörnquist Åstrand
f05f1107ce catch error and return error from krb5_openlog().
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23505 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-08-11 10:00:24 +00:00
Love Hörnquist Åstrand
a165b922e8 set log file close on exec
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23443 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-27 12:07:25 +00:00
Love Hörnquist Åstrand
7fcd266fdd use krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23316 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 04:32:32 +00:00
Love Hörnquist Åstrand
25514c9c3d use krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23295 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 03:28:37 +00:00
Love Hörnquist Åstrand
473532da2a update (c)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19088 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-21 08:08:46 +00:00
Love Hörnquist Åstrand
b24395ffde (log_file): reset pointer to freed memory
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17214 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-24 15:09:27 +00:00
Love Hörnquist Åstrand
9be36e4522 (krb5_addlog_dest): free fn in case of error
Coverity, NetBSD CID#1882


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17038 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-10 09:41:26 +00:00
Love Hörnquist Åstrand
1708cc306c (krb5_addlog_dest): make string length match strings in strcasecmp.
Found by IBM checker.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16928 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-02 00:22:08 +00:00
Love Hörnquist Åstrand
7ab97d06cc rename variable time to timestr to avoid shadowing
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15468 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-17 04:25:05 +00:00
Love Hörnquist Åstrand
9176b9b05c rename close and log to avoid shadow warnings
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15391 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-15 03:14:05 +00:00
Love Hörnquist Åstrand
4fcc39ccbc (krb5_closelog): free all content in krb5_log_facility
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15364 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-11 00:14:28 +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
6e10f776c4 (log_realloc): increase len after realloc returns sucessfully
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12841 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-09-17 23:56:14 +00:00
Johan Danielsson
45cc9bab8d (krb5_vlog_msg): delay message formating till we know we need it
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11399 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-09-05 14:59:14 +00:00
Johan Danielsson
066ef11056 rename syslog_data to avoid name conflicts (from Mattias Amnefelt)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11148 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-08-20 09:49:09 +00:00
Johan Danielsson
6c5b4ca76c constify
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10914 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-04-18 09:19:44 +00:00
Johan Danielsson
23b57ae3cc (krb5_addlog_dest): reorganise syslog parsing
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10904 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-04-17 14:42:20 +00:00
Johan Danielsson
e59f3e6a3f (krb5_closelog): don't pass pointer to pointer (from Gombas Gabor)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10818 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-02-04 10:48:33 +00:00
Assar Westerlund
d27aa3b62e add some krb5_{set,clear}_error_string
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9937 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-05-14 06:14:52 +00:00
Assar Westerlund
b1c3af9c5c (krb5_vlog_msg): fix const-ness
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9057 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-09-17 21:46:07 +00:00
Assar Westerlund
e97f681ee5 (krb5_vlog_msg): log just the format string it we fail to allocate the
actual string to log, should at least provide some hint as to where
things went wrong


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9029 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-09-10 14:11:41 +00:00
Assar Westerlund
ce07d85131 (syslogvals): static-ize
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8992 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-08-24 22:23:30 +00:00