]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Add hints for -A flag to kdestroy
authorMatt Rogers <mrogers@redhat.com>
Tue, 26 Jan 2016 19:59:43 +0000 (14:59 -0500)
committerGreg Hudson <ghudson@mit.edu>
Thu, 7 Jul 2016 14:41:43 +0000 (10:41 -0400)
When using a collection ccache, a user accustomed to the FILE ccache
behavior may not be aware of all active caches, and the default
kdestroy command could make it seem like there is no active cache
left.  Print a warning to use -A after kdestroy if there are other
caches.

ticket: 8451 (new)

src/clients/kdestroy/kdestroy.c

index 410d6cf4cbe68995f670d65a7d258ae076b3a427..214643b807e96fa8d237e9da8335779164ad066c 100644 (file)
@@ -60,6 +60,30 @@ static void usage()
     exit(2);
 }
 
+/* Print a warning if there are still un-destroyed caches in the collection. */
+static void
+print_remaining_cc_warning(krb5_context context)
+{
+    krb5_error_code retval;
+    krb5_ccache cache;
+    krb5_cccol_cursor cursor;
+
+    retval = krb5_cccol_cursor_new(context, &cursor);
+    if (retval) {
+        com_err(progname, retval, _("while listing credential caches"));
+        exit(1);
+    }
+
+    retval = krb5_cccol_cursor_next(context, cursor, &cache);
+    if (retval == 0 && cache != NULL) {
+        fprintf(stderr,
+                _("Other credential caches present, use -A to destroy all\n"));
+        krb5_cc_close(context, cache);
+    }
+
+    krb5_cccol_cursor_free(context, &cursor);
+}
+
 int
 main(argc, argv)
     int argc;
@@ -172,5 +196,9 @@ main(argc, argv)
             errflg = 1;
         }
     }
+
+    if (!quiet && !errflg)
+        print_remaining_cc_warning(kcontext);
+
     return errflg;
 }