Solving Kleopatra error "Inappropriate Ioctl for Device" on Gentoo
I like using Kleopatra1 as a GUI for managing my OpenPGP keys and signing (or encrypting documents). However, I had a problem on my Gentoo system when trying to sign documents with it. Every time it will complain throwing the following error:
gpg: signing failed: Inappropriate ioctl for device
After a bit of internet search I found a solution on Stack Overflow and on Github. Any of those were related to Kleopatra specifically, but they provided a workaround. Just running on a terminal the following commands:
$ GPG_TTY=$(tty) $ export GPG_TTY $ kleopatra
That allowed me to enter the password to the PGP key in the terminal window2 where I had the program running. This worked for that CV that needed to be sent; however it didn’t make any sense as a permanent solution.
After some more searching, I found the README file that explains the
dependencies for Kleopatra for package maintainers in the source code repo.
There I learned that the app uses pinentry3 for getting the password for gpg,
and was using the curses frontend (
pinentry-curses) for that. So, when I
launched Kleopatra from my application launcher, pinetry didn’t knew where to
run the curses interface to ask for my password.
I checked and I also had
pinentry-qt installed4. Then I wondered how do I
make that Kleopatra uses the qt-frontend instead of the curses one, so a new
window will pop up asking for my password instead of the terminal. Of course,
the solution was
eselect (that’s the gentoo way):
# eselect pinentry list Available pinentry binary implementations:  pinentry-gnome3  pinentry-qt  pinentry-gtk-2  pinentry-qt4  pinentry-curses *  pinentry-tty # eselect pinentry set 2
I hope this article it’s helpful. I tried to write about the process for solving my problem, so that it may be useful for you.
It was a curses frontend, this will become important in a bit. ↩︎
If you are wondering just like me, it’s read PIN Entry. ↩︎
To be precise,
app-crypt/pinentrywas emerged with the USE flag