home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / kerberosIV / kdestroy / kdestroy.c next >
Encoding:
C/C++ Source or Header  |  1991-02-25  |  1.5 KB  |  80 lines

  1. /*
  2.  * $Source: /usr/src/kerberosIV/kdestroy/RCS/kdestroy.c,v $
  3.  * $Author: bostic $ 
  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 <mit-copyright.h>
  18.  
  19. #ifndef    lint
  20. static char rcsid_kdestroy_c[] =
  21. "$Header: /usr/src/kerberosIV/kdestroy/RCS/kdestroy.c,v 4.8 91/02/25 15:37:38 bostic Exp $";
  22. #endif    lint
  23.  
  24. #include <stdio.h>
  25. #include <des.h>
  26. #include <krb.h>
  27. #include <string.h>
  28.  
  29. static char *pname;
  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 != 0 && k_errno != RET_TKFIL)
  57.         exit(1);
  58.     else
  59.         exit(0);
  60.     } else {
  61.     if (k_errno == 0)
  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 (error).\n");
  67.         if (!qflag)
  68.         fprintf(stderr, "\007");
  69.         exit(1);
  70.     }
  71.     }
  72.     exit(0);
  73. }
  74.  
  75. usage()
  76. {
  77.     fprintf(stderr, "usage: %s [-fq]\n", pname);
  78.     exit(1);
  79. }
  80.