Tom Yu [Fri, 14 Jan 2005 06:02:01 +0000 (06:02 +0000)]
* authgss_prot.c (xdr_rpc_gss_wrap_data): Use xdr_alloc to avoid
size limit issues. Use (unsigned int)-1 instead of MAX_NETOBJ_SZ.
(xdr_rpc_gss_unwrap_data): Use (unsigned int)-1 instead of
MAX_NETOBJ_SZ.
* xdr.c (xdr_bytes): Don't assign from *sizep if XDR_FREE, since
it'll be uninitialized then. Shuts up Purify.
Ken Raeburn [Fri, 14 Jan 2005 05:03:48 +0000 (05:03 +0000)]
* k5-thread.h (k5_pthread_assert_locked): Only call pthread_equal if
thread support is loaded.
(k5_pthread_mutex_unlock): Use k5_pthread_assert_locked instead of
duplicating it.
Ken Raeburn [Fri, 14 Jan 2005 03:24:48 +0000 (03:24 +0000)]
* yarrow.c (yarrow_reseed_locked): Renamed from krb5int_yarrow_reseed and made
static.
(Yarrow_detect_fork, yarrow_input_maybe_locking, krb5int_yarrow_output_Block):
Call it.
(krb5int_yarrow_reseed): New function, grabs lock and calls the old version.
(krb5int_yarrow_final): Hold the lock until after clearing the Yarrow context
data.
Ken Raeburn [Fri, 14 Jan 2005 03:19:39 +0000 (03:19 +0000)]
More paranoid checking...
* k5-thread.h (k5_os_mutex) [pthread case]: Add new field "owner" if
DEBUG_THREADS.
(k5_pthread_mutex_lock, k5_pthread_mutex_unlock, k5_pthread_assert_locked): New
macros/functions; if DEBUG_THREADS, set or check the owner field.
(K5_OS_MUTEX_PARTIAL_INITIALIZER) [pthread case && DEBUG_THREADS]: Set the
owner field. If PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP is defined, use it.
(k5_os_mutex_lock, k5_os_mutex_unlock, k5_os_mutex_assert_locked) [pthread
case]: Use k5_pthread_ versions.
(k5_mutex_destroy): Update the location data with the mutex locked, before
destroying it.
(k5_mutex_unlock): Update the location data while the mutex is still locked,
and check the assertion that the mutex really is locked. Convert inline
function to macro.
Jeffrey Altman [Thu, 13 Jan 2005 11:51:30 +0000 (11:51 +0000)]
correction to previous commit. do not call krb5_gss_release_cred()
if the cred was not acquired. destroy each field of the cred one
piece at a time based upon what was allocated.
Ken Raeburn [Wed, 12 Jan 2005 18:24:44 +0000 (18:24 +0000)]
* default.exp (start_tail): New proc. Handles GNU tail race condition with
less delay than the old code that was in start_kerberos_daemons.
(start_kerberos_daemons): Call start_tail for both log files.
Ken Raeburn [Wed, 12 Jan 2005 01:06:04 +0000 (01:06 +0000)]
* gc_frm_kdc.c (krb5_get_cred_from_kdc_opt): Free credentials retrieved from
ccache before returning. Based on patch from fumihiko kakuma
<kakuma@valinux.co.jp>. Also whitespace changes for readability.
Ken Raeburn [Sun, 9 Jan 2005 06:03:56 +0000 (06:03 +0000)]
* k5-thread.h (KRB5_CALLCONV, KRB5_CALLCONV_C): Define if not defined.
(krb5int_mutx_lock_update_stats, krb5int_mutex_unlock_update_stats,
krb5int_mutex_report_stats) [!DEBUG_THREADS_STATS]: Declare, with KRB5_CALLCONV.
(k5_debug_make_loc): Change "lineno" to type int.
(k5_debug_make_loc): Likewise for argument "line".
Jeffrey Altman [Wed, 5 Jan 2005 07:51:46 +0000 (07:51 +0000)]
Add new function krb5_boolean krb5_is_thread_safe(void) to library.
This function simply reports whether or not ENABLE_THREADS was specified
at compile time. It is meant to be used by applications which need to
know whether or not multithread libraries must be initialized OR
whether or not calls to Kerberos library functions from multi-threaded
applications must be protected by an application global mutex.
Ken Raeburn [Mon, 3 Jan 2005 19:30:18 +0000 (19:30 +0000)]
krb5_parse_name not thread-safe, not responsive to environment changes
As Ezra noted, krb5_parse_name saves away the default realm the first
time it looks it up, and will never look it up again, even if the
config file has changed, the context isn't the same one, etc. It also
used a static variable which wasn't thread-safe.
With this patch, we still won't catch changes in the config file
specification after the default realm has been looked up for a given
krb5_context, because it's cached in the context too, but this will at
least be more responsive, and thread safe.
* parse.c (krb5_parse_name): Don't cache the default realm name.
Ken Raeburn [Thu, 30 Dec 2004 22:08:18 +0000 (22:08 +0000)]
run "make depend"
In most library directories, this just affects where the line breaks
are. In most other directories, it's just dropping a trailing blank
line. One or two files really do have updated dependencies.
Ken Raeburn [Thu, 30 Dec 2004 22:05:12 +0000 (22:05 +0000)]
Do the target object file name hacking in "make depend" earlier, before the
line breaks are recomputed, instead of after. This will result in lots of
whitespace changes in dependencies in directories that build library object
files, but the final output is nicer (fewer long lines), and running "make
depend" uses one fewer invocation of sed (balancing out the extra one I added
in another checkin earlier today).
* config/post.in (.depend): Don't do target name munging here.
(.depfix2.sed): Pass extra value $(STLIBOBJS).
* util/depfix.sed: Don't change foo.o to $(OUTPRE)foo.$(OBJEXT) here.
* util/depgen.sed: Add new argument for STLIBOBJS. Do the OUTPRE/OBJEXT
substitution here, and if STLIBOBJS is non-empty, add foo.so and foo.po while
we're at it.
Ken Raeburn [Thu, 30 Dec 2004 21:12:41 +0000 (21:12 +0000)]
* post.in (.depend): Delete blank lines in generated file.
(DEP_CFG_VERIFY, DEP_VERIFY, depend-verify-*, .depend-verify-*, .depfix2.sed):
Move all the flag files to $(BUILDTOP) so there'll be only one of each.
Ezra Peisach [Sat, 25 Dec 2004 15:29:39 +0000 (15:29 +0000)]
Memory leaks in ccache due to thread integration
* cc_file.c (krb5_fcc_close): Free the cache id.
(dereference): When removing fcc_set entry from list, free the
pointer as well.
The first was accidently dropped in the dereference code writing.
The cache id pointer is never freed.
The second error is the removal of the krb5_fcc_data from the linked list.
The fcc_set is removed from the chain, but the memory for the removed fcc_set
is never freed.
Ken Raeburn [Fri, 17 Dec 2004 23:58:47 +0000 (23:58 +0000)]
can't build shared libraries on sparc64-netbsd
Current trunk code fails to build shared libraries on sparc64-netbsd
because the generated relocations with -fpic don't have the range
necessary. In general, any platform with sparc support that we want
to build for should use -fPIC instead of -fpic, with gcc. (I haven't
checked whether openbsd or freebsd support sparc these days; I think
they're the only ones in our shlib.conf that we might care about.)
* shlib.conf (*-*-netbsd*): Use -fPIC instead of -fpic, which won't work on
sparc64 at least.
Jeffrey Altman [Thu, 16 Dec 2004 19:57:17 +0000 (19:57 +0000)]
2004-12-16 Jeffrey Altman <jaltman@mit.edu>
* cc_mslsa.c:
Temporarily deactivate support for KerbSubmitTicketMessage
and KerbQueryTicketCacheEx2Message until the new Platform SDK
becomes publicly available.
Jeffrey Altman [Wed, 15 Dec 2004 08:25:28 +0000 (08:25 +0000)]
2004-12-15 Jeffrey Altman <jaltman@mit.edu>
* cc_mslsa.c:
- Activate support for KerbSubmitTicketMessage
- Activate support for KerbQueryTicketCacheEx2Message
- Add locale support for regions which use MultiByte characters
Ken Raeburn [Wed, 15 Dec 2004 03:02:43 +0000 (03:02 +0000)]
insufficient locking in profile re-reading case
If profiles are open and iterators in use while the on-disk file is being
modified (see tests/threads/prof1.c), the re-reading of the file can cause data
to be freed up. The iterator code does no locking and assumes that the profile
node tree won't be touched.
During our Monday meeting we discussed changing the iterator code to "snapshot"
the current state of the file if it were modified, so that a more consistent
picture could be returned, essentially by bumping a reference count for the
life of the iterator object. The reference count I was thinking of turns out
to be used for a different purpose; we'd have to add another layer of
indirection, another ref count, and another mutex to accomplish this. There
might be a more reasonable way to go about it, but I don't want to tackle it
for 1.4 when we're already shipping beta releases.
This patch just adds locking to the current iterator code so that the file data
can't be replaced while the iterator is being processed. The inconsistent-view
issue remains.
* prof_tree.c (profile_node_iterator): When the iterator has a current file,
lock it, and unlock it before changing it or returning.
ticket: new
status: resolved
target_version: 1.4
tags: pullup
Ken Raeburn [Wed, 8 Dec 2004 06:04:49 +0000 (06:04 +0000)]
* include/k5-int.h (struct _krb5int_access): Add function pointer field
use_dns_kdc.
* lib/krb5/os/accessor.c (krb5int_accessor): Set new field use_dns_kdc.
* lib/krb4/RealmsConfig-glue.c (krb_get_krbhst): Check if DNS should be used
for getting KDC names before actually using it.
Ken Raeburn [Mon, 6 Dec 2004 22:00:26 +0000 (22:00 +0000)]
hooks for recording statistics on locking behavior
Finish the hooks (left disabled by default) for logging somewhere the recorded
timing behavior relating to the use of locks in the krb5 code.
Currently, "reporting" means writing to /dev/tty or stderr, and the data is the
number of times a mutex is locked, file and line where it was created,
min/avg/max/stddev wait times to acquire the lock and hold times, and stats are
only written out for locks that were locked a certain minimum number of times
and with a minimum average wait time.
The criteria are all controlled in threads.c, and k5-thread.h just has the
hooks for gathering data. So turning on/off the data gathering requires a full
rebuild, but tweaking the reporting is mostly just a relinking pass. (May also
require adding a dependence on the math library to the support library; for a
static build that may impact a lot of makefiles.)
* include/k5-thread.h [DEBUG_THREADS_STATS]: Include string.h and inttypes.h.
(get_current_time) [DEBUG_THREADS_STATS]: Define as inline.
(k5_mutex_init_stats) [DEBUG_THREADS_STATS]: Save away current time as creation
time.
(k5_mutex_stats_tmp): New typedef, k5_debug_time_t if recording stats, dummy
int otherwise.
(k5_mutex_stats_start): New macro, get current time if recording, zero
otherwise.
(krb5int_mutex_lock_update_stats, krb5int_mutex_unlock_update_stats,
krb5int_mutex_report_stats) [DEBUG_THREADS_STATS]: Declare.
(krb5int_mutex_report_stats) [! DEBUG_THREADS_STATS]: New macro, does nothing.
(k5_mutex_lock_update_stats, k5_mutex_unlock_update_stats): New macros, map to
krb5int_ functions if recording, dummy statements otherwise.
(k5_mutex_destroy): Call krb5int_mutex_report_stats.
(k5_mutex_lock, k5_mutex_lock_1): Call k5_mutex_stats_start and
k5_mutex_lock_update_stats.
(k5_mutex_unlock_1): Call k5_mutex_unlock_update_stats.
* util/support/threads.c [DEBUG_THREADS_STATS]: Include stdio.h.
(stats_logfile) [DEBUG_THREADS_STATS]: New variable.
(krb5int_thread_support_init) [DEBUG_THREADS_STATS]: Set it to point to a file
on /dev/tty or stderr.
(krb5int_thread_support_fini) [DEBUG_THREADS_STATS]: Flush it.
(k5_mutex_lock_update_stats, krb5int_mutex_unlock_update_stats, get_stddev,
krb5int_mutex_report_stats) [DEBUG_THREADS_STATS]: New functions.
* util/support/libkrb5support.exports: Add krb5int_mutex_*_stats.
Ken Raeburn [Wed, 24 Nov 2004 02:39:44 +0000 (02:39 +0000)]
fix missing locking in keytab; fix stdio handling too
The keytab type list lock was implemented, but I missed the per-keytab lock.
Since I was in there, I ripped out the bogus stdio buffer mangling that the
code was doing, and set up a buffer to be used that we can sanitize later.
* kt_file.c (struct _krb5_ktfile_data): Add mutex and buffer.
(KTFILEBUFP, KTLOCK, KTUNLOCK, KTCHECKLOCK): New macros.
(krb5_ktfile_resolve): Initialize mutex.
(krb5_ktfile_close): Zap data buffer before freeing.
(krb5_ktfile_get_entry, krb5_ktfile_start_seq_get, krb5_ktfile_get_next,
krb5_ktfile_end_get, krb5_ktfile_add, krb5_ktfile_remove): Lock and unlock the
mutex.
(krb5_ktfileint_open): Check that the mutex is locked. Set the stdio buffer to
the new buffer in the ktfile data.
(krb5_ktfileint_write_entry, krb5_ktfileint_find_slot): Check that the mutex is
locked. Don't call setbuf. Flush the stdio buffer after writing.
Tom Yu [Wed, 24 Nov 2004 01:28:03 +0000 (01:28 +0000)]
set errno=0 prior to fopen in kt_file
* kt_file.c (krb5_ktfileint_open): Update previous change by
explicitly setting errno=0 prior to calling fopen(). Also, return
EMFILE, not ENFILE, for compatibility with Solaris 8, which does
set errno when out of file descriptors.
Ken Raeburn [Tue, 23 Nov 2004 03:15:12 +0000 (03:15 +0000)]
KDC on Tru64 was hanging because of another case where Yarrow code
assumes locks are recursive. Probably didn't trigger on Linux,
Solaris, or NetBSD because they have /dev/random and Tru64 does not.
* yarrow.c (yarrow_input_maybe_locking): Renamed from
yarrow_input_maybe_locking, made static. New argument indicates whether or not
to do locking.
(krb5int_yarrow_input): New wrapper function.
(yarrow_input_locked): New wrapper function.
(Yarrow_detect_fork): Call yarrow_input_locked.
Ken Raeburn [Fri, 19 Nov 2004 22:12:50 +0000 (22:12 +0000)]
* locate_kdc.c (krb5int_add_host_to_list): If debugging, log the requested
family and socket type. If AI_NUMERICSERV is defined, set it in ai_flags. If
getaddrinfo returns an error with debugging enabled, log the error.
(krb5_locate_srv_conf_1): When logging an error from add_host_to_list, include
the corresponding error string.
* t_locate_kdc.c: Include port-sockets.h, instead of sys/socket.h, netdb.h,
netinet/in.h, and arpa/inet.h.
* Makefile.in ($(OUTPRE)t_locate_kdc.exe): New target.
Ken Raeburn [Fri, 19 Nov 2004 21:09:45 +0000 (21:09 +0000)]
* fake-addrinfo.c (HAVE_GETADDRINFO, HAVE_GETNAMEINFO)[_WIN32]: Don't define
here.
(protoname): Handle IPPROTO_IGMP.
(debug_dump_addrinfo_args): Update for current interfaces to socktypename and
familyname.
Tom Yu [Fri, 19 Nov 2004 20:36:45 +0000 (20:36 +0000)]
* aclocal.m4 (KRB5_AC_PRIOCNTL_HACK): Check for Solaris patch
117171-11 (sparc) or 117172-11 (x86), which fixes the Solaris 9
bug which can cause final pty output to be on close.
Ken Raeburn [Tue, 16 Nov 2004 05:04:56 +0000 (05:04 +0000)]
Create a ccache get-flags operation.
The MSLSA and CCAPI versions are untested!
* cc_file.c (krb5_fcc_get_flags): New function.
(krb5_fcc_ops, krb5_cc_file_ops): Add it.
* cc_memory.c (krb5_mcc_get_flags): New function.
(krb5_mcc_ops): Add it.
* cc_mslsa.c (krb5_lcc_get_flags): New function.
(krb5_lcc_ops): Add it.
* ccfns.c (krb5_cc_get_flags): New function.
* ccapi/stdcc.c (krb5_stdcc_get_flags): New function.
(krb5_cc_stdcc_ops): Add it.
* ccapi/stdcc.h (krb5_stdcc_get_flags): Declare.
Ken Raeburn [Mon, 15 Nov 2004 22:16:02 +0000 (22:16 +0000)]
Make static linking not require -lsocket, -lnsl, etc.
Don't duplicate macro definitions.
Header files and comments still need some cleanup.
* cache-addrinfo.h, init-addrinfo.c: New files, split out from fake-addrinfo.c.
* fake-addrinfo.c: Include cache-addrinfo.h.
(FAI_CACHE, struct face, struct fac): Moved to cache-addrinfo.h.
(krb5int_fac, krb5int_init_fac, krb5int_fini_fac): Moved to init-addrinfo.c.
(addrinfo, struct addrinfo): Don't define.
(AI_* and NI_* and EAI_* macros): Don't define.
* threads.c: Include cache-addrinfo.h.
(krb5int_init_fac, krb5int_fini_fac): Don't declare.
* Makefile.in (SRCS, STLIBOBJS, LIBOBJS): Updated.
* prof_init.c, profile.hin: added profile_is_modified and profile_is_writable so that callers can check to see if profile_release() will fail before calling it
* prof_set.c: profile calls which set values should not fail if file is not writable. You can now write to a different file with profile_flush_to_file() or buffer with profile_flush_to_buffer()