Page MenuHome GnuPG

gpgme - Inappropriate ioctl for device
Closed, ResolvedPublic

Description

dnf fails to work on Fedora, which is run in container through LXD because of
gpgme.

dnf install -y git

...
Traceback (most recent call last):

File "/usr/bin/dnf", line 58, in <module>
  main.user_main(sys.argv[1:], exit_code=True)
File "/usr/lib/python3.5/site-packages/dnf/cli/main.py", line 174, in

user_main

  errcode = main(args)
File "/usr/lib/python3.5/site-packages/dnf/cli/main.py", line 60, in main
  return _main(base, args)
File "/usr/lib/python3.5/site-packages/dnf/cli/main.py", line 120, in _main
  ret = resolving(cli, base)
File "/usr/lib/python3.5/site-packages/dnf/cli/main.py", line 149, in

resolving

  base.do_transaction(display=displays)
File "/usr/lib/python3.5/site-packages/dnf/cli/cli.py", line 220, in

do_transaction

  self.gpgsigcheck(downloadpkgs)
File "/usr/lib/python3.5/site-packages/dnf/cli/cli.py", line 258, in

gpgsigcheck

  self._get_key_for_package(po, fn)
File "/usr/lib/python3.5/site-packages/dnf/base.py", line 1842, in

_get_key_for_package

  keys = dnf.crypto.retrieve(keyurl, repo)
File "/usr/lib/python3.5/site-packages/dnf/crypto.py", line 124, in retrieve
  keyinfos = rawkey2infos(handle)
File "/usr/lib/python3.5/site-packages/dnf/crypto.py", line 117, in

rawkey2infos

  info.raw_key = buf.getvalue()
File "/usr/lib64/python3.5/contextlib.py", line 77, in __exit__
  self.gen.throw(type, value, traceback)
File "/usr/lib/python3.5/site-packages/dnf/crypto.py", line 95, in pubring_dir
  yield
File "/usr/lib/python3.5/site-packages/dnf/crypto.py", line 107, in

rawkey2infos

ctx.import_(key_fo)

gpgme.GpgmeError: (7, 32870, 'Inappropriate ioctl for device')

Event Timeline

Thanks for the report.

I see that you are using pygpgme, is that correct? If so, which version, and are
there significant patches applied in the Fedora package? And can you please tell
me what version of libgpgme you are using?

Let's try to figure out which ioctl fails. Could you try to strace this process?

On Wed, Jul 27, 2016 at 1:24 PM, Justus Winter via BTS
<gnupg@bugs.g10code.com> wrote:

I see that you are using pygpgme, is that correct?If so, which version, and are
there significant patches applied in the Fedora package? And can you please tell
me what version of libgpgme you are using?

[root@pgp ~]# dnf list installed | grep gpg
gpgme.x86_64 1.4.3-7.fc24 @System
libgpg-error.x86_64 1.24-1.fc24 @System
pygpgme.x86_64 0.3-15.fc24 @System
python3-pygpgme.x86_64 0.3-15.fc24 @System

I don't know about patches. I guess I need to find source package - SRPM for
pygpgme, but I haven't figured out where to get it yet.
https://wiki.centos.org/HowTos/RebuildSRPM

Let's try to figure out which ioctl fails. Could you try to strace this process?

How to do this?

Ok, there are no significant patches on top of pygpgme. Note that pygpgme is not really
maintained, and that we neither develop nor support pygpgme. But seeing that dnf is important to
Fedora, let's figure this out.

It would be nice if you could try to reproduce the problem without pygpgme though, just to make a
more minimal test case. I see the exception is thrown during some import. This is how I strace
gnupg to see what ioctls it is issuing:

% strace -eioctl g10/gpg --import ../tests/openpgp/samplekeys/ecc-sample-1-pub.asc
gpg: NOTE: THIS IS A DEVELOPMENT VERSION!
gpg: It is only intended for test purposes and should NOT be
gpg: used in a production environment or with production keys!
gpg: key 0BA52DF0BAA59D9C: public key "ec_dsa_dh_256 <openpgp@brainhub.org>" imported

  • SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=26716, si_uid=1000, si_status=0,

si_utime=0, si_stime=0} ---
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon
echo ...}) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon
echo ...}) = 0
gpg: Total number processed: 1
gpg: imported: 1
+++ exited with 0 +++

Note that if you try to strace your gpgme-based application, you need to pass '-f' to strace to
follow forks.

I have grepped through gpgme and gnupg, and it looks like gnupg is only doing ioctls to terminals,
so maybe your container setup is doing something funny to terminals. But let's see what the strace
shows.

I've made new container and can't repeat the bug. gpgme
components got updated in Fedora.

[root@pgp3 ~]# dnf list installed | grep gpg
gpgme.x86_64 1.6.0-3.fc24 @System
libgpg-error.x86_64 1.24-1.fc24 @System
python2-pygpgme.x86_64 0.3-18.fc24 @System
python3-pygpgme.x86_64 0.3-18.fc24 @System

http://koji.fedoraproject.org/koji/buildinfo?buildID=785378

Funny enough, but strace is not installed, and because dnf was
broken, it was impossible to strace anything. But it could be closed
now as they seem to fix that with newer Fedora image.

Unknown Object (User) renamed this task from gpgme - Inappropriate ioctl for device to NATIONAL SECURITY. FEDERAL OFFENSE 12-20yrs FEDERAL PRISON.May 23 2017, 4:03 AM
Unknown Object (User) changed the task status from Resolved to Invalid.
Unknown Object (User) removed justus as the assignee of this task.
Unknown Object (User) updated the task description. (Show Details)
Unknown Object (User) removed projects: gpgme, Bug Report, Fedora, Python.
Unknown Object (User) removed subscribers: werner, techtonik, justus.
marcus renamed this task from NATIONAL SECURITY. FEDERAL OFFENSE 12-20yrs FEDERAL PRISON to gpgme - Inappropriate ioctl for device.May 23 2017, 9:38 AM
marcus changed the task status from Invalid to Resolved.
marcus assigned this task to justus.
marcus updated the task description. (Show Details)
marcus added projects: gpgme, Bug Report, Fedora, Python.
marcus added subscribers: werner, techtonik, justus.