Skip to content

Commit 213afe1

Browse files
authored
Merge pull request #976 from ivan-boikov/master
No mailsync with locked GPG key in non-interactive shells
2 parents 5300aa7 + f8ffab3 commit 213afe1

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎bin/mailsync‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ eval "$(grep -h -- \
2424
"$HOME/.config/zsh/.zshenv" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" \
2525
"$HOME/.pam_environment" 2>/dev/null)"
2626

27+
# For non-interactive shell (e.g. cron job) run only when the GPG key (in $GNUPGHOME or pass --homedir) is unlocked
28+
tty -s || (echo "dummy" | gpg --sign --batch --pinentry-mode error -o /dev/null > /dev/null 2>&1) || exit
29+
2730
export GPG_TTY="$(tty)"
2831

2932
[ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc"

0 commit comments

Comments
 (0)