procmail
[Top] [All Lists]

Re: chmod immediately?

1997-07-14 12:03:00
Mitsuru Furukawa <furu(_at_)009(_dot_)com> writes:
I want to chmod a file right after finishing writing to it.

 :0c
 <snip>
 echo "<h1>END of WEB</h1>" >> $WEB/$FILE.html;
 :0a
 | chmod a+r $WEB/$FILE.html

This recipe works only about 50% of the time:-<
It fails with message WARNING: can't access.....
I tried
 | sleep 5;  chmod a+r $WEB/$FILE.html
but, did not improve.

Is there better way?

Fix the permissions once (outside of procmail), and then tell procmail
(using the UMASK variable) to use the correct umask for that recipe.
You also need to tell procmail that the action isn't going to be
reading the entire message that procmail is trying to feed to it, and
that procmail should _not_ consider this an error.  (This is the source
of the "50%" troubles.) Thus the recipe needs the 'i' flag:

        # set a less paranoid umask that allows everyone read access
        # in case the file doesn't exist
        UMASK = 022
        :0 i
        * conditions here
        |echo "<h1>END of WEB</h1>" >> $WEB/$FILE.html

        UMASK = 077     # restore the paranoid umask 


I'll note that the umask does *NOT* affect the permissions of a file
that already exists: that's what chmod is for.  The umask only affects
the permissions of newly created files.

Philip Guenther

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