Comment 14 for bug 909189

Revision history for this message
Julian Taylor (jtaylor) wrote :

just to illustrate why creating a file and then chmod'ing it is wrong.

I by accident start a script with my normal user permissions which contains this:
file = inotifywait -e create /path/to/wakup/tmpdir | grep CREATE | awk '{$3}'
echo "... do-bad-stuff" >> file

this can now win the race condition and write arbitrary data to the file before wakup chmod's the file to be only root rightable.
now the script gained root access while it before only had normal user access.

better create the file with the correct permissions in the first place, or truncate the file when root writes to it.