chiark / gitweb /
test suite: gnupg: Save stdin on apt-key's import invocations
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 7 Jan 2018 14:34:08 +0000 (14:34 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 7 Jan 2018 16:18:53 +0000 (16:18 +0000)
Recognise these with an ad-hoc pattern on the command line arguments.
When they occur, save stdin to a temporary file.

We can't do this generally, because stdin might be some thing that
gpg's caller doesn't expect gpg to eat.

When we do this saving, print the size in bytes of the input file.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
tests/tstunt/gpg-locked

index 892b9c8cf446b255a221276463553c88fc83a0f7..ddb880f6c208fa7cb47a6938c67e1f09ec3bf87d 100755 (executable)
@@ -3,6 +3,20 @@ set -e
 
 for attempt in '' ' ' exec; do
 
+case "$*" in
+*"
+--batch
+--import")
+       # ^ apt-key's invocation
+       if [ "x$stdin_tmp" = x ]; then
+               stdin_tmp="$GNUPGHOME"/dgit-stdin-tmp
+               cat >$stdin_tmp
+               stdin_tmp_bytes=$(wc -c <$stdin_tmp)
+       fi
+       exec <$stdin_tmp
+       ;;
+esac
+
 set +e
 $attempt                                               \
 $DGIT_TEST_REAL_GPG                                    \
@@ -13,7 +27,7 @@ set -e
 
 if [ $rc != 2 ]; then exit $rc; fi
 
-echo >&2 "WARNING - GNUPG FAILED $rc - STUNT GNUPG $attempt $*"
+echo >&2 "WARNING - GNUPG FAILED $rc - STUNT GNUPG $attempt $stdin_tmp_bytes $*"
 
 sh -ec '
        if [ "x$DGIT_GNUPG_STUNT_ERRLOG" != x ]; then
@@ -23,7 +37,7 @@ sh -ec '
        fi
        exec >/dev/tty
        printf "%s\n" "$*"
-' x "GNUPG WRAPPER - TROUBLE - $HOME $GNUPGHOME - FAILED $rc $attempt $*"
+' x "GNUPG WRAPPER - TROUBLE - $HOME $GNUPGHOME - FAILED $rc $attempt $stdin_tmp_bytes $*"
 
 sleep 10