(foreach_principal): If any of calls to `func' failes, the first error

is returned when all principals are processed.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16652 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2006-01-25 12:11:09 +00:00
parent 5736f9af51
commit ff51c4fa4c

View File

@@ -485,7 +485,11 @@ is_expression(const char *string)
return 0;
}
/* loop over all principals matching exp */
/*
* Loop over all principals matching exp. If any of calls to `func'
* failes, the first error is returned when all principals are
* processed.
*/
int
foreach_principal(const char *exp_str,
int (*func)(krb5_principal, void*),
@@ -495,7 +499,7 @@ foreach_principal(const char *exp_str,
char **princs;
int num_princs;
int i;
krb5_error_code ret = 0;
krb5_error_code saved_ret = 0, ret = 0;
krb5_principal princ_ent;
int is_expr;
@@ -527,12 +531,17 @@ foreach_principal(const char *exp_str,
continue;
}
ret = (*func)(princ_ent, data);
if(ret)
if(ret) {
krb5_warn(context, ret, "%s %s", funcname, princs[i]);
if (saved_ret == 0)
saved_ret = ret;
}
krb5_free_principal(context, princ_ent);
}
if (ret == 0 && saved_ret != 0)
ret = saved_ret;
kadm5_free_name_list(kadm_handle, princs, &num_princs);
return 0;
return ret;
}
/*