From owner-freebsd-bugs Sat Sep 8 1:10: 8 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 13B8D37B406 for ; Sat, 8 Sep 2001 01:10:02 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f888A2Y27121; Sat, 8 Sep 2001 01:10:02 -0700 (PDT) (envelope-from gnats) Date: Sat, 8 Sep 2001 01:10:02 -0700 (PDT) Message-Id: <200109080810.f888A2Y27121@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Peter Pentchev Subject: Re: bin/30424: Generalization of vipw to lock pwdb while being edited by a script Reply-To: Peter Pentchev Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/30424; it has been noted by GNATS. From: Peter Pentchev To: alan@batie.org Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: bin/30424: Generalization of vipw to lock pwdb while being edited by a script Date: Sat, 8 Sep 2001 11:08:06 +0300 On Fri, Sep 07, 2001 at 03:34:37PM -0700, alan@batie.org wrote: > > >Number: 30424 > >Category: bin > >Synopsis: Generalization of vipw to lock pwdb while being edited by a script > >Originator: Alan Batie > >Release: FreeBSD 4.3-STABLE i386 > >Organization: > RainDrop Laboratories > >Environment: > System: FreeBSD aggie.rdrop.com 4.3-STABLE FreeBSD 4.3-STABLE #3: Wed Sep 5 13:36:38 PDT 2001 root@aggie.rdrop.com:/usr/src/freebsd/sys/compile/AGORA i386 > > > >Description: > I have scripts to update accounts, and need to have the password > file locked while they run to avoid having a user change their > password at the same time and losing one of the updates. Since > vipw already does most of what needs to be done, I've modified it > so that when invoked as "pw_lock", instead of running vi, it runs > the specified command, but still does all the locking and database > updating. Good idea! [snip] > + if (!(pid = vfork())) { > + execl(argv[0], progname, tempname, (char *)NULL); > + warn("Command '%s' failed", argv[0]); > + pw_error((char *)NULL, 0, 0); > + } I think you should check pid for -1 here, though.. > *************** > *** 83,88 **** > --- 85,95 ---- > at very large sites could take several minutes. Until this update > is completed, the password file is unavailable for other updates > and the new information is not available to programs. > + .Pp > + If invoked as > + .Nm pw_lock > + , the user database ... This might be written better as If invoked as .Nm pw_lock , the user database ... Other than that, good work! G'luck, Peter -- If there were no counterfactuals, this sentence would not have been paradoxical. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message