summaryrefslogtreecommitdiff
path: root/tests/tstunt/gpg-locked
blob: ddb880f6c208fa7cb47a6938c67e1f09ec3bf87d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
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					\
	--agent-program=$DGIT_STUNT_AGENT		\
	"$@"
rc=$?
set -e

if [ $rc != 2 ]; then exit $rc; fi

echo >&2 "WARNING - GNUPG FAILED $rc - STUNT GNUPG $attempt $stdin_tmp_bytes $*"

sh -ec '
	if [ "x$DGIT_GNUPG_STUNT_ERRLOG" != x ]; then
		exec >"$DGIT_GNUPG_STUNT_ERRLOG"
	else
		exec 2>/dev/null
	fi
	exec >/dev/tty
	printf "%s\n" "$*"
' x "GNUPG WRAPPER - TROUBLE - $HOME $GNUPGHOME - FAILED $rc $attempt $stdin_tmp_bytes $*"

sleep 10

done

exit 127