#include "ccapi_string.h"
#include "ccapi_ipc.h"
#include "ccapi_context_change_time.h"
+#include "ccapi_err.h"
#include <CredentialsCache2.h>
err = cci_ipc_thread_init ();
}
+ if (!err) {
+ add_error_table (&et_CAPI_error_table);
+ }
+
return err;
}
return;
}
+ remove_error_table(&et_CAPI_error_table);
cci_context_change_time_thread_fini ();
cci_ipc_thread_fini ();
}
if (!err) {
NSLog (@"Got auth prompt with identity '%s', type '%d', allow_save_reply '%d', hide '%d', title '%s', message '%s', description '%s'",
- identity_string, type, hide_reply, title, message, description);
+ identity_string, type, allow_save_reply, hide_reply, title, message, description);
err = kim_handle_reply_auth_prompt (in_reply_port, "ydobon", 0, 0);
#warning Send auth prompt message to main thread with 2 ports and arguments
}
kim_error kim_ccache_iterator_create (kim_ccache_iterator *out_ccache_iterator)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_ccache_iterator ccache_iterator = NULL;
if (!err && !out_ccache_iterator) { err = check_error (KIM_NULL_PARAMETER_ERR); }
static inline kim_error kim_ccache_allocate (kim_ccache *out_ccache)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_ccache ccache = NULL;
if (!err && !out_ccache) { err = check_error (KIM_NULL_PARAMETER_ERR); }
kim_error kim_credential_iterator_create (kim_credential_iterator *out_credential_iterator,
kim_ccache in_ccache)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_credential_iterator credential_iterator = NULL;
if (!err && !out_credential_iterator) { err = check_error (KIM_NULL_PARAMETER_ERR); }
static inline kim_error kim_credential_allocate (kim_credential *out_credential)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_credential credential = NULL;
if (!err && !out_credential) { err = check_error (KIM_NULL_PARAMETER_ERR); }
static inline kim_error kim_identity_allocate (kim_identity *out_identity)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_identity identity = NULL;
if (!err && !out_identity) { err = check_error (KIM_NULL_PARAMETER_ERR); }
#include "kim_private.h"
#include "kim_os_private.h"
+
+MAKE_INIT_FUNCTION(kim_error_init);
+MAKE_FINI_FUNCTION(kim_error_fini);
+
+/* ------------------------------------------------------------------------ */
+
+static int kim_error_init (void)
+{
+ add_error_table (&et_KIM_error_table);
+ return 0;
+}
+
+/* ------------------------------------------------------------------------ */
+
+static void kim_error_fini (void)
+{
+ if (!INITIALIZER_RAN (kim_error_init) || PROGRAM_EXITING ()) {
+ return;
+ }
+
+ remove_error_table (&et_KIM_error_table);
+}
+
+/* ------------------------------------------------------------------------ */
+
+kim_error kim_library_init (void)
+{
+ return CALL_INIT_FUNCTION (kim_error_init);
+}
+
+#pragma mark -
+
static k5_mutex_t g_allow_home_directory_access_mutex = K5_MUTEX_PARTIAL_INITIALIZER;
static k5_mutex_t g_allow_automatic_prompting_mutex = K5_MUTEX_PARTIAL_INITIALIZER;
static k5_mutex_t g_ui_environment_mutex = K5_MUTEX_PARTIAL_INITIALIZER;
#include <kim/kim.h>
+kim_error kim_library_init (void);
+
kim_ui_environment kim_os_library_get_ui_environment (void);
kim_ui_environment kim_library_ui_environment (void);
static inline kim_error kim_options_allocate (kim_options *out_options)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_options options = NULL;
if (!err && !out_options) { err = check_error (KIM_NULL_PARAMETER_ERR); }
kim_error err = KIM_NO_ERROR;
if (!err && !in_favorites) { err = check_error (KIM_NULL_PARAMETER_ERR); }
- if (!err && !io_favorites ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+ if (!err && !io_favorites) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
err = kim_favorites_resize (io_favorites, in_favorites->count);
&in_preferences->maximum_renewal_lifetime);
}
- if (!err) {
-
- }
-
return check_error (err);
}
static inline kim_error kim_preferences_allocate (kim_preferences *out_preferences)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_preferences preferences = NULL;
if (!err && !out_preferences) { err = check_error (KIM_NULL_PARAMETER_ERR); }
static inline kim_error kim_selection_hints_allocate (kim_selection_hints *out_selection_hints)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_selection_hints selection_hints = NULL;
if (!err && !out_selection_hints) { err = check_error (KIM_NULL_PARAMETER_ERR); }
kim_string in_format,
...)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
va_list args;
va_start (args, in_format);
kim_string in_format,
va_list in_args)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
int count = vasprintf ((char **) out_string, in_format, in_args);
if (count < 0) { err = check_error (KIM_OUT_OF_MEMORY_ERR); }
kim_string in_format,
va_list in_args)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_string string = NULL;
if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
const char *in_buffer,
kim_count in_length)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_string string = NULL;
if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
kim_error kim_string_create_for_last_error (kim_string *out_string,
kim_error in_error)
{
- return kim_string_copy (out_string, kim_error_message (in_error));
+ kim_error err = kim_library_init ();
+
+ err = kim_string_copy (out_string, kim_error_message (in_error));
+
+ return check_error (err);
}
/* ------------------------------------------------------------------------ */
kim_error kim_string_copy (kim_string *out_string,
kim_string in_string)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error err = kim_library_init ();
kim_string string = NULL;
if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
}
if (!err) {
- strcpy ((char *) string, in_string);
+ strncpy ((char *) string, in_string, strlen (in_string) + 1);
*out_string = string;
string = NULL;
}
kim_error kim_os_library_get_application_path (kim_string *out_path);
-
-kim_error kim_os_string_create_for_key (kim_string *out_string,
- kim_string in_key_string);
-
kim_error kim_os_string_create_from_cfstring (kim_string *out_string,
CFStringRef in_cfstring);
#include "kim_os_private.h"
-/* ------------------------------------------------------------------------ */
-static kim_error kim_os_string_for_key_in_bundle (CFBundleRef in_bundle,
- CFStringRef in_key,
- kim_string *out_string)
-{
- kim_error err = KIM_NO_ERROR;
- kim_string string = NULL;
-
- if (!err && !in_bundle ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
- if (!err && !in_key ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
- if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
-
- if (!err) {
- CFDictionaryRef dictionary = NULL;
- int release_dictionary = 0;
- CFStringRef cfstring = NULL;
-
-#if !KERBEROS_LITE
- if (kim_library_allow_home_directory_access ()) {
-#endif
- /* Accesses user's homedir to get localization information */
- dictionary = CFBundleGetLocalInfoDictionary (in_bundle);
-
-#if !KERBEROS_LITE
- } else {
- CFURLRef url = NULL;
- CFDataRef data = NULL;
- CFAllocatorRef allocator = CFGetAllocator (in_bundle);
- SInt32 code = 0;
-
- url = CFBundleCopyResourceURLForLocalization (in_bundle,
- CFSTR("InfoPlist"),
- CFSTR("strings"),
- NULL,
- CFSTR("English"));
-
- if (url && CFURLCreateDataAndPropertiesFromResource (allocator,
- url, &data,
- NULL, NULL,
- &code)) {
-
- dictionary = CFPropertyListCreateFromXMLData (allocator,
- data,
- kCFPropertyListImmutable,
- NULL);
- release_dictionary = 1;
- }
-
- if (data) { CFRelease (data); }
- if (url ) { CFRelease (url); }
- }
-#endif
-
- if (dictionary && (CFGetTypeID(dictionary) == CFDictionaryGetTypeID())) {
- cfstring = (CFStringRef) CFDictionaryGetValue (dictionary, in_key);
- }
-
- if (cfstring && (CFGetTypeID (cfstring) == CFStringGetTypeID ())) {
- err = kim_os_string_create_from_cfstring (&string, cfstring);
- }
-
- if (dictionary && release_dictionary) { CFRelease (dictionary); }
- }
-
- if (!err) {
- /* set to NULL if no string found */
- *out_string = string;
- string = NULL;
- }
-
- kim_string_free (&string);
-
- return check_error (err);
-}
-
-#pragma mark -
-
/* ------------------------------------------------------------------------ */
kim_error kim_os_string_create_localized (kim_string *out_string,
kim_string in_string)
{
- kim_error err = KIM_NO_ERROR;
+ kim_error lock_err = kim_os_library_lock_for_bundle_lookup ();
+ kim_error err = lock_err;
kim_string string = NULL;
+ CFStringRef cfkey = NULL;
if (!err && !out_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err && !in_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
if (!err) {
- err = kim_os_string_create_for_key (&string, in_string);
- }
-
- if (!err && !string) {
- err = kim_string_copy (&string, in_string);
- }
-
- if (!err) {
- *out_string = string;
- string = NULL;
+ err = kim_os_string_get_cfstring (in_string, &cfkey);
}
- kim_string_free (&string);
-
- return check_error (err);
-}
-
-/* ------------------------------------------------------------------------ */
-
-kim_error kim_os_string_create_for_key (kim_string *out_string,
- kim_string in_key_string)
-{
- kim_error lock_err = kim_os_library_lock_for_bundle_lookup ();
- kim_error err = lock_err;
- CFStringRef key = NULL;
- kim_string string = NULL;
-
- if (!err && !out_string ) { err = check_error (KIM_NULL_PARAMETER_ERR); }
- if (!err && !in_key_string) { err = check_error (KIM_NULL_PARAMETER_ERR); }
-
- if (!err) {
- err = kim_os_string_get_cfstring (in_key_string, &key);
- }
-
- if (!err) {
- /* Try to find the key, first searching in the framework */
+ if (!err && kim_library_allow_home_directory_access ()) {
+ CFStringRef cfstring = NULL;
CFBundleRef framework = CFBundleGetBundleWithIdentifier (CFSTR ("edu.mit.Kerberos"));
+ CFBundleRef main_bundle = CFBundleGetMainBundle ();
+
if (framework) {
- err = kim_os_string_for_key_in_bundle (framework, key, &string);
+ cfstring = CFCopyLocalizedStringFromTableInBundle (cfkey,
+ CFSTR ("InfoPlist"),
+ framework,
+ "");
+ }
+
+ if (main_bundle && !cfstring) {
+ cfstring = CFCopyLocalizedStringFromTableInBundle (cfkey,
+ CFSTR ("InfoPlist"),
+ main_bundle,
+ "");
+ }
+
+ if (!err && cfstring) {
+ err = kim_os_string_create_from_cfstring (&string, cfstring);
}
}
if (!err && !string) {
- /* If we didn't find it in the framwork, try in the main bundle */
- CFBundleRef main_bundle = CFBundleGetMainBundle ();
- if (main_bundle) {
- err = kim_os_string_for_key_in_bundle (main_bundle, key, &string);
- }
+ err = kim_string_copy (&string, in_string);
}
if (!err) {
string = NULL;
}
+ if (cfkey) { CFRelease (cfkey); }
kim_string_free (&string);
- if (key) { CFRelease (key); }
if (!lock_err) { kim_os_library_unlock_for_bundle_lookup (); }
printf("gssint_lib_init\n");
#endif
-#if !USE_BUNDLE_ERROR_STRINGS
add_error_table(&et_k5g_error_table);
add_error_table(&et_ggss_error_table);
-#endif
+
err = gssint_mechglue_init();
if (err)
return err;
#ifdef SHOW_INITFINI_FUNCS
printf("gssint_lib_fini\n");
#endif
-#if !USE_BUNDLE_ERROR_STRINGS
remove_error_table(&et_k5g_error_table);
remove_error_table(&et_ggss_error_table);
-#endif
+
k5_key_delete(K5_KEY_GSS_KRB5_SET_CCACHE_OLD_NAME);
k5_key_delete(K5_KEY_GSS_KRB5_CCACHE_NAME);
k5_mutex_destroy(&kg_vdb.mutex);
printf("krb5int_lib_init\n");
#endif
-#if !USE_BUNDLE_ERROR_STRINGS
add_error_table(&et_krb5_error_table);
add_error_table(&et_kv5m_error_table);
add_error_table(&et_kdb5_error_table);
add_error_table(&et_asn1_error_table);
add_error_table(&et_k524_error_table);
-#endif
err = krb5int_rc_finish_init();
if (err)
krb5_stdcc_shutdown();
#endif
-#if !USE_BUNDLE_ERROR_STRINGS
remove_error_table(&et_krb5_error_table);
remove_error_table(&et_kv5m_error_table);
remove_error_table(&et_kdb5_error_table);
remove_error_table(&et_asn1_error_table);
remove_error_table(&et_k524_error_table);
-#endif
+
krb5int_set_error_info_callout_fn (0);
}
* or implied warranty.
*/
+#ifndef LEAN_CLIENT
+
#include "k5_mig_client.h"
#include <Kerberos/kipc_client.h>
return err;
}
+
+#endif /* LEAN CLIENT */
#ifdef SHOW_INITFINI_FUNCS
printf("profile_library_initializer\n");
#endif
-#if !USE_BUNDLE_ERROR_STRINGS
add_error_table(&et_prof_error_table);
-#endif
+
return k5_mutex_finish_init(&g_shared_trees_mutex);
}
void profile_library_finalizer(void)
printf("profile_library_finalizer\n");
#endif
k5_mutex_destroy(&g_shared_trees_mutex);
-#if !USE_BUNDLE_ERROR_STRINGS
+
remove_error_table(&et_prof_error_table);
-#endif
}
static void profile_free_file_data(prf_data_t);