xref: /original-bsd/old/athena/kdestroy/kdestroy.c (revision 87febec0)
1 /*
2  * $Source: /mit/kerberos/src/kuser/RCS/kdestroy.c,v $
3  * $Author: steiner $
4  *
5  * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
6  *
7  * For copying and distribution information, please see the file
8  * <mit-copyright.h>.
9  *
10  * This program causes Kerberos tickets to be destroyed.
11  * Options are:
12  *
13  *   -q[uiet]	- no bell even if tickets not destroyed
14  *   -f[orce]	- no message printed at all
15  */
16 
17 #include <kerberos/mit-copyright.h>
18 
19 #ifndef	lint
20 static char rcsid_kdestroy_c[] =
21 "$Header: kdestroy.c,v 4.5 88/03/18 15:16:02 steiner Exp $";
22 #endif	lint
23 
24 #include <stdio.h>
25 #include <kerberos/krb.h>
26 #include <strings.h>
27 
28 static char *pname;
29 
30 
31 main(argc, argv)
32     char   *argv[];
33 {
34     int     fflag=0, qflag=0, k_errno;
35     register char *cp;
36 
37     cp = rindex (argv[0], '/');
38     if (cp == NULL)
39 	pname = argv[0];
40     else
41 	pname = cp+1;
42 
43     if (argc > 2)
44 	usage();
45     else if (argc == 2) {
46 	if (!strcmp(argv[1], "-f"))
47 	    ++fflag;
48 	else if (!strcmp(argv[1], "-q"))
49 	    ++qflag;
50 	else usage();
51     }
52 
53     k_errno = dest_tkt();
54 
55     if (fflag) {
56 	if (k_errno != KSUCCESS && k_errno != RET_TKFIL)
57 	    exit(1);
58 	else
59 	    exit(0);
60     } else {
61 	if (k_errno == KSUCCESS)
62 	    printf("Tickets destroyed.\n");
63 	else if (k_errno == RET_TKFIL)
64 	    fprintf(stderr, "No tickets to destroy.\n");
65 	else {
66 	    fprintf(stderr, "Tickets NOT destroyed.\n");
67 	    if (!qflag)
68 		fprintf(stderr, "\007");
69 	    exit(1);
70 	}
71     }
72     exit(0);
73 }
74 
75 static usage()
76 {
77     fprintf(stderr, "Usage: %s [-f] [-q]\n", pname);
78     exit(1);
79 }
80