Skip to content

Commit 00cd8d7

Browse files
NHOrusthesamesam
authored andcommitted
getuto: add manual timeout around GPG connection to keyserver
Some kinds of ISP site blocks terminate connection after it is established. This leaves GPG thinking it's connected successfully and waiting for keys. Add manual timeout invocations over keyserver calls. Set timeout for them longer than GPG connection timeout. Closes: #22 Closes: #28 Signed-off-by: NHOrus <jy6x2b32pie9@yahoo.com> Part-of: #29 Closes: #29 Signed-off-by: Sam James <sam@gentoo.org>
1 parent 5f62138 commit 00cd8d7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

getuto

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ LASTRUNFILE=${GNUPGHOME}/.getuto.last
2727
QUIET='1'
2828
QUIET_GPG=''
2929

30+
GPG_TIMEOUT_TERM='3.5m'
31+
GPG_TIMEOUT_KILL='5m'
32+
3033
[[ $1 == '-v' ]] && QUIET=''
3134
# If QUIET is enabled, pass '--quiet' and suppress GPG homedir permission warnings
3235
# These permission warnings cannot be suppressed using gpg.conf
@@ -73,7 +76,7 @@ getuto_refresh() {
7376
# Refresh all keys from the keyserver if we can.
7477
for keyserver in "${mykeyservers[@]}" ; do
7578
# TODO: keys.openpgp.org lacks a UID for our keys, need to verify email
76-
gpg ${QUIET_GPG} --batch --keyserver "${keyserver}" --refresh-keys || true
79+
timeout -k ${GPG_TIMEOUT_KILL} ${GPG_TIMEOUT_TERM} gpg ${QUIET_GPG} --batch --keyserver "${keyserver}" --refresh-keys || true
7780
done
7881
# We only sign (-> ultimate trust) the keys we originally import, so this is fine and
7982
# just serves as an additional refresh method.
@@ -167,7 +170,7 @@ if [[ ! -d ${GNUPGHOME} ]] ; then
167170

168171
# TODO: keys.openpgp.org lacks a UID for our keys, need to verify email
169172
for keyserver in "${mykeyservers[@]}" ; do
170-
gpg ${QUIET_GPG} --batch --keyserver "${keyserver}" --recv-keys ${myrelkeys} || true
173+
timeout -k ${GPG_TIMEOUT_KILL} ${GPG_TIMEOUT_TERM} gpg ${QUIET_GPG} --batch --keyserver "${keyserver}" --recv-keys ${myrelkeys} || true
171174
done
172175
# We only sign (-> ultimate trust) the keys we originally import, so this is fine and
173176
# just serves as an additional refresh method.

0 commit comments

Comments
 (0)