X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=blobdiff_plain;f=bsmtp-pull;h=cd51d6872ac1fd4e3ae0adf6b365a234f986ae2b;hb=0b942b568b5b6609aaa2ee4145d5633e662c91ea;hp=5c95f92e4c067b2e1a149b2487f8b595c9494056;hpb=14b864f3bf2ae03124cd966476a3cc3aec671b33;p=bin.git diff --git a/bsmtp-pull b/bsmtp-pull index 5c95f92..cd51d68 100755 --- a/bsmtp-pull +++ b/bsmtp-pull @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash # Depends: lockfile-progs, ssh set -e @@ -19,13 +19,19 @@ HOST="$1" # By default, lockfile-create gives up after three minutes, so don't cron # this any more frequently than that without supplying a --retry argument. lockfile-create "$HOST" +# Race condition pointed out by pjb: this doesn't guarantee that the lock is +# held before the critical section starts. lockfile-touch "$HOST" & TOUCH="$!" trap 'kill "$TOUCH"; lockfile-remove "$HOST"' EXIT ERR HUP INT QUIT TERM +disown %1 -ssh -2 -i "$HOME/.ssh/id-bsmtp-$HOST" -C "$HOST" bsmtp-pull-server > "$HOST" +ssh -S none -i "$HOME/.ssh/id-bsmtp-$HOST" -C "$HOST" bsmtp-pull-server > "$HOST" +if [ "$BSMTP_PULL_DEBUG" ]; then + ls -l "$HOST" || true +fi [ -s "$HOST" ] || exit 0 -/usr/sbin/sendmail -bS < "$HOST" +/usr/sbin/sendmail -bS -odb < "$HOST" rm -f "$HOST" exit 0