James wrote:

> -> If i'm playing round with user's mailboxes, do i need to somehow lock
> -> them?
> -
> -Yes.
> -
> -When manipulating mail spools, you should generally use both a
> -lockfile and fcntl().
> -
> -To create a lockfile, create a file in the spool directory, link() it
> -to <username>.lock, and unlink() the original. This is the only method 
> -which is reliable over NFS.
> 
> so what i do is:
> 
> make some file in the spool dir.(using mktemp() or similar?)
> link that file to <name_of_mail_spool>.lock
> [do various nasty things to the mail spool :) ]
> unlink the .lock file
> delete the temp file
> 
> this right?

You would typically delete the temp file after you've link()ed it to
<whatever>.lock, but apart from that, yes.

> the lock file doesn't need to contain any data does it?

No.

> it's just there as a marker for other things to check the existance
> of?

Yes.

> What happens if some other program (sendmail, procmail etc) tries to
> fiddle with the locked mail spool, do they just hang around waiting?

Yes, although procmail will apparently override the lockfile after a
certain amount of time. However, fcntl() locks won't be (can't be)
overriden.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to