From 5f7cf5fc22ac3ca62175c69c1a25139dde4b22b0 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Wed, 19 Dec 2012 10:59:24 -0500 Subject: [PATCH] Windows: limit number of retries due to kdc repeat error don't retry forever. does not apply to master due to difference in sdk for kerberos Reviewed-on: http://gerrit.openafs.org/8792 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman (cherry picked from commit 8c1288ed64714a3e136a644eac1e64466d5dfdbc) Change-Id: I67e20e302d09ebecec8e7856cafe7133333b89f4 Reviewed-on: http://gerrit.openafs.org/8798 Tested-by: BuildBot Reviewed-by: Paul Smeddle Reviewed-by: Stephan Wiesand --- src/WINNT/afsd/afskfw.c | 24 +++++++++++++++--------- src/WINNT/aklog/aklog.c | 3 ++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/WINNT/afsd/afskfw.c b/src/WINNT/afsd/afskfw.c index 7ce4516b0..edd81aab1 100644 --- a/src/WINNT/afsd/afskfw.c +++ b/src/WINNT/afsd/afskfw.c @@ -2060,7 +2060,7 @@ KFW_kinit( krb5_context alt_ctx, krb5_creds my_creds; krb5_get_init_creds_opt options; krb5_address ** addrs = NULL; - int i = 0, addr_count = 0; + int i = 0, addr_count = 0, passes = 0; if (!pkrb5_init_context) return KRB5_CONFIG_CANTOPEN; @@ -2182,7 +2182,7 @@ KFW_kinit( krb5_context alt_ctx, &options); if (code == KRB5KRB_AP_ERR_REPEAT) Sleep(1000); - } while(code == KRB5KRB_AP_ERR_REPEAT); + } while(code == KRB5KRB_AP_ERR_REPEAT && passes++ < 2); if (code) goto cleanup; @@ -2882,6 +2882,7 @@ KFW_AFS_klog( krb5_principal client_principal = NULL; krb5_data * k5data = NULL; unsigned int i, retry = 0; + int passes = 0; CurrentState = 0; memset(HostName, '\0', sizeof(HostName)); @@ -3040,12 +3041,12 @@ KFW_AFS_klog( pkrb5_free_unparsed_name(ctx,cname); pkrb5_free_unparsed_name(ctx,sname); } - + passes = 0; do { code = pkrb5_get_credentials(ctx, 0, cc, &increds, &k5creds); if (code == KRB5KRB_AP_ERR_REPEAT) Sleep(1000); - } while(code == KRB5KRB_AP_ERR_REPEAT); + } while(code == KRB5KRB_AP_ERR_REPEAT && passes++ < 2); if (code == 0) { /* The client's realm is a local realm for the cell. @@ -3089,11 +3090,12 @@ KFW_AFS_klog( } if (!code) { + passes = 0; do { code = pkrb5_get_credentials(ctx, 0, cc, &increds, &k5creds); if (code == KRB5KRB_AP_ERR_REPEAT) Sleep(1000); - } while(code == KRB5KRB_AP_ERR_REPEAT); + } while(code == KRB5KRB_AP_ERR_REPEAT && passes++ < 2); } if (code == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN || @@ -3124,11 +3126,12 @@ KFW_AFS_klog( } if (!code) { + passes = 0; do { code = pkrb5_get_credentials(ctx, 0, cc, &increds, &k5creds); if (code == KRB5KRB_AP_ERR_REPEAT) Sleep(1000); - } while(code == KRB5KRB_AP_ERR_REPEAT); + } while(code == KRB5KRB_AP_ERR_REPEAT && passes++ < 2); } } } @@ -3161,11 +3164,12 @@ KFW_AFS_klog( } if (!code) { + passes = 0; do { code = pkrb5_get_credentials(ctx, 0, cc, &increds, &k5creds); if (code == KRB5KRB_AP_ERR_REPEAT) Sleep(1000); - } while(code == KRB5KRB_AP_ERR_REPEAT); + } while(code == KRB5KRB_AP_ERR_REPEAT && passes++ < 2); } if (!code && !strlen(realm_of_cell)) @@ -3203,11 +3207,12 @@ KFW_AFS_klog( } if (!code) { + passes = 0; do { code = pkrb5_get_credentials(ctx, 0, cc, &increds, &k5creds); if (code == KRB5KRB_AP_ERR_REPEAT) Sleep(1000); - } while(code == KRB5KRB_AP_ERR_REPEAT); + } while(code == KRB5KRB_AP_ERR_REPEAT && passes++ < 2); } if (!code && !strlen(realm_of_cell)) @@ -3242,11 +3247,12 @@ KFW_AFS_klog( } if (!code) { + passes = 0; do { code = pkrb5_get_credentials(ctx, 0, cc, &increds, &k5creds); if (code == KRB5KRB_AP_ERR_REPEAT) Sleep(1000); - } while(code == KRB5KRB_AP_ERR_REPEAT); + } while(code == KRB5KRB_AP_ERR_REPEAT && passes++ < 2); } if (!code && !strlen(realm_of_cell)) diff --git a/src/WINNT/aklog/aklog.c b/src/WINNT/aklog/aklog.c index f1a50311f..222936476 100644 --- a/src/WINNT/aklog/aklog.c +++ b/src/WINNT/aklog/aklog.c @@ -482,6 +482,7 @@ static int get_v5cred(krb5_context context, krb5_creds increds; krb5_error_code r; static krb5_principal client_principal = 0; + int passes = 0; if (client_principal) { krb5_free_principal(context, client_principal); @@ -518,7 +519,7 @@ static int get_v5cred(krb5_context context, r = krb5_get_credentials(context, 0, _krb425_ccache, &increds, creds); if (r == KRB5KRB_AP_ERR_REPEAT) Sleep(1000); - } while(r == KRB5KRB_AP_ERR_REPEAT); + } while(r == KRB5KRB_AP_ERR_REPEAT && passes++ < 2); if (r) { return((int)r); -- 2.39.5