configure: handle TEMP_GPG more robustly

We never want ./configure to try to do something with an unassigned
variable.  So, make the directory $TEMP_GPG at the start of the
testing of session-key handling, and clean it up afterwards as long as
the directory exists.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
This commit is contained in:
Daniel Kahn Gillmor 2019-05-20 16:52:00 -04:00 committed by David Bremner
parent 7546fd9cf6
commit 0def7b6860

10
configure vendored
View file

@ -529,8 +529,10 @@ int main () {
return 0; return 0;
} }
EOF EOF
if ${CC} ${CFLAGS} ${gmime_cflags} ${gmime_ldflags} _check_session_keys.c -o _check_session_keys \ if ! TEMP_GPG=$(mktemp -d); then
&& TEMP_GPG=$(mktemp -d) \ printf 'No.\nCould not make tempdir for testing session-key support.\n'
errors=$((errors + 1))
elif ${CC} ${CFLAGS} ${gmime_cflags} ${gmime_ldflags} _check_session_keys.c -o _check_session_keys \
&& GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < test/gnupg-secret-key.asc \ && GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < test/gnupg-secret-key.asc \
&& SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \ && SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \
&& [ $SESSION_KEY = 9:0BACD64099D1468AB07C796F0C0AC4851948A658A15B34E803865E9FC635F2F5 ] && [ $SESSION_KEY = 9:0BACD64099D1468AB07C796F0C0AC4851948A658A15B34E803865E9FC635F2F5 ]
@ -552,9 +554,11 @@ EOF
else else
printf 'You do not have the GPGME development libraries installed.\n' printf 'You do not have the GPGME development libraries installed.\n'
fi fi
rm -rf "$TEMP_GPG"
errors=$((errors + 1)) errors=$((errors + 1))
fi fi
if [ -n "$TEMP_GPG" -a -d "$TEMP_GPG" ]; then
rm -rf "$TEMP_GPG"
fi
else else
have_gmime=0 have_gmime=0
printf "No.\n" printf "No.\n"