From: Jeffrey Altman Date: Mon, 8 Mar 2004 02:23:34 +0000 (+0000) Subject: kfw-changes-20040307 X-Git-Tag: openafs-devel-1_3_60~62 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e0461bfb375a634850043b77b477e7015fbc3e9e;p=packages%2Fo%2Fopenafs.git kfw-changes-20040307 * Increase debugging of the KFW code; * Remove the krb5_cc_remove_creds --- diff --git a/src/WINNT/client_creds/afskfw.c b/src/WINNT/client_creds/afskfw.c index 3e5c3ca45..471a60de4 100644 --- a/src/WINNT/client_creds/afskfw.c +++ b/src/WINNT/client_creds/afskfw.c @@ -419,7 +419,7 @@ KFW_initialize(void) KFW_import_windows_lsa(); #endif /* USE_MS2MIT */ KFW_import_ccache_data(); - KFW_AFS_renew_expiring_credentials(); + KFW_AFS_renew_expiring_tokens(); /* WIN32 NOTE: no way to get max chars */ if (!pcm_GetRootCellName(rootcell)) @@ -1316,7 +1316,7 @@ KFW_AFS_destroy_tickets_for_cell(char * cell) } int -KFW_AFS_renew_expiring_credentials(void) +KFW_AFS_renew_expiring_tokens(void) { krb5_error_code code = 0; krb5_context ctx = 0; @@ -1333,7 +1333,7 @@ KFW_AFS_renew_expiring_credentials(void) return 0; if ( IsDebuggerPresent() ) { - OutputDebugString("KFW_AFS_renew_expiring_credentials\n"); + OutputDebugString("KFW_AFS_renew_expiring_tokens\n"); } code = pkrb5_init_context(&ctx); @@ -1458,6 +1458,10 @@ KFW_AFS_renew_token_for_cell(char * cell) OutputDebugString("\n"); } +#ifdef COMMENT + /* krb5_cc_remove_cred() is not implemented + * for a single cred + */ code = pkrb5_build_principal(ctx, &service, strlen(realm), realm, "afs", cell, NULL); if (!code) { @@ -1485,6 +1489,8 @@ KFW_AFS_renew_token_for_cell(char * cell) pkrb5_free_principal(ctx, creds.server); } } +#endif /* COMMENT */ + code = KFW_AFS_klog(ctx, cc, "afs", cell, (char *)realm, pLeash_get_default_lifetime()); if ( IsDebuggerPresent() ) { char message[256]; @@ -2477,7 +2483,7 @@ KFW_AFS_klog( char * cname, *sname; pkrb5_unparse_name(ctx, increds.client, &cname); pkrb5_unparse_name(ctx, increds.server, &sname); - OutputDebugString("Getting credentials for \""); + OutputDebugString("Getting tickets for \""); OutputDebugString(cname); OutputDebugString("\" and service \""); OutputDebugString(sname); @@ -2503,7 +2509,7 @@ KFW_AFS_klog( pkrb5_unparse_name(ctx, increds.client, &cname); pkrb5_unparse_name(ctx, increds.server, &sname); OutputDebugString("krb5_get_credentials() returned Service Principal Unknown\n"); - OutputDebugString("Trying again: getting credentials for \""); + OutputDebugString("Trying again: getting tickets for \""); OutputDebugString(cname); OutputDebugString("\" and service \""); OutputDebugString(sname); @@ -3080,6 +3086,13 @@ ObtainTokensFromUserIfNeeded(HWND hWnd) if (!rc && (now < atoken.endTime)) goto cleanup; + + if ( IsDebuggerPresent() ) { + char message[256]; + sprintf(message,"KFW_AFS_klog() returns: %d now = %ul endTime = %ul\n", + rc, now, atoken.endTime); + OutputDebugString(message); + } } else { SYSTEMTIME stNow; FILETIME ftNow; @@ -3101,6 +3114,13 @@ ObtainTokensFromUserIfNeeded(HWND hWnd) if (!rc && (llNow < llExpires)) goto cleanup; + + if ( IsDebuggerPresent() ) { + char message[256]; + sprintf(message,"KFW_AFS_klog() returns: %d now = %ul endTime = %ul\n", + rc, llNow, llExpires); + OutputDebugString(message); + } } @@ -3163,14 +3183,20 @@ ObtainTokensFromUserIfNeeded(HWND hWnd) serverReachable = 1; } #endif - if ( !serverReachable ) + if ( !serverReachable ) { + if ( IsDebuggerPresent() ) + OutputDebugString("Server Unreachable\n"); goto cleanup; + } + + if ( IsDebuggerPresent() ) + OutputDebugString("Server Reachable\n"); if ( KFW_is_available() ) { #ifdef USE_MS2MIT KFW_import_windows_lsa(); #endif /* USE_MS2MIT */ - KFW_AFS_renew_expiring_credentials(); + KFW_AFS_renew_expiring_tokens(); KFW_AFS_renew_token_for_cell(rootcell); rc = pktc_GetToken(&aserver, &atoken, sizeof(atoken), &aclient); @@ -3269,6 +3295,14 @@ IpAddrChangeMonitor(void * hWnd) #endif NumOfAddrs = GetNumOfIpAddrs(); + + if ( IsDebuggerPresent() ) { + char message[256]; + sprintf(message,"IPAddrChangeMonitor() NumOfAddrs: now %d was %d\n", + NumOfAddrs, prevNumOfAddrs); + OutputDebugString(message); + } + if ( NumOfAddrs != prevNumOfAddrs ) { // Give AFS Client Service a chance to notice and die // Or for network services to startup diff --git a/src/WINNT/client_creds/afskfw.h b/src/WINNT/client_creds/afskfw.h index 8051e6425..a34341b47 100644 --- a/src/WINNT/client_creds/afskfw.h +++ b/src/WINNT/client_creds/afskfw.h @@ -37,7 +37,7 @@ void KFW_initialize(void); void KFW_cleanup(void); int KFW_is_available(void); int KFW_AFS_destroy_tickets_for_cell(char *); -int KFW_AFS_renew_expiring_credentials(void); +int KFW_AFS_renew_expiring_tokens(void); int KFW_AFS_get_cred( char * username, char * instance, char * cell, diff --git a/src/WINNT/client_creds/window.cpp b/src/WINNT/client_creds/window.cpp index 3564fa736..0a2cb1482 100644 --- a/src/WINNT/client_creds/window.cpp +++ b/src/WINNT/client_creds/window.cpp @@ -270,25 +270,36 @@ void Main_OnInitDialog (HWND hDlg) } BOOL fFoundUserName = FALSE; - if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), &hk) == 0) - { - DWORD dwSize = sizeof(szUser); - DWORD dwType = REG_SZ; - if (RegQueryValueEx (hk, TEXT("DefaultUserName"), NULL, &dwType, (PBYTE)szUser, &dwSize) == 0) - fFoundUserName = TRUE; - RegCloseKey (hk); - } - if (!fFoundUserName) - { - if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT("Network\\Logon"), &hk) == 0) - { - DWORD dwSize = sizeof(szUser); - DWORD dwType = REG_SZ; - if (RegQueryValueEx (hk, TEXT("UserName"), NULL, &dwType, (PBYTE)szUser, &dwSize) == 0) + if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Explorer"), &hk) == 0) + { + DWORD dwSize = sizeof(szUser); + DWORD dwType = REG_SZ; + if (RegQueryValueEx (hk, TEXT("Logon User Name"), NULL, &dwType, (PBYTE)szUser, &dwSize) == 0) fFoundUserName = TRUE; - RegCloseKey (hk); - } - } + RegCloseKey (hk); + } + if (!fFoundUserName ) + { + if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), &hk) == 0) + { + DWORD dwSize = sizeof(szUser); + DWORD dwType = REG_SZ; + if (RegQueryValueEx (hk, TEXT("DefaultUserName"), NULL, &dwType, (PBYTE)szUser, &dwSize) == 0) + fFoundUserName = TRUE; + RegCloseKey (hk); + } + } + if (!fFoundUserName) + { + if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT("Network\\Logon"), &hk) == 0) + { + DWORD dwSize = sizeof(szUser); + DWORD dwType = REG_SZ; + if (RegQueryValueEx (hk, TEXT("UserName"), NULL, &dwType, (PBYTE)szUser, &dwSize) == 0) + fFoundUserName = TRUE; + RegCloseKey (hk); + } + } TCHAR szSource[ cchRESOURCE ]; TCHAR szTarget[ cchRESOURCE ]; @@ -599,7 +610,7 @@ size_t Main_FindExpiredCreds (void) size_t retval = (size_t) -1; lock_ObtainMutex(&g.expirationCheckLock); if ( KFW_is_available() ) - KFW_AFS_renew_expiring_credentials(); + KFW_AFS_renew_expiring_tokens(); lock_ObtainMutex(&g.credsLock); for (size_t iCreds = 0; iCreds < g.cCreds; ++iCreds) {