9 date 92.12.15.00.20.22; author jromine; state Exp;
14 date 92.02.03.17.53.37; author jromine; state Exp;
19 date 90.04.05.15.34.47; author sources; state Exp;
24 date 90.04.05.14.54.09; author sources; state Exp;
29 date 90.02.05.14.08.37; author sources; state Exp;
34 date 90.02.05.13.59.17; author sources; state Exp;
39 date 90.02.05.13.59.09; author sources; state Exp;
53 @/* popwrd.c - set password for a POP subscriber */
55 static char ident[] = "@@(#)$Id: popwrd.c,v 1.6 1992/02/03 17:53:37 jromine Exp jromine $";
58 #include "../h/strings.h"
59 #include "../zotnet/bboards.h"
64 #include <sys/types.h>
72 struct passwd *getpwnam();
76 static char temp[] = "ptmp";
77 static char home[BUFSIZ];
81 char *crypt (), *getpass (), *tail ();
84 #define compar(s,t) (strcmp (s, t) ? s : "")
109 if ((pw = getpwnam (POPUID)) == NULL) {
110 fprintf (stderr, "no entry for ~%s.\n", POPUID);
113 if (chdir (strcpy (home, pw -> pw_dir)) < 0) {
114 fprintf (stderr, "no home directory for ~%s.\n", POPUID);
117 if (!setpwinfo (pw, POPDB, 0)) {
118 fprintf (stderr, "setbbinfo(%s, %s, 0) failed -- %s.\n",
119 pw -> pw_name, POPDB, getbberr ());
124 fprintf (stderr, "usage: %s pop-subscriber\n", *argv);
127 if ((bb = getbbnam (argv[1])) == NULL
128 && (bb = getbbaka (argv[1])) == NULL) {
129 fprintf (stderr, "Permission denied.\n");
133 if (!ldrbb (bb) && getuid () && !ldrchk (bb))
136 if ((bp = getbbcpy (bb)) == NULL) {
137 fprintf (stderr, "getbbcpy loses.\n");
146 for (insist = 0; insist < 2; insist++) {
148 printf ("Please use %s.\n",
149 flags == 1 ? "at least one non-numeric character"
150 : "a longer password");
152 if ((i = strlen (strcpy (buffer, getpass ("New password:")))) == 0) {
153 fprintf (stderr, "Password unchanged.\n");
158 for (cp = buffer; c = *cp++;)
159 if (c >= 'a' && c <= 'z')
162 if (c >= 'A' && c <= 'Z')
165 if (c >= '0' && c <= '9')
170 if ((flags >= 7 && i >= 4)
171 || ((flags == 2 || flags == 4) && i >= 6)
172 || ((flags == 3 || flags == 5 || flags == 6) && i >= 5))
176 if (strcmp (buffer, getpass ("Retype new password:"))) {
177 fprintf (stderr, "Mismatch - password unchanged.\n");
182 salt ^= 9 * getpid ();
183 saltc[0] = salt & 077;
184 saltc[1] = (salt >> 6) & 077;
185 for (i = 0; i < 2; i++) {
193 cp = crypt (buffer, saltc);
195 (void) signal (SIGHUP, SIG_IGN);
196 (void) signal (SIGINT, SIG_IGN);
197 (void) signal (SIGQUIT, SIG_IGN);
200 if ((fd = open (temp, O_WRONLY | O_CREAT | O_EXCL, 0644)) < 0) {
203 fprintf (stderr, "POP file busy - try again later.\n");
214 (void) signal (SIGTSTP, SIG_IGN);
216 if ((fp = fdopen (fd, "w")) == NULL) {
217 fprintf (stderr, "fdopen loses.\n");
218 (void) unlink (temp);
222 (void) setbbent (SB_STAY | SB_FAST);
223 while (bb = getbbent ()) {
224 if (strcmp (bb -> bb_name, bp -> bb_name) == 0)
225 bb -> bb_passwd = cp;
226 fprintf (fp, "%s:", bb -> bb_name);
227 if (ap = bb -> bb_aka)
229 fprintf (fp, "%s%s", ap != bb -> bb_aka ? "," : "", *ap);
230 fprintf (fp, ":%s:%s:", tail (bb -> bb_file), bb -> bb_passwd);
231 if ((ap = bb -> bb_leader) != NULL
232 && (strcmp (*ap, POPUID) != 0 || ap[1] != NULL))
234 fprintf (fp, "%s%s", ap != bb -> bb_leader ? "," : "", *ap);
235 fprintf (fp, ":%s:%s:%s:",
236 compar (bb -> bb_addr, bb -> bb_name),
237 compar (bb -> bb_request, POPUID),
239 if (ap = bb -> bb_dist)
241 fprintf (fp, "%s%s", ap != bb -> bb_dist ? "," : "", *ap);
242 fprintf (fp, ":%o\n", bb -> bb_flags);
246 if (rename (temp, POPDB) < 0) {
248 (void) unlink (temp);
264 if (strncmp (s, home, i = strlen (home)) == 0
265 && *(cp = s + i) == '/'
283 static char ident[] = "@@(#)$Id: popwrd.c,v 1.5 1990/04/05 15:34:47 sources Exp jromine $";
304 static char ident[] = "@@(#)$Id:$";
316 static char ident[] = "@@(#)$Id:";
322 @*** empty log message ***
331 @*** empty log message ***