Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Jan 2000 08:00:02 -0800 (PST)
From:      Daniel Hagan <dhagan@cs.vt.edu>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/4238 - chpass time delay sensitivity [PATCH]
Message-ID:  <200001121600.IAA01959@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/4238; it has been noted by GNATS.

From: Daniel Hagan <dhagan@cs.vt.edu>
To: John Polstra <jdp@polstra.com>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/4238 - chpass time delay sensitivity [PATCH]
Date: Wed, 12 Jan 2000 10:56:56 -0500 (EST)

 Updated to use MD5 hashes to detect changes.
 
 -Daniel
 
 Index: Makefile
 ===================================================================
 RCS file: /src/cvs/src/usr.bin/chpass/Makefile,v
 retrieving revision 1.20
 diff -c -r1.20 Makefile
 *** Makefile	1999/12/18 13:55:13	1.20
 --- Makefile	2000/01/12 14:31:27
 ***************
 *** 27,34 ****
   #Some people need this, uncomment to activate
   #COPTS+= -DRESTRICT_FULLNAME_CHANGE
   
 ! DPADD=	${LIBRPCSVC} ${LIBCRYPT}
 ! LDADD+=	-lrpcsvc -lcrypt
   
   CLEANFILES= ${GENSRCS}
   
 --- 27,34 ----
   #Some people need this, uncomment to activate
   #COPTS+= -DRESTRICT_FULLNAME_CHANGE
   
 ! DPADD=	${LIBRPCSVC} ${LIBCRYPT} ${LIBMD}
 ! LDADD+=	-lrpcsvc -lcrypt -lmd
   
   CLEANFILES= ${GENSRCS}
   
 Index: edit.c
 ===================================================================
 RCS file: /src/cvs/src/usr.bin/chpass/edit.c,v
 retrieving revision 1.16
 diff -c -r1.16 edit.c
 *** edit.c	1999/12/21 19:30:09	1.16
 --- edit.c	2000/01/12 14:36:31
 ***************
 *** 39,48 ****
 --- 39,50 ----
   
   #include <sys/param.h>
   #include <sys/stat.h>
 + #include <sys/types.h>
   
   #include <ctype.h>
   #include <err.h>
   #include <errno.h>
 + #include <md5.h>
   #include <paths.h>
   #include <pwd.h>
   #include <stdio.h>
 ***************
 *** 65,81 ****
   	struct passwd *pw;
   {
   	struct stat begin, end;
   
   	for (;;) {
   		if (stat(tempname, &begin))
   			pw_error(tempname, 1, 1);
   		pw_edit(1);
   		if (stat(tempname, &end))
   			pw_error(tempname, 1, 1);
 ! 		if (begin.st_mtime == end.st_mtime) {
   			warnx("no changes made");
   			pw_error(NULL, 0, 0);
   		}
   		if (verify(pw))
   			break;
   		pw_prompt();
 --- 67,89 ----
   	struct passwd *pw;
   {
   	struct stat begin, end;
 + 	char *begin_sum, *end_sum;
   
   	for (;;) {
   		if (stat(tempname, &begin))
   			pw_error(tempname, 1, 1);
 + 		begin_sum = MD5File(tempname, (char *)NULL);
   		pw_edit(1);
   		if (stat(tempname, &end))
   			pw_error(tempname, 1, 1);
 ! 		end_sum = MD5File(tempname, (char *)NULL);
 ! 		if ((begin.st_mtime == end.st_mtime) &&
 ! 		    (strcmp(begin_sum, end_sum) == 0)) {
   			warnx("no changes made");
   			pw_error(NULL, 0, 0);
   		}
 + 		free(begin_sum);
 + 		free(end_sum);
   		if (verify(pw))
   			break;
   		pw_prompt();
 
 
 -- 
 Daniel Hagan                                             Computer Science CSE
 dhagan@cs.vt.edu                                http://www.cs.vt.edu/~dhagan/
 
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001121600.IAA01959>