Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/passwd - Pull in pwd.h since `struct passwd' is now ...
details: https://anonhg.NetBSD.org/src/rev/c9578283f25f
branches: trunk
changeset: 494428:c9578283f25f
user: ad <ad%NetBSD.org@localhost>
date: Thu Jul 06 11:19:39 2000 +0000
description:
- Pull in pwd.h since `struct passwd' is now used in extern.h.
- Use pwd_gensalt().
diffstat:
usr.bin/passwd/krb5_passwd.c | 4 ++--
usr.bin/passwd/local_passwd.c | 35 ++++++++---------------------------
usr.bin/passwd/passwd.c | 5 +++--
usr.bin/passwd/yp_passwd.c | 22 +++++++++-------------
4 files changed, 22 insertions(+), 44 deletions(-)
diffs (165 lines):
diff -r 6c7134764832 -r c9578283f25f usr.bin/passwd/krb5_passwd.c
--- a/usr.bin/passwd/krb5_passwd.c Thu Jul 06 11:17:25 2000 +0000
+++ b/usr.bin/passwd/krb5_passwd.c Thu Jul 06 11:19:39 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: krb5_passwd.c,v 1.8 2000/06/20 06:00:37 thorpej Exp $ */
+/* $NetBSD: krb5_passwd.c,v 1.9 2000/07/06 11:19:39 ad Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -40,8 +40,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
#include <err.h>
+#include <pwd.h>
#include <openssl/des.h>
#include <krb5.h>
diff -r 6c7134764832 -r c9578283f25f usr.bin/passwd/local_passwd.c
--- a/usr.bin/passwd/local_passwd.c Thu Jul 06 11:17:25 2000 +0000
+++ b/usr.bin/passwd/local_passwd.c Thu Jul 06 11:19:39 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: local_passwd.c,v 1.19 2000/02/14 04:36:21 aidan Exp $ */
+/* $NetBSD: local_passwd.c,v 1.20 2000/07/06 11:19:39 ad Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)local_passwd.c 8.3 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: local_passwd.c,v 1.19 2000/02/14 04:36:21 aidan Exp $");
+__RCSID("$NetBSD: local_passwd.c,v 1.20 2000/07/06 11:19:39 ad Exp $");
#endif
#endif /* not lint */
@@ -66,21 +66,6 @@
char *tempname;
-static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
- "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
-void
-to64(s, v, n)
- char *s;
- long v;
- int n;
-{
- while (--n >= 0) {
- *s++ = itoa64[v&0x3f];
- v >>= 6;
- }
-}
-
static char *
getnewpasswd(pw, min_pw_len)
struct passwd *pw;
@@ -88,7 +73,7 @@
{
int tries;
char *p, *t;
- char buf[_PASSWORD_LEN+1], salt[9];
+ char buf[_PASSWORD_LEN+1], salt[_PASSWORD_LEN+1];
(void)printf("Changing local password for %s.\n", pw->pw_name);
@@ -127,15 +112,11 @@
break;
(void)printf("Mismatch; try again, EOF to quit.\n");
}
- /* grab a random printable character that isn't a colon */
- (void)srandom((int)time((time_t *)NULL));
-#ifdef NEWSALT
- salt[0] = _PASSWORD_EFMT1;
- to64(&salt[1], (long)(29 * 25), 4);
- to64(&salt[5], random(), 4);
-#else
- to64(&salt[0], random(), 2);
-#endif
+
+ if(!pwd_gensalt(salt, _PASSWORD_LEN, pw, 'l')) {
+ (void)printf("Couldn't generate salt.\n");
+ pw_error(NULL, 0, 0);
+ }
return(crypt(buf, salt));
}
diff -r 6c7134764832 -r c9578283f25f usr.bin/passwd/passwd.c
--- a/usr.bin/passwd/passwd.c Thu Jul 06 11:17:25 2000 +0000
+++ b/usr.bin/passwd/passwd.c Thu Jul 06 11:19:39 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: passwd.c,v 1.19 2000/07/03 02:51:28 matt Exp $ */
+/* $NetBSD: passwd.c,v 1.20 2000/07/06 11:19:40 ad Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "from: @(#)passwd.c 8.3 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: passwd.c,v 1.19 2000/07/03 02:51:28 matt Exp $");
+__RCSID("$NetBSD: passwd.c,v 1.20 2000/07/06 11:19:40 ad Exp $");
#endif
#endif /* not lint */
@@ -52,6 +52,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <pwd.h>
#include "extern.h"
diff -r 6c7134764832 -r c9578283f25f usr.bin/passwd/yp_passwd.c
--- a/usr.bin/passwd/yp_passwd.c Thu Jul 06 11:17:25 2000 +0000
+++ b/usr.bin/passwd/yp_passwd.c Thu Jul 06 11:19:39 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: yp_passwd.c,v 1.22 2000/02/14 04:36:21 aidan Exp $ */
+/* $NetBSD: yp_passwd.c,v 1.23 2000/07/06 11:19:40 ad Exp $ */
/*
* Copyright (c) 1988, 1990, 1993, 1994
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)local_passwd.c 8.3 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: yp_passwd.c,v 1.22 2000/02/14 04:36:21 aidan Exp $");
+__RCSID("$NetBSD: yp_passwd.c,v 1.23 2000/07/06 11:19:40 ad Exp $");
#endif
#endif /* not lint */
@@ -242,8 +242,8 @@
int tries;
char *p, *t;
static char buf[_PASSWORD_LEN+1];
- char salt[9];
-
+ char salt[_PASSWORD_LEN+1];
+
(void)printf("Changing YP password for %s.\n", pw->pw_name);
if (old_pass) {
@@ -284,15 +284,11 @@
break;
(void)printf("Mismatch; try again, EOF to quit.\n");
}
- /* grab a random printable character that isn't a colon */
- (void)srandom((int)time((time_t *)NULL));
-#ifdef NEWSALT
- salt[0] = _PASSWORD_EFMT1;
- to64(&salt[1], (long)(29 * 25), 4);
- to64(&salt[5], random(), 4);
-#else
- to64(&salt[0], random(), 2);
-#endif
+
+ if(!pwd_gensalt(salt, _PASSWORD_LEN, pw, 'y' )) {
+ (void)printf("Couldn't generate salt.\n");
+ pw_error(NULL, 0, 0);
+ }
return(strdup(crypt(buf, salt)));
}
Home |
Main Index |
Thread Index |
Old Index