diff options
author | markm <markm@FreeBSD.org> | 1995-12-16 09:45:17 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 1995-12-16 09:45:17 +0000 |
commit | 2d2185e129a0b9591326cf6780f33103e6daf487 (patch) | |
tree | 7cda69034c3f75363c1c91fd1cdf9f6f9b2de853 /usr.bin | |
parent | c141a4f4bb83940bb7b6208d7605034c71eca2a2 (diff) | |
download | FreeBSD-src-2d2185e129a0b9591326cf6780f33103e6daf487.zip FreeBSD-src-2d2185e129a0b9591326cf6780f33103e6daf487.tar.gz |
1) Fix local_passwd to co-operate with dual-personality crypt(3).
Changing a local passwd will now keep the encryption type that
was originally used to encrypt the password, so folks adding DES
to their systems will not be irritated/confused by having MD5'ed
passwords in their master.passwd. Coming later is an option to
allow the user to choose the encryption type.
2) Fix a bunch of compiler warnings announced by turning on -Wall.
I did not get them all, that will come a bit later.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/passwd/local_passwd.c | 22 | ||||
-rw-r--r-- | usr.bin/passwd/passwd.c | 11 | ||||
-rw-r--r-- | usr.bin/passwd/yp_passwd.c | 3 |
3 files changed, 26 insertions, 10 deletions
diff --git a/usr.bin/passwd/local_passwd.c b/usr.bin/passwd/local_passwd.c index b98bba3..aefd9af 100644 --- a/usr.bin/passwd/local_passwd.c +++ b/usr.bin/passwd/local_passwd.c @@ -29,10 +29,12 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $Id$ */ #ifndef lint -static char sccsid[] = "@(#)local_passwd.c 8.3 (Berkeley) 4/2/94"; +static const char sccsid[] = "@(#)local_passwd.c 8.3 (Berkeley) 4/2/94"; #endif /* not lint */ #include <sys/types.h> @@ -124,11 +126,21 @@ getnewpasswd(pw, nis) salt[9] = '\0'; #else /* Make a good size salt for algoritms that can use it. */ - to64(&salt[0], random(), 3); gettimeofday(&tv,0); - to64(&salt[3], tv.tv_usec, 3); - to64(&salt[6], tv.tv_sec, 2); - salt[8] = '\0'; + if (strncmp(pw->pw_passwd, "$1$", 3)) { + /* DES Salt */ + to64(&salt[0], random(), 3); + to64(&salt[3], tv.tv_usec, 3); + to64(&salt[6], tv.tv_sec, 2); + salt[8] = '\0'; + } + else { + /* MD5 Salt */ + strncpy(&salt[0], "$1$", 3); + to64(&salt[3], random(), 3); + to64(&salt[6], tv.tv_usec, 3); + salt[8] = '\0'; + } #endif return (crypt(buf, salt)); } diff --git a/usr.bin/passwd/passwd.c b/usr.bin/passwd/passwd.c index 31e005d..92dd895 100644 --- a/usr.bin/passwd/passwd.c +++ b/usr.bin/passwd/passwd.c @@ -29,18 +29,21 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $id$ + * */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1988, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -static char sccsid[] = "From: @(#)passwd.c 8.3 (Berkeley) 4/2/94"; +static const char sccsid[] = "From: @(#)passwd.c 8.3 (Berkeley) 4/2/94"; static const char rcsid[] = - "$Id: passwd.c,v 1.5 1995/08/13 16:07:35 wpaul Exp $"; + "$Id$"; #endif /* not lint */ #include <err.h> @@ -48,12 +51,14 @@ static const char rcsid[] = #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <string.h> #ifdef YP #include <pwd.h> #include <pw_yp.h> char *prog_name; int __use_yp = 0; +int yp_passwd(char *user); #endif #ifdef KERBEROS diff --git a/usr.bin/passwd/yp_passwd.c b/usr.bin/passwd/yp_passwd.c index 86811e3..fc6b0e4 100644 --- a/usr.bin/passwd/yp_passwd.c +++ b/usr.bin/passwd/yp_passwd.c @@ -91,7 +91,7 @@ yp_passwd(char *user) struct passwd *pw; CLIENT *clnt; char *master; - int c, err, status; + int err, status; char *s; if ((master = getserver()) == NULL) { @@ -136,7 +136,6 @@ yp_passwd(char *user) /* Get old password */ if(pw->pw_passwd[0]) { - char prompt[40]; s = getpass ("Old password: "); if( strcmp(crypt(s, pw->pw_passwd), pw->pw_passwd)) { |