Tips running gpg-agent/scdaemon in a dev env?

Grant Olson kgo at
Sun Jan 16 02:20:18 CET 2011

Short story

I'm looking for some tips to make it easy to develop and test changes
with scdaemon, without having to do make install and restarting my X
session.  Any tips would be appreciated.

Long Story

I've got a cryptostick, and it's been annoying me that scdaemon dies
whenever I unplug the device.  It seems scdaemon expects you to have a
card reader that is always there, and a card that you would remove and
re-insert.  Since the cryptostick is one of those USB reader/cards, I
need to kill the scdaemon process whenever I remove the card and
re-insert it later.  I thought I'd see if I could fix this.

My pertinent background:  I'm a proficient C programmer, and have
written some patches for other open source projects, but most of that is
at an 'application' level.  I haven't done much dealing with background
processes and daemons and talking to hardware.  So I might be asking
some stupid questions.

I did checkout STABLE-BRANCH-2.0 from git, and got everything compiled
and ran a 'make install'.  The newly compiled version works just fine on
my Ubuntu 10.4 machine.

The first problem I ran into was that gpg-agent was always starting up
on my box, even if I didn't start it up in .xsession.  Then when I
killed it, the process sat around, but it was listed as <defunct>.  I
finally tracked that down to /etc/X11/Xsession.d, where gpg-agent would
automatically be started if 'use-agent' was set in gpg.conf.  I disabled
that, restarted, and gpg-agent wasn't running in the background anymore.

At this point, I was hoping I could at least run 'gpg-agent --daemon
--no-detach' and that would at least provide a usable gpg-agent.  But
when I try to run a simple command, I no longer find my card:

grant at johnsmallberries:~$ . ./.gnupg/gpg-agent-info-johnsmallberries
grant at johnsmallberries:~$ gpg2 --card-status
gpg: can't connect to the agent - trying fall back
scdaemon[2511]: PC/SC OPEN failed: unknown PC/SC error code
gpg: selecting openpgp failed: Card error
gpg: OpenPGP card not available: Card error
grant at johnsmallberries:~$ scdaemon[2511]: scdaemon (GnuPG)
2.0.17-git56b2bc2 stopped

If anyone could provide some tips so that I can get to the point where I
can easily start/stop gpg-agent and scdaemon at will while developing,
I'd greatly appreciate it.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: </pipermail/attachments/20110115/1b07fcdc/attachment.pgp>

More information about the Gnupg-devel mailing list