Remove the RCSID macro
[openafs.git] / src / kauth / kas.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 /* These two needed for rxgen output to work */
11 #include <afsconfig.h>
12 #include <afs/param.h>
13
14
15 #include <afs/stds.h>
16 #ifdef  AFS_AIX32_ENV
17 #include <signal.h>
18 #endif
19
20 #include <sys/types.h>
21 #include <rx/xdr.h>
22
23 #include <lock.h>
24 #include <ubik.h>
25 #ifndef AFS_NT40_ENV
26 #include <pwd.h>
27 #else
28 #include <WINNT/afsevent.h>
29 #endif
30 #include <string.h>
31 #include <afs/cellconfig.h>
32 #include <afs/com_err.h>
33
34 #include "kauth.h"
35 #include "kautils.h"
36
37
38 int
39 main(int argc, char *argv[])
40 {
41     afs_int32 code;
42     char *ap[25];
43     int i;
44     char *whoami = argv[0];
45
46 #ifdef  AFS_AIX32_ENV
47     /*
48      * The following signal action for AIX is necessary so that in case of a 
49      * crash (i.e. core is generated) we can include the user's data section 
50      * in the core dump. Unfortunately, by default, only a partial core is
51      * generated which, in many cases, isn't too useful.
52      */
53     struct sigaction nsa;
54
55     sigemptyset(&nsa.sa_mask);
56     nsa.sa_handler = SIG_DFL;
57     nsa.sa_flags = SA_FULLDUMP;
58     sigaction(SIGABRT, &nsa, NULL);
59     sigaction(SIGSEGV, &nsa, NULL);
60 #endif
61     initialize_CMD_error_table();
62     initialize_KTC_error_table();
63     initialize_KA_error_table();
64     initialize_ACFG_error_table();
65     initialize_U_error_table();
66
67 #ifdef AFS_NT40_ENV
68     /* initialize winsock */
69     if (afs_winsockInit() < 0) {
70         fprintf(stderr, "%s: Couldn't initialize winsock.\n", whoami);
71         exit(1);
72     }
73 #endif
74
75     code = ka_Init(0);
76     if (code) {
77         afs_com_err(whoami, code, "Can't get cell info");
78         exit(1);
79     }
80
81     /* if there are no arguments or if the first argument is "-cell" or if the
82      * first argument is clearly a username (it contains a '.' or '@') assume
83      * the interactive command and splice it into the arglist. */
84
85     ap[0] = argv[0];
86     ap[1] = "interactive";
87     if (argc == 1)
88         code = ka_AdminInteractive(2, ap);
89     else if ((strncmp(argv[1], "-admin_username", strlen(argv[1])) == 0)
90              || (strncmp(argv[1], "-password_for_admin", strlen(argv[1])) ==
91                  0)
92              || (strncmp(argv[1], "-cell", strlen(argv[1])) == 0)
93              || (strncmp(argv[1], "-servers", strlen(argv[1])) == 0)
94              || (strncmp(argv[1], "-noauth", strlen(argv[1])) == 0)
95              || (strpbrk(argv[1], "@.") != 0)) {
96         for (i = 1; i < argc; i++)
97             ap[i + 1] = argv[i];
98         code = ka_AdminInteractive(argc + 1, ap);
99     } else
100         code = ka_AdminInteractive(argc, argv);
101
102     rx_Finalize();
103     exit(code != 0);
104 }