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>
20 #include <sys/types.h>
30 #include <afs/com_err.h>
32 #include <afs/cellconfig.h>
33 #include <afs/afsutil.h>
42 "Please read the following message before entering your password.",
44 "This program will display your new, temporary DCE password on your",
45 "terminal, and you should change the assigned password as soon as",
46 "possible (from a DCE client). The program assumes that your site uses",
47 "the standard AFS authentication service provided by Transarc and that",
48 "your initial account was created from the AFS authentication",
49 "information by Transarc-supplied migration software. If this is not",
50 "the case, you should consult your system administrator. The password",
51 "you enter should be the AFS password that was in effect when your DCE",
52 "account was created; this is not necessarily the same password you",
53 "have at the moment. The cell name (which you may override with a",
54 "command line option), must be the name of the AFS cell from which the",
55 "authentication information was taken.",
59 CommandProc (as, arock)
61 struct cmd_syndesc *as;
65 struct ktc_encryptionKey key;
66 char cell[MAXKTCREALMLEN];
71 * We suppress the message, above, if this environment variable
72 * is set. This allows the administrator to wrap dpass in a shell
73 * script, if desired, in order to display more information
74 * about registry conversion dates, etc.
76 if (!getenv("DPASS_NO_MESSAGE")) {
77 for (i = 0; msg[i]; i++) printf("%s\n", msg[i]);
80 if (as->parms[0].items) {
81 struct afsconf_cell cellinfo;
82 struct afsconf_dir *cdir;
84 cell_p = as->parms[0].items->data;
85 cdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
87 fprintf(stderr, "\nUnable to verify that \"%s\" is a valid cell name\nProceeding on the assumption that it is correct.\n", cell_p);
90 code = afsconf_GetCellInfo(cdir, cell_p, 0, &cellinfo);
92 fprintf(stderr, "\nUnable to find information about cell \"%s\"\nProceeding on the assumption that this is a valid cell name.\n", cell_p);
94 strncpy(cell, cellinfo.name, sizeof(cell) - 1);
95 cell[sizeof(cell)] = '\0';
99 struct afsconf_dir *cdir;
101 cdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
103 fprintf(stderr, "\nUnable to read the AFS client configuration file to get local cell name.\nTry specifying the cell with the -cell switch.\n");
106 afsconf_GetLocalCell(cdir, cell, sizeof(cell));
111 sprintf(prompt, "Original password for AFS cell %s: ", cell_p);
112 code = ka_ReadPassword(prompt, 1, cell_p, &key);
114 fprintf(stderr, "Error reading password\n");
117 #define k(i) (key.data[i] & 0xff)
118 #define s(n) ((k(n) << 8) | k(n+1))
119 printf("\nThe new DCE password is: %0.4x-%0.4x-%0.4x-%0.4x\n",
120 s(0), s(2), s(4), s(6));
126 { struct cmd_syndesc *ts;
130 * The following signal action for AIX is necessary so that in case of a
131 * crash (i.e. core is generated) we can include the user's data section
132 * in the core dump. Unfortunately, by default, only a partial core is
133 * generated which, in many cases, isn't too useful.
135 struct sigaction nsa;
137 sigemptyset(&nsa.sa_mask);
138 nsa.sa_handler = SIG_DFL;
139 nsa.sa_flags = SA_FULLDUMP;
140 sigaction(SIGSEGV, &nsa, NULL);
142 ts = cmd_CreateSyntax((char *) 0, CommandProc, 0, "show new DCE passord");
143 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL,"original AFS cell name");
144 code = cmd_Dispatch(argc, argv);