chiark / gitweb /
bsmtp-pull: Note race condition pointed out by Peter Benie.
[bin.git] / bsmtp-pull
index 5a2c474c6c68fc09bdf879bda76c08221888eae8..600763d58e4540b7cd1c6f2ee912aea9fbd3cbd1 100755 (executable)
@@ -7,7 +7,7 @@ if [ -z "$1" ]; then
     exit 1
 fi
 
-DIR="$HOME/.bsmtp"
+DIR="$HOME/tmp/.bsmtp"
 mkdir -p "$DIR"
 cd "$DIR"
 
@@ -19,11 +19,13 @@ 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
 
-ssh -2 -C "$HOST" bsmtp-pull-server > "$HOST"
+ssh -2 -i "$HOME/.ssh/id-bsmtp-$HOST" -C "$HOST" bsmtp-pull-server > "$HOST"
 [ -s "$HOST" ] || exit 0
 /usr/sbin/sendmail -bS < "$HOST"
 rm -f "$HOST"