diff options
author | Simo Sorce <simo@redhat.com> | 2012-02-03 22:21:14 -0500 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2012-02-03 22:32:24 -0500 |
commit | f6b7355c9219fa3e8fd231b964161afd4e27b940 (patch) | |
tree | 6bc0ef191a61d7b9a7e33a310622d421a70e6b00 | |
parent | 38321678d5595f7b2db35732c5c047884cca36db (diff) | |
download | gss-proxy-f6b7355c9219fa3e8fd231b964161afd4e27b940.tar.gz gss-proxy-f6b7355c9219fa3e8fd231b964161afd4e27b940.tar.xz gss-proxy-f6b7355c9219fa3e8fd231b964161afd4e27b940.zip |
Fix loop in case of errors and use gp_debug
We need to have 2 variables to hold the array index otherwise we will
leave holes and loose elements that come after a failure.
Use gp_log_failure() to make code more readable
-rw-r--r-- | proxy/src/gp_export.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/proxy/src/gp_export.c b/proxy/src/gp_export.c index 311140c..f1b7dce 100644 --- a/proxy/src/gp_export.c +++ b/proxy/src/gp_export.c @@ -29,6 +29,7 @@ #include <errno.h> #include "gp_conv.h" #include "gp_export.h" +#include "gp_debug.h" /* FIXME: F I X M E * @@ -63,7 +64,7 @@ int gp_export_gssx_cred(gss_cred_id_t *in, gssx_cred *out) uint32_t acceptor_lifetime; struct gssx_cred_element *el; int ret; - int i; + int i, j; ret_maj = gss_inquire_cred(&ret_min, *in, &name, &lifetime, &cred_usage, &mechanisms); @@ -87,9 +88,9 @@ int gp_export_gssx_cred(gss_cred_id_t *in, gssx_cred *out) goto done; } - for (i = 0; i < mechanisms->count; i++) { + for (i = 0, j = 0; i < mechanisms->count; i++, j++) { - el = &out->elements.elements_val[i]; + el = &out->elements.elements_val[j]; ret_maj = gss_inquire_cred_by_mech(&ret_min, *in, &mechanisms->elements[i], @@ -98,29 +99,11 @@ int gp_export_gssx_cred(gss_cred_id_t *in, gssx_cred *out) &acceptor_lifetime, &cred_usage); if (ret_maj) { - uint32_t msgctx; - uint32_t discard; - gss_buffer_desc tmp; - - gss_oid_to_str(&ret_min, &mechanisms->elements[i], &tmp); - fprintf(stderr, "Mech OID: %s", (char *)tmp.value); - gss_release_buffer(&discard, &tmp); - - msgctx = 0; - gss_display_status(&discard, ret_maj, GSS_C_GSS_CODE, - &mechanisms->elements[i], &msgctx, &tmp); - fprintf(stderr, " ... failed with %s,", (char *)tmp.value); - gss_release_buffer(&discard, &tmp); - - msgctx = 0; - gss_display_status(&discard, ret_min, GSS_C_MECH_CODE, - &mechanisms->elements[i], &msgctx, &tmp); - fprintf(stderr, " %s\n", (char *)tmp.value); - - gss_release_buffer(&discard, &tmp); + gp_log_failure(&mechanisms->elements[i], ret_maj, ret_min); /* temporarily skip any offender */ out->elements.elements_len--; + j--; continue; #if 0 ret = EINVAL; |