49a82f861b2c4478e8024f6c8006298179eeb443
[openafs.git] / src / WINNT / afsd / cunlog.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <afs/param.h>
11 #include <afs/stds.h>
12
13 #include <afs/auth.h>
14 #include "cmd.h"
15 #include <afsint.h>
16 #include <winsock2.h>
17
18 static int
19 CommandProc (struct cmd_syndesc *as, void *arock)
20 {
21   afs_int32 code, ecode=0;
22   struct ktc_principal server;
23   struct cmd_item *itp;
24
25   if (as->parms[0].items) {     /* A cell is provided */
26      for (itp=as->parms[0].items; itp; itp = itp->next) {
27         strcpy(server.cell, itp->data);
28         server.instance[0] = '\0';
29         strcpy(server.name, "afs");
30         code = ktc_ForgetToken(&server);
31         if (code) {
32            printf("unlog: could not discard tickets for cell %s, code %d\n",
33                   itp->data, code);
34            ecode = code;                   /* return last error */
35         }
36      }
37   } else {
38      ecode = ktc_ForgetAllTokens ();
39      if (ecode)
40         printf("unlog: could not discard tickets, code %d\n", ecode);
41   }
42   return ecode;
43 }
44
45
46 main(argc, argv)
47   int argc;
48   char *argv[];
49
50 {
51   struct cmd_syndesc *ts;
52   afs_int32 code;
53   WSADATA WSAjunk;
54
55   WSAStartup(0x0101, &WSAjunk);
56
57   ts = cmd_CreateSyntax(NULL, CommandProc, NULL, "Release Kerberos authentication");
58   cmd_AddParm(ts, "-cell", CMD_LIST, CMD_OPTIONAL, "cell name");
59
60   code = cmd_Dispatch(argc, argv);
61   return (code);
62 }