forked from ungleich-public/cdist
Merge branch '__apt_key_mktemp_gpghome' into 'master'
__apt_key: use mktemp for unique temporary gpg home See merge request ungleich-public/cdist!812
This commit is contained in:
commit
8efd2681db
1 changed files with 5 additions and 7 deletions
|
@ -61,31 +61,29 @@ EOF
|
|||
echo "curl -s -L '$uri' | apt-key add -"
|
||||
fi
|
||||
elif [ -d "$keydir" ]; then
|
||||
tmp='/tmp/cdist_apt_key_tmp'
|
||||
|
||||
# we need to kill gpg after 30 seconds, because gpg
|
||||
# can get stuck if keyserver is not responding.
|
||||
# exporting env var and not exit 1,
|
||||
# because we need to clean up and kill dirmngr.
|
||||
cat << EOF
|
||||
|
||||
mkdir -m 700 -p "$tmp"
|
||||
gpgtmphome="\$( mktemp -d )"
|
||||
|
||||
if timeout 30s \\
|
||||
gpg --homedir "$tmp" \\
|
||||
gpg --homedir "\$gpgtmphome" \\
|
||||
--keyserver "$keyserver" \\
|
||||
--recv-keys "$keyid"
|
||||
then
|
||||
gpg --homedir "$tmp" \\
|
||||
gpg --homedir "\$gpgtmphome" \\
|
||||
--export "$keyid" \\
|
||||
> "$keyfile"
|
||||
else
|
||||
export GPG_GOT_STUCK=1
|
||||
fi
|
||||
|
||||
GNUPGHOME="$tmp" gpgconf --kill dirmngr
|
||||
GNUPGHOME="\$gpgtmphome" gpgconf --kill dirmngr
|
||||
|
||||
rm -rf "$tmp"
|
||||
rm -rf "\$gpgtmphome"
|
||||
|
||||
if [ -n "\$GPG_GOT_STUCK" ]
|
||||
then
|
||||
|
|
Loading…
Reference in a new issue