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