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 migration toolkit when migrating his password information
18 #include <afsconfig.h>
19 #include <afs/param.h>
25 #include <sys/types.h>
42 #include <afs/com_err.h>
44 #include <afs/cellconfig.h>
45 #include <afs/afsutil.h>
54 "Please read the following message before entering your password.",
56 "This program will display your new, temporary DCE password on your",
57 "terminal, and you should change the assigned password as soon as",
58 "possible (from a DCE client). The program assumes that your site uses",
59 "the standard AFS authentication service provided by Transarc and that",
60 "your initial account was created from the AFS authentication",
61 "information by Transarc-supplied migration software. If this is not",
62 "the case, you should consult your system administrator. The password",
63 "you enter should be the AFS password that was in effect when your DCE",
64 "account was created; this is not necessarily the same password you",
65 "have at the moment. The cell name (which you may override with a",
66 "command line option), must be the name of the AFS cell from which the",
67 "authentication information was taken.",
71 CommandProc(as, arock)
73 struct cmd_syndesc *as;
77 struct ktc_encryptionKey key;
78 char cell[MAXKTCREALMLEN];
83 * We suppress the message, above, if this environment variable
84 * is set. This allows the administrator to wrap dpass in a shell
85 * script, if desired, in order to display more information
86 * about registry conversion dates, etc.
88 if (!getenv("DPASS_NO_MESSAGE")) {
89 for (i = 0; msg[i]; i++)
90 printf("%s\n", msg[i]);
93 if (as->parms[0].items) {
94 struct afsconf_cell cellinfo;
95 struct afsconf_dir *cdir;
97 cell_p = as->parms[0].items->data;
98 cdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
101 "\nUnable to verify that \"%s\" is a valid cell name\nProceeding on the assumption that it is correct.\n",
105 code = afsconf_GetCellInfo(cdir, cell_p, 0, &cellinfo);
108 "\nUnable to find information about cell \"%s\"\nProceeding on the assumption that this is a valid cell name.\n",
111 strncpy(cell, cellinfo.name, sizeof(cell) - 1);
112 cell[sizeof(cell)] = '\0';
116 struct afsconf_dir *cdir;
118 cdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
121 "\nUnable to read the AFS client configuration file to get local cell name.\nTry specifying the cell with the -cell switch.\n");
124 afsconf_GetLocalCell(cdir, cell, sizeof(cell));
129 sprintf(prompt, "Original password for AFS cell %s: ", cell_p);
130 code = ka_ReadPassword(prompt, 1, cell_p, &key);
132 fprintf(stderr, "Error reading password\n");
135 #define k(i) (key.data[i] & 0xff)
136 #define s(n) ((k(n) << 8) | k(n+1))
137 printf("\nThe new DCE password is: %0.4x-%0.4x-%0.4x-%0.4x\n", s(0), s(2),
145 struct cmd_syndesc *ts;
149 * The following signal action for AIX is necessary so that in case of a
150 * crash (i.e. core is generated) we can include the user's data section
151 * in the core dump. Unfortunately, by default, only a partial core is
152 * generated which, in many cases, isn't too useful.
154 struct sigaction nsa;
156 sigemptyset(&nsa.sa_mask);
157 nsa.sa_handler = SIG_DFL;
158 nsa.sa_flags = SA_FULLDUMP;
159 sigaction(SIGSEGV, &nsa, NULL);
161 ts = cmd_CreateSyntax(NULL, CommandProc, 0, "show new DCE passord");
162 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL,
163 "original AFS cell name");
164 code = cmd_Dispatch(argc, argv);