2 * Copyright 2000, International Business Machines Corporation and others.
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
13 * This program allows a user to discover the password generated for him
14 * by the transarc migration toolkit when migrating his password information
18 #include <afs/param.h>
19 #include <afsconfig.h>
24 #include <sys/types.h>
34 #include <afs/com_err.h>
36 #include <afs/cellconfig.h>
37 #include <afs/afsutil.h>
46 "Please read the following message before entering your password.",
48 "This program will display your new, temporary DCE password on your",
49 "terminal, and you should change the assigned password as soon as",
50 "possible (from a DCE client). The program assumes that your site uses",
51 "the standard AFS authentication service provided by Transarc and that",
52 "your initial account was created from the AFS authentication",
53 "information by Transarc-supplied migration software. If this is not",
54 "the case, you should consult your system administrator. The password",
55 "you enter should be the AFS password that was in effect when your DCE",
56 "account was created; this is not necessarily the same password you",
57 "have at the moment. The cell name (which you may override with a",
58 "command line option), must be the name of the AFS cell from which the",
59 "authentication information was taken.",
63 CommandProc (as, arock)
65 struct cmd_syndesc *as;
69 struct ktc_encryptionKey key;
70 char cell[MAXKTCREALMLEN];
75 * We suppress the message, above, if this environment variable
76 * is set. This allows the administrator to wrap dpass in a shell
77 * script, if desired, in order to display more information
78 * about registry conversion dates, etc.
80 if (!getenv("DPASS_NO_MESSAGE")) {
81 for (i = 0; msg[i]; i++) printf("%s\n", msg[i]);
84 if (as->parms[0].items) {
85 struct afsconf_cell cellinfo;
86 struct afsconf_dir *cdir;
88 cell_p = as->parms[0].items->data;
89 cdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
91 fprintf(stderr, "\nUnable to verify that \"%s\" is a valid cell name\nProceeding on the assumption that it is correct.\n", cell_p);
94 code = afsconf_GetCellInfo(cdir, cell_p, 0, &cellinfo);
96 fprintf(stderr, "\nUnable to find information about cell \"%s\"\nProceeding on the assumption that this is a valid cell name.\n", cell_p);
98 strncpy(cell, cellinfo.name, sizeof(cell) - 1);
99 cell[sizeof(cell)] = '\0';
103 struct afsconf_dir *cdir;
105 cdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
107 fprintf(stderr, "\nUnable to read the AFS client configuration file to get local cell name.\nTry specifying the cell with the -cell switch.\n");
110 afsconf_GetLocalCell(cdir, cell, sizeof(cell));
115 sprintf(prompt, "Original password for AFS cell %s: ", cell_p);
116 code = ka_ReadPassword(prompt, 1, cell_p, &key);
118 fprintf(stderr, "Error reading password\n");
121 #define k(i) (key.data[i] & 0xff)
122 #define s(n) ((k(n) << 8) | k(n+1))
123 printf("\nThe new DCE password is: %0.4x-%0.4x-%0.4x-%0.4x\n",
124 s(0), s(2), s(4), s(6));
130 { struct cmd_syndesc *ts;
134 * The following signal action for AIX is necessary so that in case of a
135 * crash (i.e. core is generated) we can include the user's data section
136 * in the core dump. Unfortunately, by default, only a partial core is
137 * generated which, in many cases, isn't too useful.
139 struct sigaction nsa;
141 sigemptyset(&nsa.sa_mask);
142 nsa.sa_handler = SIG_DFL;
143 nsa.sa_flags = SA_FULLDUMP;
144 sigaction(SIGSEGV, &nsa, NULL);
146 ts = cmd_CreateSyntax((char *) 0, CommandProc, 0, "show new DCE passord");
147 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL,"original AFS cell name");
148 code = cmd_Dispatch(argc, argv);