procmail
[Top] [All Lists]

Re: file locking

2000-08-16 16:51:44
Xander Soldaat <xander(_at_)soldaat(_dot_)com> writes:
On Wed, 16 Aug 2000 guenther(_at_)gac(_dot_)edu wrote:

Xander Soldaat <xander(_at_)soldaat(_dot_)com> writes:
I was wondering if it is necessary to use the :0: flag when writing
to a file,
 ie something like this:
:0:
* some_condition
my_file

I was using procmail with VERBOSE=yes defined in my rc file and I
noticed some thing about aquiring kernel locks. Does this mean that the
":" is not always necessary, but only in the case of using a program
such as formail to write something to a file?

If you can trust the kernel-locking (no NFS involved, etc), and _all_
programs that access the file use kernel locking, then "yes".
Otherwise, no.

But who is to say that the other programs will respect the lock file :)

Well, there's always the documentation to start, and the source should
definitively answer the question.


If the kernel has put a lock on a file, does this mean that the file
cannot be opened in RW mode? I am not much of a programmer anymore, but
this would be interesting to see. If this were the case then surely
kernel locking would be a far superior method for local filesystems.

Many versions of UNIX implement so-called 'mandatory' file locking, but
it use is, in general, advised against.  Enabling mandatory file locking
for a file is *often* (no guarantees!) done by turning on the setgid bit
while turning off the group-execute bit, i.e.:

        chmod g-w,g+s filename

Mandatory locking can be dangerous in the face of naive or untrusted
programs, so be very careful before jumping into this.  They're also
used so rarely that latent kernel bugs and inefficiencies may be
exposed.


The lock file mechanism is just user-space, is it not? Another program
would have to know that the lock file in the cwd belongs to file "A" and
not file "B". 

Hmm?  Lockfiles are generally named after the file being locked with
".lock" appended.  For example, the lockfile for the file
"/home/guenther/.mailspool" would be "/home/guenther/.mailspool.lock".


Philip Guenther

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>