no-getcellconfig-error-20040323
[openafs.git] / src / WINNT / client_creds / afskfw.c
index 5c93cfe..376ce09 100644 (file)
@@ -2596,7 +2596,7 @@ KFW_AFS_klog(
     // NULL or empty cell returns information on local cell
     if (rc = get_cellconfig(Dmycell, &ak_cellconfig, local_cell))
     {
-               KFW_AFS_error(rc, "get_cellconfig()");
+        // KFW_AFS_error(rc, "get_cellconfig()");
         return(rc);
     }
 
@@ -2965,7 +2965,7 @@ KFW_AFS_error(LONG rc, LPCSTR FailedFunctionName)
     else
       errText = "Unknown error!";
 
-    sprintf(message, "%s\n(%s failed)", errText, FailedFunctionName);
+    sprintf(message, "%s (0x%x)\n(%s failed)", errText, rc, FailedFunctionName);
 
     if ( IsDebuggerPresent() ) {
         OutputDebugString(message);
@@ -3354,7 +3354,7 @@ ObtainTokensFromUserIfNeeded(HWND hWnd)
         code = pkrb5_c_random_make_octets(ctx, &pwdata);
         if (code) {
             int i;
-            for ( i=0 ; i<PROBE_PASSWORD_LEN ; i )
+            for ( i=0 ; i<PROBE_PASSWORD_LEN ; i++ )
                 password[i] = 'x';
         }
         password[PROBE_PASSWORD_LEN] = '\0';
@@ -3382,11 +3382,21 @@ ObtainTokensFromUserIfNeeded(HWND hWnd)
         }
     } else {
         int i;
-        for ( i=0 ; i<PROBE_PASSWORD_LEN ; i )
+
+        for ( i=0 ; i<PROBE_PASSWORD_LEN ; i++ )
             password[i] = 'x';
 
-        code = ObtainNewCredentials(rootcell, PROBE_USERNAME, password);
-        serverReachable = 1;
+        code = ObtainNewCredentials(rootcell, PROBE_USERNAME, password, TRUE);
+        switch ( code ) {
+        case INTK_BADPW:
+        case KERB_ERR_PRINCIPAL_UNKNOWN:
+        case KERB_ERR_SERVICE_EXP:
+        case RD_AP_TIME:
+            serverReachable = TRUE;
+            break;
+        default:
+            serverReachable = FALSE;
+        }
     }
 #endif
     if ( !serverReachable ) {
@@ -3449,9 +3459,11 @@ GetNumOfIpAddrs(void)
     if (code == ERROR_INSUFFICIENT_BUFFER) {
         pIpAddrTable = malloc(dwSize);
         code = GetIpAddrTable(pIpAddrTable, &dwSize, 0);
-        for ( index=0; index < pIpAddrTable->dwNumEntries; index++ ) {
-            if (pIpAddrTable->table[index].dwAddr != 0)
-                validAddrs++;
+        if ( code == NO_ERROR ) {
+            for ( index=0; index < pIpAddrTable->dwNumEntries; index++ ) {
+                if (pIpAddrTable->table[index].dwAddr != 0)
+                    validAddrs++;
+            }
         }
         free(pIpAddrTable);
     }
@@ -3462,12 +3474,13 @@ void
 IpAddrChangeMonitor(void * hWnd)
 {
 #ifdef USE_OVERLAPPED
-    HANDLE Handle = INVALID_HANDLE_VALUE;
+    HANDLE Handle = INVALID_HANDLE_VALUE;   /* Do Not Close This Handle */
     OVERLAPPED Ovlap;
 #endif /* USE_OVERLAPPED */
     DWORD Result;
     DWORD prevNumOfAddrs = GetNumOfIpAddrs();
     DWORD NumOfAddrs;
+    char message[256];
 
     if ( !hWnd )
         return;
@@ -3479,33 +3492,48 @@ IpAddrChangeMonitor(void * hWnd)
         Result = NotifyAddrChange(&Handle,&Ovlap);
         if (Result != ERROR_IO_PENDING)
         {        
-            printf("NotifyAddrChange() failed with error %d \n", Result);
+            if ( IsDebuggerPresent() ) {
+                sprintf(message, "NotifyAddrChange() failed with error %d \n", Result);
+                OutputDebugString(message);
+            }
             break;
         }
 
-        if ((Result = WaitForSingleObject(Handle,INFINITE)) == WAIT_FAILED)
+        if ((Result = WaitForSingleObject(Handle,INFINITE)) != WAIT_OBJECT_0)
         {
-            printf("WaitForSingleObject() failed with error %d\n",
-                    GetLastError());
+            if ( IsDebuggerPresent() ) {
+                sprintf(message, "WaitForSingleObject() failed with error %d\n",
+                        GetLastError());
+                OutputDebugString(message);
+            }
             continue;
         }
 
         if (GetOverlappedResult(Handle, &Ovlap,
                                  &DataTransfered, TRUE) == 0)
         {
-            printf("GetOverlapped result failed %d \n",
-                    GetLastError());
+            if ( IsDebuggerPresent() ) {
+                sprintf(message, "GetOverlapped result failed %d \n",
+                        GetLastError());
+                OutputDebugString(message);
+            }
             break;
         }
-
 #else
         Result = NotifyAddrChange(NULL,NULL);
+        if (Result != NO_ERROR)
+        {        
+            if ( IsDebuggerPresent() ) {
+                sprintf(message, "NotifyAddrChange() failed with error %d \n", Result);
+                OutputDebugString(message);
+            }
+            break;
+        }
 #endif
         
         NumOfAddrs = GetNumOfIpAddrs();
 
         if ( IsDebuggerPresent() ) {
-            char message[256];
             sprintf(message,"IPAddrChangeMonitor() NumOfAddrs: now %d was %d\n",
                     NumOfAddrs, prevNumOfAddrs);
             OutputDebugString(message);
@@ -3520,11 +3548,6 @@ IpAddrChangeMonitor(void * hWnd)
         }
         prevNumOfAddrs = NumOfAddrs;
     }
-
-#ifdef USE_OVERLAPPED
-    if (Handle != INVALID_HANDLE_VALUE)
-        CloseHandle(Handle);
-#endif 
 }