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