kim_debug_printf ("KIM_NEVER_PROMPT is set.");
allow_automatic_prompting = FALSE;
}
+
+ if (allow_automatic_prompting && !kim_os_library_caller_uses_gui ()) {
+ kim_debug_printf ("Caller is not using gui.");
+ allow_automatic_prompting = FALSE;
+ }
if (allow_automatic_prompting) {
/* Make sure there is at least 1 config file. We don't support DNS
kim_error kim_library_init (void);
+kim_boolean kim_os_library_caller_uses_gui (void);
+
kim_ui_environment kim_os_library_get_ui_environment (void);
kim_ui_environment kim_library_ui_environment (void);
/* ------------------------------------------------------------------------ */
+kim_boolean kim_os_library_caller_uses_gui (void)
+{
+ kim_boolean caller_uses_gui = 0;
+
+ /* Check for the HIToolbox (Carbon) or AppKit (Cocoa).
+ * If either is loaded, we are a GUI app! */
+ CFBundleRef appKitBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.AppKit"));
+ CFBundleRef hiToolBoxBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.HIToolbox"));
+
+ if (hiToolBoxBundle && CFBundleIsExecutableLoaded (hiToolBoxBundle)) {
+ caller_uses_gui = 1; /* Using Carbon */
+ }
+
+ if (appKitBundle && CFBundleIsExecutableLoaded (appKitBundle)) {
+ caller_uses_gui = 1; /* Using Cocoa */
+ }
+
+ return caller_uses_gui;
+}
+
+/* ------------------------------------------------------------------------ */
+
kim_ui_environment kim_os_library_get_ui_environment (void)
{
#ifdef KIM_BUILTIN_UI
NULL, &sattrs) == noErr) &&
(sattrs & sessionHasGraphicAccess));
- if (has_gui_access) {
- /* Check for the HIToolbox (Carbon) or AppKit (Cocoa).
- * If either is loaded, we are a GUI app! */
- CFBundleRef appKitBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.AppKit"));
- CFBundleRef hiToolBoxBundle = CFBundleGetBundleWithIdentifier (CFSTR ("com.apple.HIToolbox"));
-
- if (hiToolBoxBundle && CFBundleIsExecutableLoaded (hiToolBoxBundle)) {
- /* Using Carbon */
- return KIM_UI_ENVIRONMENT_GUI;
- }
-
- if (appKitBundle && CFBundleIsExecutableLoaded (appKitBundle)) {
- /* Using Cocoa */
- return KIM_UI_ENVIRONMENT_GUI;
- }
+ if (has_gui_access && kim_os_library_caller_uses_gui ()) {
+ return KIM_UI_ENVIRONMENT_GUI;
}
{
#if defined(USE_KIM)
#include <kim/kim.h>
+#include "kim_library_private.h"
#elif defined(USE_LEASH)
#ifdef _WIN64
#define LEASH_DLL "leashw64.dll"
kim_error err = KIM_NO_ERROR;
kim_ccache kimccache = NULL;
kim_identity identity = NULL;
+ kim_credential_state state;
+ krb5_principal desired_princ = (krb5_principal) desired_name;
err = kim_identity_create_from_krb5_principal (&identity,
context,
- (krb5_principal) desired_name);
+ desired_princ);
if (!err) {
- err = kim_ccache_create_new_if_needed (&kimccache,
- identity,
- KIM_OPTIONS_DEFAULT);
+ err = kim_ccache_create_from_client_identity (&kimccache, identity);
}
-
+
+ if (!err) {
+ err = kim_ccache_get_state (kimccache, &state);
+ }
+
+ if (!err && state != kim_credentials_state_valid) {
+ if (state == kim_credentials_state_needs_validation) {
+ err = kim_ccache_validate (kimccache, KIM_OPTIONS_DEFAULT);
+ } else {
+ kim_ccache_free (&kimccache);
+ ccache = NULL;
+ }
+ }
+
+ if (!kimccache && kim_library_allow_automatic_prompting ()) {
+ /* ccache does not already exist, create a new one */
+ err = kim_ccache_create_new (&kimccache, identity,
+ KIM_OPTIONS_DEFAULT);
+ }
+
if (!err) {
err = kim_ccache_get_krb5_ccache (kimccache, context, &ccache);
}
#if defined(USE_KIM)
#include <kim/kim.h>
+#include "kim_library_private.h"
#elif defined(USE_LEASH)
static void (*pLeash_AcquireInitialTicketsIfNeeded)(krb5_context,krb5_principal,char*,int) = NULL;
static HANDLE hLeashDLL = INVALID_HANDLE_VALUE;
}
#ifdef USE_KIM
- {
+ if (kim_library_allow_automatic_prompting ()) {
kim_error err = KIM_NO_ERROR;
kim_ccache kimccache = NULL;
kim_identity identity = KIM_IDENTITY_ANY;