Date: Tue, 21 Mar 1995 21:52:13 +1000 From: Bruce Evans <bde@zeta.org.au> To: hackers@FreeBSD.org, luigi@labinfo.iet.unipi.it Subject: Re: vipw feature (and fix) Message-ID: <199503211152.VAA14006@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>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) {
This wouldn't help if the file system is the current or older ufs. The
nanonseconds field is always 0.
The problem could be fixed by adding `sleep(1)' before calling pw_edit()
(assuming sleep(1) is guaranteed to take >= 1 second).
Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503211152.VAA14006>
