summaryrefslogtreecommitdiffstats
path: root/src/lib/gssapi
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2004-04-24 21:09:44 +0000
committerKen Raeburn <raeburn@mit.edu>2004-04-24 21:09:44 +0000
commitfcf02bef88a17724aa230547459a9eaf1159d6c1 (patch)
tree7f9dd998b8e7baf61111f6bf0428da47de1291eb /src/lib/gssapi
parent3b4d753fc5169469da270c831654a8fae407cfdf (diff)
downloadkrb5-fcf02bef88a17724aa230547459a9eaf1159d6c1.tar.gz
krb5-fcf02bef88a17724aa230547459a9eaf1159d6c1.tar.xz
krb5-fcf02bef88a17724aa230547459a9eaf1159d6c1.zip
Added support for library initialization and finalization, and verification
that the initializer completed successfully. Delay initialization on POSIX until the first "verification" call. Currently specific to a few platforms, but should still build on others without thread support enabled. Use it to finish creating (if necessary) and destroy mutexes, and free some other storage "permanently" allocated by libraries (currently, libkrb5 cache/keytab type registries only). Change initialization of static mutexes to a two-step operation, a static "partial" initializer and a "finish_init" routine called from a thread-safe environment like library initialization is assumed to be. POSIX will use the former, Windows will use the latter, and the debug support will check that *both* have been used. Added init/fini functions to com_err, profile, krb5, and gssapi libraries. (The profile library one may need to be removed later.) The existing ones, not thread-safe, are still around. Use weak symbol support if available to figure out if the pthread library has been linked in, and avoid calling certain routines if the C library stubs are known not to exist or work. Stub declarations for thread-specific data. Minor bugfixes, whitespace changes. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16268 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/gssapi')
-rw-r--r--src/lib/gssapi/ChangeLog8
-rw-r--r--src/lib/gssapi/generic/ChangeLog5
-rw-r--r--src/lib/gssapi/generic/gssapiP_generic.h2
-rw-r--r--src/lib/gssapi/gss_libinit.c28
-rw-r--r--src/lib/gssapi/krb5/ChangeLog3
-rw-r--r--src/lib/gssapi/krb5/krb5_gss_glue.c10
6 files changed, 46 insertions, 10 deletions
diff --git a/src/lib/gssapi/ChangeLog b/src/lib/gssapi/ChangeLog
index e33541574..0c2d0ec16 100644
--- a/src/lib/gssapi/ChangeLog
+++ b/src/lib/gssapi/ChangeLog
@@ -1,3 +1,11 @@
+2004-04-24 Ken Raeburn <raeburn@mit.edu>
+
+ * gss_libinit.c: Include k5-platform.h.
+ (gssint_lib_init, gssint_lib_fini): New init/fini functions.
+ Create and clean up the mutex in kg_vdb.
+ (gssint_initialize_library): Verify the library initializer has
+ run successfully.
+
2004-04-22 Ken Raeburn <raeburn@mit.edu>
* libgssapi_krb5.exports: New file.
diff --git a/src/lib/gssapi/generic/ChangeLog b/src/lib/gssapi/generic/ChangeLog
index 563eb2f06..a9f93eb14 100644
--- a/src/lib/gssapi/generic/ChangeLog
+++ b/src/lib/gssapi/generic/ChangeLog
@@ -1,3 +1,8 @@
+2004-04-24 Ken Raeburn <raeburn@mit.edu>
+
+ * gssapiP_generic.h (G_SET_INIT): Use the new mutex partial
+ initializer now.
+
2004-03-14 Ken Raeburn <raeburn@mit.edu>
* gssapiP_generic.h (struct _g_set_elt, g_set_elt): Renamed from
diff --git a/src/lib/gssapi/generic/gssapiP_generic.h b/src/lib/gssapi/generic/gssapiP_generic.h
index 30afc5264..e297862fe 100644
--- a/src/lib/gssapi/generic/gssapiP_generic.h
+++ b/src/lib/gssapi/generic/gssapiP_generic.h
@@ -139,7 +139,7 @@ typedef struct {
k5_mutex_t mutex;
void *data;
} g_set;
-#define G_SET_INIT { K5_MUTEX_INITIALIZER, 0 }
+#define G_SET_INIT { K5_MUTEX_PARTIAL_INITIALIZER, 0 }
int g_set_init (g_set_elt *s);
int g_set_destroy (g_set_elt *s);
diff --git a/src/lib/gssapi/gss_libinit.c b/src/lib/gssapi/gss_libinit.c
index 0568f2964..fb80c8946 100644
--- a/src/lib/gssapi/gss_libinit.c
+++ b/src/lib/gssapi/gss_libinit.c
@@ -5,6 +5,7 @@
#include "gssapiP_krb5.h"
#include "gss_libinit.h"
+#include "k5-platform.h"
static int initialized = 0;
@@ -12,19 +13,33 @@ static int initialized = 0;
* Initialize the GSSAPI library.
*/
+MAKE_INIT_FUNCTION(gssint_lib_init);
+MAKE_FINI_FUNCTION(gssint_lib_fini);
+
+int gssint_lib_init(void)
+{
+ return k5_mutex_finish_init(&kg_vdb.mutex);
+}
+
+void gssint_lib_fini(void)
+{
+ if (!INITIALIZER_RAN(gssint_lib_init) || PROGRAM_EXITING())
+ return;
+ k5_mutex_destroy(&kg_vdb.mutex);
+}
+
OM_uint32 gssint_initialize_library (void)
{
-
if (!initialized) {
#if !USE_BUNDLE_ERROR_STRINGS
add_error_table(&et_k5g_error_table);
add_error_table(&et_ggss_error_table);
#endif
- initialized = 1;
+ initialized = 1;
}
-
- return 0;
+
+ return CALL_INIT_FUNCTION(gssint_lib_init);
}
/*
@@ -33,13 +48,12 @@ OM_uint32 gssint_initialize_library (void)
void gssint_cleanup_library (void)
{
-
assert (initialized);
-
+
#if !USE_BUNDLE_ERROR_STRINGS
remove_error_table(&et_k5g_error_table);
remove_error_table(&et_ggss_error_table);
#endif
-
+
initialized = 0;
}
diff --git a/src/lib/gssapi/krb5/ChangeLog b/src/lib/gssapi/krb5/ChangeLog
index f55b779da..1be0a67a7 100644
--- a/src/lib/gssapi/krb5/ChangeLog
+++ b/src/lib/gssapi/krb5/ChangeLog
@@ -5,6 +5,9 @@
(kg_set_ccache_name): Likewise. Return after an error rather
than continuing.
+ * krb5_gss_glue.c (gss_import_name): Call
+ gssint_initialize_library and check the return status.
+
2004-04-13 Jeffrey Altman <jaltman@mit.edu>
* k5unseal.c: gss_krb5int_unseal_token_v3() takes a pointer to
diff --git a/src/lib/gssapi/krb5/krb5_gss_glue.c b/src/lib/gssapi/krb5/krb5_gss_glue.c
index 540652ad8..583881d8e 100644
--- a/src/lib/gssapi/krb5/krb5_gss_glue.c
+++ b/src/lib/gssapi/krb5/krb5_gss_glue.c
@@ -211,8 +211,14 @@ gss_import_name(minor_status, input_name_buffer, input_name_type, output_name)
gss_OID input_name_type;
gss_name_t *output_name;
{
- return(krb5_gss_import_name(minor_status, input_name_buffer,
- input_name_type, output_name));
+ OM_uint32 err;
+ err = gssint_initialize_library();
+ if (err) {
+ *minor_status = err;
+ return GSS_S_FAILURE;
+ }
+ return(krb5_gss_import_name(minor_status, input_name_buffer,
+ input_name_type, output_name));
}
/* V2 */