*BSD News Article 75903


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.mel.connect.com.au!news.mel.aone.net.au!merlin.tassie.net.au!usenet
From: Brook Schofield <Brook@tassie.net.au>
Newsgroups: comp.lang.perl.misc,comp.unix.bsd.freebsd.misc
Subject: 'vipw' Style File Locking in Perl
Date: Sun, 11 Aug 1996 23:53:29 +1000
Organization: Tasmania's Access Server
Lines: 33
Message-ID: <320DE5D9.3FF1@tassie.net.au>
Reply-To: Brook@tassie.net.au
NNTP-Posting-Host: dialin4.ltn.tassie.net.au
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.02 (Macintosh; I; 68K)
Xref: euryale.cc.adfa.oz.au comp.lang.perl.misc:36093 comp.unix.bsd.freebsd.misc:25302

I am trying to write a change password script in perl that is accessed 
though a Web Browser, using Apache and FreeBSD 2.0.5.

I have tried using 'chpass' in FreeBSD but it doesn't seem accessable 
in Perl, unless I run as root. Not even SUID CGI's will work with this 
one.

So I am wondering if anyone has a script out there that can implement 
file locking in the same way that 'vipw' does.

IE:-		open file
	     lock file
      write out new file
      replace new file with old
      close file
      unlock file

I am having the problem with replacing the old with the new as I need 
(or do I) to close the original file in order to open it for 
re-writing. I thought of an intermediate lock file, but not all 
programmes on the system will use it.

Any assistance is appreciated.

-Brook
     ____
    / |* \  Brook Schofield
   /  |/  \
  /   |*** \ Tasmania's Access Server
 | ***||/  | Ph +61 03-343536   Fax +61 03-343537
 \  \||/  /
  \  \|  /  PO Box 2126  LAUNCESTON TAS 7250  Australia
   \__|_/   E-Mail: Brook@tassie.net.au