summaryrefslogtreecommitdiff
path: root/usr.bin/passwd/local_passwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/passwd/local_passwd.c')
-rw-r--r--usr.bin/passwd/local_passwd.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c
index 0a81ab1dce184..7eec89289c0f4 100644
--- a/usr.bin/passwd/local_passwd.c
+++ b/usr.bin/passwd/local_passwd.c
@@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)local_passwd.c 5.5 (Berkeley) 5/6/91";*/
-static char rcsid[] = "$Id: local_passwd.c,v 1.4 1994/01/11 19:01:13 nate Exp $";
+static char rcsid[] = "$Id: local_passwd.c,v 1.7 1994/05/20 00:29:19 ache Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -81,8 +81,17 @@ local_passwd(uname)
pw->pw_change = 0;
pw_copy(pfd, tfd, pw);
- if (!pw_mkdb())
- pw_error((char *)NULL, 0, 1);
+ /*
+ * Attempt a recovery if the incremental database update failed by
+ * handing off to the real password hashing program to remake the
+ * whole mess. Even though this costs lots of time it's better than
+ * having the password databases out of sync with the master pw file.
+ */
+ if (pw_fastmkdb(pw) < 0) {
+ fprintf(stderr,"%s: WARNING!! Password database mangled, recreating it from scratch\n", progname);
+ if(!pw_mkdb())
+ pw_error((char *)NULL, 0, 1);
+ }
return(0);
}