- Pull in pwd.h since `struct passwd' is now used in extern.h.

- Use pwd_gensalt().
This commit is contained in:
ad 2000-07-06 11:19:39 +00:00
parent 44f550958a
commit 34e4fc5261
4 changed files with 22 additions and 44 deletions

View File

@ -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>

View File

@ -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 @@ static int force_local;
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 @@ getnewpasswd(pw, min_pw_len)
{
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 @@ getnewpasswd(pw, min_pw_len)
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));
}

View File

@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993, 1994\n\
#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 @@ __RCSID("$NetBSD: passwd.c,v 1.19 2000/07/03 02:51:28 matt Exp $");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pwd.h>
#include "extern.h"

View File

@ -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 @@ getnewpasswd(pw, old_pass)
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 @@ getnewpasswd(pw, old_pass)
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)));
}