diff options
author | Graeme Fowler <graemef@exim.org> | 2015-11-17 14:01:28 +0000 |
---|---|---|
committer | Graeme Fowler <graemef@exim.org> | 2015-11-17 14:01:28 +0000 |
commit | 77d31cea07808daf55f04cf6929adf5d805fa726 (patch) | |
tree | ba6540a1a9b9c03e20367d5103c3651095f80b06 /src | |
parent | 5ef5dd52d1ded8b0ffdf4708e1d00e4ef458b86a (diff) |
GF: Fix esoteric race condition in exicyclog
Diffstat (limited to 'src')
-rw-r--r-- | src/src/exicyclog.src | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/src/exicyclog.src b/src/src/exicyclog.src index 01d1f2feb..1559a4794 100644 --- a/src/src/exicyclog.src +++ b/src/src/exicyclog.src @@ -282,28 +282,34 @@ done if [ $keep -gt 99 ]; then first=001; else first=01; fi +# Grab our pid ro avoid race in file creation +ourpid=$$ + if [ -f $mainlog ]; then $mv $mainlog $mainlog.$first $chown $user:$group $mainlog.$first - $touch $mainlog - $chown $user:$group $mainlog - $chmod 640 $mainlog + $touch $mainlog.$ourpid + $chown $user:$group $mainlog.$ourpid + $chmod 640 $mainlog.$ourpid + $mv $mainlog.$ourpid $mainlog fi if [ -f $rejectlog ]; then $mv $rejectlog $rejectlog.$first $chown $user:$group $rejectlog.$first - $touch $rejectlog - $chown $user:$group $rejectlog - $chmod 640 $rejectlog + $touch $rejectlog.$ourpid + $chown $user:$group $rejectlog.$ourpid + $chmod 640 $rejectlog.$ourpid + $mv $rejectlog.$ourpid $rejectlog fi if [ -f $paniclog ]; then $mv $paniclog $paniclog.$first $chown $user:$group $paniclog.$first - $touch $paniclog - $chown $user:$group $paniclog - $chmod 640 $paniclog + $touch $paniclog.$ourpid + $chown $user:$group $paniclog.$ourpid + $chmod 640 $paniclog.$ourpid + $mv $paniclog.$ourpid $paniclog fi # Now scan the (0)02 and later files, compressing where necessary, and |