From owner-freebsd-hackers Tue Mar 21 01:25:51 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id BAA12622 for hackers-outgoing; Tue, 21 Mar 1995 01:25:51 -0800 Received: from labinfo.iet.unipi.it (labinfo.iet.unipi.it [131.114.9.5]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id BAA12614 for ; Tue, 21 Mar 1995 01:25:40 -0800 Received: from localhost (luigi@localhost) by labinfo.iet.unipi.it (8.6.5/8.6.5) id JAA24384 for hackers@freebsd.org; Tue, 21 Mar 1995 09:50:24 +0100 From: Luigi Rizzo Message-Id: <199503210850.JAA24384@labinfo.iet.unipi.it> Subject: vipw feature (and fix) To: hackers@FreeBSD.org Date: Tue, 21 Mar 1995 09:50:23 +0100 (MET) X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 1488 Sender: hackers-owner@FreeBSD.org Precedence: bulk This is interesting... I was building a quick and dirty "adduser" function driven by a shell script, and thought to use vipw driven by a shell script (I thought this way locking, error checking etc would come for free..). After setting thing up, I found out that most of the times vipw would say "no changes made" even if the (temporary) master.passwd was actually changed. I thought it was me, but look at this fragment of vipw.c where the check is made for changes to the password file... ... if (stat(tempname, &begin)) pw_error(tempname, 1, 1); pw_edit(0); if (stat(tempname, &end)) pw_error(tempname, 1, 1); if (begin.st_mtime == end.st_mtime) { warnx("no changes made"); pw_error((char *)NULL, 0, 0); } ... so, if the changes to the password file are done faster than the st_mtime resolution (is that one second ?), then no changes are assumed. A better way would be needed for the check. On 2.1 the stat structure actually uses "struct timespec" for the times. I propose to modify line 95 of vipw.c from if (begin.st_mtime == end.st_mtime) { to if (begin.st_mtimespec == end.st_mtimespec) { Luigi ==================================================================== Luigi Rizzo Dip. di Ingegneria dell'Informazione email: luigi@iet.unipi.it Universita' di Pisa tel: +39-50-568533 via Diotisalvi 2, 56126 PISA (Italy) fax: +39-50-568522 ====================================================================