Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run gpg in batch mode #9728

Merged
merged 2 commits into from
Jan 12, 2022
Merged

Run gpg in batch mode #9728

merged 2 commits into from
Jan 12, 2022

Conversation

wadells
Copy link
Contributor

@wadells wadells commented Jan 11, 2022

Summary

This fixes a release bug when gpg attempts to sign repomd.xml when a signature is already present.

Contributes to #9726.

Testing Done

I set up a docker container with a repomd.xml.asc already in place, and verify the gpg: cannot open '/dev/tty': No such device or address message showed up. Then I added the fix.

Dockerfile and docker run
walt@work:/tmp/rpm$ ls
Dockerfile  gpg.tar.base64  repomd.xml  sign.sh
walt@work:/tmp/rpm$ cat Dockerfile 
from centos:8
copy . /
entrypoint ["bash", "/sign.sh"]
walt@work:/tmp/rpm$ cat sign.sh 
export GNUPGHOME=/tmp/gnupg
mkdir -p -m0700 $GNUPGHOME
cat gpg.tar.base64 | base64 -d | tar -xzf - -C $GNUPGHOME
chown -R root:root $GNUPGHOME
# rm -f /dev/tty
gpg --detach-sign --armor --batch --yes /repomd.xml
echo foo >> /repomd.xml.asc
cat /repomd.xml.asc
gpg --detach-sign --armor --batch --yes /repomd.xml
cat /repomd.xml.asc
walt@work:/tmp/rpm$ docker build . -t foo && docker run foo
Sending build context to Docker daemon  14.85kB
Step 1/3 : from centos:8
 ---> 300e315adb2f
Step 2/3 : copy . /
 ---> 8fdf24cd2d92
Step 3/3 : entrypoint ["bash", "/sign.sh"]
 ---> Running in ccf7b521ad04
Removing intermediate container ccf7b521ad04
 ---> 6c7a920b804b
Successfully built 6c7a920b804b
Successfully tagged foo:latest
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEDF6LpWWOMg0bAxF5yH7VOmKCxBEFAmHc8eEACgkQyH7VOmKC
xBEnFxAAtrxEHVuaThN2ytETZaQXYV4y+X11n750quudTydca1Sxlr7Cz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
7/26q/2HLAUQAToS51OVYmLvatgcTYLF6HtgAW/8nPt6umP4gSq+IFkvq2A9T7Au
RPN/mBZ3o1Z4lfdATnoDxm4J/ACZk3gC7uAF1dOjlCYy+0Ewdy+V0yQA9TUj6FiF
Ef4pB50yUcSAOD7q9bFJZU4yaQgKdzs780TGEBnxlcxnb42jhjqhduiE1zRieDTk
xNtd53oicVpFfPuhCjI8BbQvqg9n0U+rgLeAgtc7KSZtvUut6TNNk/dDltARXE6t
tCdR9Xhn0JjJKsqcGmzyngXSmzS8ue9VYtxgOmVjKm573PwCs9ZWuAkIHlX9bbja
wxuN/+hAdSppFXIzu53jruP5RAYziuen2d1kwQqrrgzbJ6n59hw=
=IT+Q
-----END PGP SIGNATURE-----

Do not prompt for any reason, especially not if a repomd.xml.asc already
exists when signing repomd.xml. Attempting to prompt (instead of
overwriting) results in publish failures like the following:

  + gpg --detach-sign --armor /rpmrepo/teleport/repodata/repomd.xml
  gpg: cannot open '/dev/tty': No such device or address

Contributes to #9726.
@wadells wadells enabled auto-merge (squash) January 12, 2022 01:55
@wadells wadells merged commit e3c6446 into master Jan 12, 2022
@wadells wadells deleted the walt/rpm-sig-overwrite branch January 12, 2022 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants