Date: Tue, 21 Mar 1995 09:50:23 +0100 (MET) From: Luigi Rizzo <luigi@labinfo.iet.unipi.it> To: hackers@FreeBSD.org Subject: vipw feature (and fix) Message-ID: <199503210850.JAA24384@labinfo.iet.unipi.it>
next in thread | raw e-mail | index | archive | help
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
====================================================================
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503210850.JAA24384>
