gpg called without no-tty

Bug #1813396 reported by Till Riedel on 2019-01-26
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Medium
Unassigned

Bug Description

I am running cloud-init on a libvirt/virsh with this image: https://cdimage.debian.org/cdimage/openstack/archive/9.6.5-20190122/debian-9.6.5-20190122-openstack-amd64.qcow2

the relevant lines are:
apt:
  sources:
   docker:
     source: 'deb [arch=amd64] https://download.docker.com/linux/debian stretch stable'
     keyserver: keyserver.ubuntu.com
     keyid: 0EBFCD88

sorry for not attaching any bugs, but the triggered command just does not find "/dev/tty")

The gpg wrapper should have the "no-tty" argument for receiving key at least on debian systems.
Otherwise cloudinit fails when specifying key-ids on debian cloudimages (with manually added dirmngr and apt-transport-https, it is quite a mess on the openstack debian images...)

I would naively propose the following patch:

diff --git a/cloudinit/gpg.py b/cloudinit/gpg.py
index 7fe17a2..21d598e 100644
--- a/cloudinit/gpg.py
+++ b/cloudinit/gpg.py
@@ -42,7 +42,7 @@ def recv_key(key, keyserver, retries=(1, 1)):
     @param retries: an iterable of sleep lengths for retries.
                     Use None to indicate no retries."""
     LOG.debug("Importing key '%s' from keyserver '%s'", key, keyserver)
- cmd = ["gpg", "--keyserver=%s" % keyserver, "--recv-keys", key]
+ cmd = ["gpg", "--no-tty", "--keyserver=%s" % keyserver, "--recv-keys", key]
     if retries is None:
         retries = []
     trynum = 0

BR

Till

summary: - no-tty
+ gpg called without no-tty
Ryan Harper (raharper) wrote :

Hi, thanks for reporting the bug. I suspect cloud-init can check if there's a tty and if not append the --no-tty flag.

Changed in cloud-init:
importance: Undecided → Medium
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers