summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal/kuser/kdestroy.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/heimdal/kuser/kdestroy.c')
-rw-r--r--crypto/heimdal/kuser/kdestroy.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/crypto/heimdal/kuser/kdestroy.c b/crypto/heimdal/kuser/kdestroy.c
index 4d23245..5358fcd 100644
--- a/crypto/heimdal/kuser/kdestroy.c
+++ b/crypto/heimdal/kuser/kdestroy.c
@@ -32,15 +32,18 @@
*/
#include "kuser_locl.h"
-RCSID("$Id: kdestroy.c,v 1.14.2.1 2003/05/08 18:59:17 lha Exp $");
+RCSID("$Id: kdestroy.c 20458 2007-04-19 20:41:27Z lha $");
static const char *cache;
+static const char *credential;
static int help_flag;
static int version_flag;
static int unlog_flag = 1;
static int dest_tkt_flag = 1;
struct getargs args[] = {
+ { "credential", 0, arg_string, &credential,
+ "remove one credential", "principal" },
{ "cache", 'c', arg_string, &cache, "cache to destroy", "cache" },
{ "unlog", 0, arg_negative_flag, &unlog_flag,
"do not destroy tokens", NULL },
@@ -65,12 +68,12 @@ main (int argc, char **argv)
krb5_error_code ret;
krb5_context context;
krb5_ccache ccache;
- int optind = 0;
+ int optidx = 0;
int exit_val = 0;
setprogname (argv[0]);
- if(getarg(args, num_args, argc, argv, &optind))
+ if(getarg(args, num_args, argc, argv, &optidx))
usage(1);
if (help_flag)
@@ -81,8 +84,8 @@ main (int argc, char **argv)
exit(0);
}
- argc -= optind;
- argv += optind;
+ argc -= optidx;
+ argv += optidx;
if (argc != 0)
usage (1);
@@ -99,11 +102,32 @@ main (int argc, char **argv)
}
}
- ret = krb5_cc_resolve(context,
+ ret = krb5_cc_resolve(context,
cache,
&ccache);
if (ret == 0) {
+ if (credential) {
+ krb5_creds mcred;
+
+ krb5_cc_clear_mcred(&mcred);
+
+ ret = krb5_parse_name(context, credential, &mcred.server);
+ if (ret)
+ krb5_err(context, 1, ret,
+ "Can't parse principal %s", credential);
+
+ ret = krb5_cc_remove_cred(context, ccache, 0, &mcred);
+ if (ret)
+ krb5_err(context, 1, ret,
+ "Failed to remove principal %s", credential);
+
+ krb5_cc_close(context, ccache);
+ krb5_free_principal(context, mcred.server);
+ krb5_free_context(context);
+ return 0;
+ }
+
ret = krb5_cc_destroy (context, ccache);
if (ret) {
warnx ("krb5_cc_destroy: %s", krb5_get_err_text(context, ret));
@@ -117,10 +141,6 @@ main (int argc, char **argv)
krb5_free_context (context);
-#if KRB4
- if(dest_tkt_flag && dest_tkt ())
- exit_val = 1;
-#endif
if (unlog_flag && k_hasafs ()) {
if (k_unlog ())
exit_val = 1;
OpenPOWER on IntegriCloud