non-kfw-probe-fix-20040319
authorJeffrey Altman <jaltman@mit.edu>
Sat, 20 Mar 2004 01:01:07 +0000 (01:01 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 20 Mar 2004 01:01:07 +0000 (01:01 +0000)
Fix the non-KFW case of the KDC Probe.  Prevent infinite loop.

src/WINNT/client_creds/afskfw-int.h
src/WINNT/client_creds/afskfw.c
src/WINNT/client_creds/afswiz.cpp
src/WINNT/client_creds/creds.cpp
src/WINNT/client_creds/creds.h
src/WINNT/client_creds/credstab.cpp

index 828724d..139bceb 100644 (file)
@@ -275,4 +275,18 @@ int  KFW_AFS_klog(krb5_context, krb5_ccache, char*, char*, char*, int);
 void KFW_import_ccache_data(void);
 void KFW_import_windows_lsa(void);
 BOOL MSLSA_IsKerberosLogon();
+
+/* From afs/krb_prot.h */
+/* values for kerb error codes */
+#define         KERB_ERR_OK                              0
+#define         KERB_ERR_NAME_EXP                        1
+#define         KERB_ERR_SERVICE_EXP                     2
+#define         KERB_ERR_AUTH_EXP                        3
+#define         KERB_ERR_PKT_VER                         4
+#define         KERB_ERR_NAME_MAST_KEY_VER               5
+#define         KERB_ERR_SERV_MAST_KEY_VER               6
+#define         KERB_ERR_BYTE_ORDER                      7
+#define         KERB_ERR_PRINCIPAL_UNKNOWN               8
+#define         KERB_ERR_PRINCIPAL_NOT_UNIQUE            9
+#define         KERB_ERR_NULL_KEY                       10
 #endif /* AFSKFW_INT_H */
index bedb85f..32dabdd 100644 (file)
@@ -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 ) {
index 65b942c..43390d5 100644 (file)
@@ -313,7 +313,7 @@ BOOL CALLBACK WizCreds_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
 
                      WizCreds_OnEnable (hDlg, FALSE);
 
-                     if (ObtainNewCredentials (szCell, szUser, szPassword) == 0)
+                     if (ObtainNewCredentials (szCell, szUser, szPassword, FALSE) == 0)
                         {
                         g.pWizard->SetState (STEP_MOUNT);
                         }
index ac8a218..930418c 100644 (file)
@@ -370,7 +370,7 @@ int DestroyCurrentCredentials (LPCTSTR pszCell)
 }
 
 
-int ObtainNewCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword)
+int ObtainNewCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, BOOL Silent)
 {
    int rc = KTC_NOCM;
    char *Result = NULL;
@@ -398,7 +398,7 @@ int ObtainNewCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword)
           rc = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION, szNameA, "", szCellA, szPasswordA, 0, &Expiration, 0, &Result);
       }
 
-   if (rc != 0)
+   if (!Silent && rc != 0)
       {
       int idsTitle = (g.fIsWinNT) ? IDS_ERROR_TITLE : IDS_ERROR_TITLE_95;
       int idsDesc = (g.fIsWinNT) ? IDS_ERROR_OBTAIN : IDS_ERROR_OBTAIN_95;
index ab87b64..f1ea6ae 100644 (file)
@@ -27,7 +27,7 @@ int GetCurrentCredentials (void);
 
 int DestroyCurrentCredentials (LPCTSTR pszCell);
 
-int ObtainNewCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword);
+int ObtainNewCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, BOOL Silent);
 
 int GetDefaultCell (LPTSTR pszCell);
 
index bbcb8a6..f6bfc44 100644 (file)
@@ -357,7 +357,7 @@ BOOL NewCreds_OnOK (HWND hDlg)
    GetDlgItemText (hDlg, IDC_NEWCREDS_PASSWORD, szPassword, cchRESOURCE);
 
    int rc;
-   if ((rc = ObtainNewCredentials (szCell, szUser, szPassword)) != 0)
+   if ((rc = ObtainNewCredentials (szCell, szUser, szPassword, FALSE)) != 0)
       {
       EnableWindow (GetDlgItem (hDlg, IDOK), TRUE);
       EnableWindow (GetDlgItem (hDlg, IDCANCEL), TRUE);