Add kdestroy --all/-A
This commit is contained in:
@@ -41,11 +41,13 @@ static int version_flag;
|
|||||||
static int unlog_flag = 1;
|
static int unlog_flag = 1;
|
||||||
#endif
|
#endif
|
||||||
static int dest_tkt_flag = 1;
|
static int dest_tkt_flag = 1;
|
||||||
|
static int all_flag = 0;
|
||||||
|
|
||||||
struct getargs args[] = {
|
struct getargs args[] = {
|
||||||
{ "credential", 0, arg_string, &credential,
|
{ "credential", 0, arg_string, &credential,
|
||||||
"remove one credential", "principal" },
|
"remove one credential", "principal" },
|
||||||
{ "cache", 'c', arg_string, &cache, "cache to destroy", "cache" },
|
{ "cache", 'c', arg_string, &cache, "cache to destroy", "cache" },
|
||||||
|
{ "all", 'A', arg_flag, &all_flag, "destroy all caches" },
|
||||||
#ifndef NO_AFS
|
#ifndef NO_AFS
|
||||||
{ "unlog", 0, arg_negative_flag, &unlog_flag,
|
{ "unlog", 0, arg_negative_flag, &unlog_flag,
|
||||||
"do not destroy tokens", NULL },
|
"do not destroy tokens", NULL },
|
||||||
@@ -97,17 +99,35 @@ main (int argc, char **argv)
|
|||||||
if (ret)
|
if (ret)
|
||||||
errx (1, "krb5_init_context failed: %d", ret);
|
errx (1, "krb5_init_context failed: %d", ret);
|
||||||
|
|
||||||
if(cache == NULL) {
|
if (all_flag) {
|
||||||
cache = krb5_cc_default_name(context);
|
krb5_cccol_cursor cursor;
|
||||||
if (cache == NULL) {
|
|
||||||
warnx ("krb5_cc_default_name: %s", krb5_get_err_text(context, ret));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ret = krb5_cccol_cursor_new (context, &cursor);
|
||||||
|
if (ret)
|
||||||
|
krb5_err(context, 1, ret, "krb5_cccol_cursor_new");
|
||||||
|
|
||||||
|
while (krb5_cccol_cursor_next (context, cursor, &ccache) == 0 && ccache != NULL) {
|
||||||
|
|
||||||
|
ret = krb5_cc_destroy (context, ccache);
|
||||||
|
if (ret) {
|
||||||
|
krb5_warn(context, ret, "krb5_cc_destroy");
|
||||||
|
exit_val = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
krb5_cccol_cursor_free(context, &cursor);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if(cache == NULL) {
|
||||||
|
ret = krb5_cc_default(context, &ccache);
|
||||||
|
if (ret)
|
||||||
|
krb5_err(context, 1, ret, "krb5_cc_default");
|
||||||
|
} else {
|
||||||
ret = krb5_cc_resolve(context,
|
ret = krb5_cc_resolve(context,
|
||||||
cache,
|
cache,
|
||||||
&ccache);
|
&ccache);
|
||||||
|
if (ret)
|
||||||
|
krb5_err(context, 1, ret, "krb5_cc_resolve");
|
||||||
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
if (credential) {
|
if (credential) {
|
||||||
@@ -136,10 +156,7 @@ main (int argc, char **argv)
|
|||||||
warnx ("krb5_cc_destroy: %s", krb5_get_err_text(context, ret));
|
warnx ("krb5_cc_destroy: %s", krb5_get_err_text(context, ret));
|
||||||
exit_val = 1;
|
exit_val = 1;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
warnx ("krb5_cc_resolve(%s): %s", cache,
|
|
||||||
krb5_get_err_text(context, ret));
|
|
||||||
exit_val = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
krb5_free_context (context);
|
krb5_free_context (context);
|
||||||
|
Reference in New Issue
Block a user