in reply to How to make sure that non-Perl programs will respect Perl's file locking?

On unix-like systems, file locking is advisory by default. This means that nobody else has to pay attention to anything you say about the file-lock state. Wikipedia has a nice entry on file locking that expands on the stuff already mentioned in perlfunc's entry for flock.

You want a mandatory lock that the system enforces. You don't implement this yourself (either through semaphores or other schemes). The solution to your task is complicated by the particular operating system you use, your filesystem set-up, and so on.

In your case, however, if the password changes, I think the CGI script should have to re-authenticate. That's the point of changing passwords. :)

--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review
  • Comment on Re: How to make sure that non-Perl programs will respect Perl's file locking?
  • Download Code

Replies are listed 'Best First'.
Re^2: How to make sure that non-Perl programs will respect Perl's file locking?
by Perl Mouse (Chaplain) on Jan 12, 2006 at 00:03 UTC
    You want a mandatory lock that the system enforces.
    No you don't. At least, not in general. Just suppose you have mandatory file locking. Consider a (user) program that opens /etc/passwd and acquires a read lock. You can't prevent that as /etc/passwd needs to be readable by all.

    As long as the program keeps the lock, noone could acquire an exclusive lock on /etc/passwd, so no modifications to the user of the machine are possible.

    Believe me, you don't want system-wide mandatory locking.

    Perl --((8:>*

      I never said anything about a read lock. I don't think a read lock would do any good here. :)

      --
      brian d foy <brian@stonehenge.com>
      Subscribe to The Perl Review