Page MenuHome GnuPG

gpg-agent doesn't work if started by the superuser (roor)
Closed, ResolvedPublic

Description

If I try to (for example) encrypt file with symmetric cypher as root, I get the
following:

gpg --cipher-algo=CAST5 -c etc_2007-10-06.tar.gz

can't connect to `/root/.gnupg/S.gpg-agent': No such file or directory
gpg-agent[9191]: command get_passphrase failed: Operation cancelled
gpg: cancelled by user
gpg: error creating passphrase: Operation cancelled
gpg: symmetric encryption of `etc_2007-10-06.tar.gz' failed: Operation cancelled

No attempt to ask for the password, file stays unencrypted.

If I start gpg-agent --daemon manually as root, the behavior is similar. Here
is output from gpg-agent --daemon --debug-level advanced being run as root:

2007-10-06 16:33:44 gpg-agent[9486] listening on socket
`/tmp/gpg-mYKxIM/S.gpg-agent'
2007-10-06 16:33:52 gpg-agent[9487] handler 0x8090588 for fd 7 started
gpg-agent[9487.7] DBG: -> OK Pleased to meet you
gpg-agent[9487.7] DBG: <- RESET
gpg-agent[9487.7] DBG: -> OK
gpg-agent[9487.7] DBG: <- OPTION ttyname=/dev/pts/0
gpg-agent[9487.7] DBG: -> OK
gpg-agent[9487.7] DBG: <- OPTION ttytype=xterm
gpg-agent[9487.7] DBG: -> OK
gpg-agent[9487.7] DBG: <- OPTION lc-ctype=ru_RU.KOI8-R
gpg-agent[9487.7] DBG: -> OK
gpg-agent[9487.7] DBG: <- OPTION lc-messages=ru_RU.KOI8-R
gpg-agent[9487.7] DBG: -> OK
gpg-agent[9487.7] DBG: <- GET_PASSPHRASE --data -- X X X
п▓п╡п╣п╢п╦я┌п╣+я└я─п╟п╥я┐-п©п╟я─п╬п╩я▄%0A
2007-10-06 16:33:52 gpg-agent[9487] starting a new PIN Entry
2007-10-06 16:33:52 gpg-agent[9487] DBG: connection to PIN entry established
2007-10-06 16:33:53 gpg-agent[9487] command get_passphrase failed: Operation
cancelled
gpg-agent[9487.7] DBG: -> ERR 67108963 Operation cancelled <GPG Agent>
gpg-agent[9487.7] DBG: <- [EOF]
2007-10-06 16:33:53 gpg-agent[9487] handler 0x8090588 for fd 7 terminated

If I run gpg-agent as ordinary user, and pass GPG_AGENT_INFO to gpg being run as
root, everything works correctly.

Details

Version
2.0.7

Event Timeline

slav set Version to 2.0.7.
slav added a subscriber: slav.

This is a problem with your pinentry. What version are you using?
Also check that the environment variables are fine (i.e. GPG_TTY).

I'm using pinentry-0.7.3 (latest version available in Gentoo). Setting GPG_TTY
doesn't help (moreover, if I start gpg-agent as ordinary user, it works even
without GPG_TTY being set).

I have found that now everything works correctly. I can't determine what exactly
has solved this problem - several packages was updated since my last post, but
there were no gpg or pinentry-related ones. I could suspect that the package in
question is udev (upgraded from udev-104 to udev-115) - perhaps there was
something wrong with tty devices in /dev.

slav claimed this task.