sign-my-commits fails when gpg-agent and pinentry-curses are being used

Bug #54468 reported by James Westby
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Low
John A Meinel

Bug Description

When trying to use sign-my-commits, with gpg-agent and pinentry-curses in use then the command fails with

$ bzr sign-my-commits
<email address hidden>

You need a passphrase to unlock the secret key for
user: "James Westby <email address hidden>"
1024-bit DSA key, ID B577FE13, created 2006-06-02

gpg: cancelled by user
gpg: no default secret key: bad passphrase
gpg: [stdin]: clearsign failed: bad passphrase
bzr: ERROR: Failed to gpg sign data with command '['gpg', '--clearsign']'

But works with pinentry-gtk2.

The problem can be seen that

cat test | gpg --clearsign fails, where gpg --clearsign test suceeds.

So

  process = subprocess.Popen(self._command_line(),
                                       stdin=subprocess.PIPE,
                                       stdout=subprocess.PIPE)

will cause it to fail in this case.

I think it is reasonable for pinentry-curses to work in this case, but maybe it could be handled more gracefully.

The solution I immediately thought of was to write the commit to a temporary file and pass that to gpg. But as LarstiQ pointed out this could be troublesome.

Hopfully someone smarter can think up a better solution.

James

Related branches

Revision history for this message
John A Meinel (jameinel) wrote :

This plugin:
http://bzr.arbash-meinel.com/plugins/gpg_uses_tempfile/

Uses a temporary chmod directory, followed by a temporary chmod file, to prevent tampering. And spawns 'gpg --clearsign' on the file.

Implemented as a plugin, because it is not as safe as using pipes. But is a reasonable workaround.

Changed in bzr:
importance: Untriaged → Low
status: Unconfirmed → Fix Committed
Revision history for this message
James Westby (james-w) wrote :

Thanks,

Tested and it works fine here using pinentry-curses and gtk2.

James

Revision history for this message
John A Meinel (jameinel) wrote :

James pointed me to this debian bug

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=322932

Which indicates that the environment variable GPG_TTY can be set, which seems to fix the problem. The associated branch seems to fix this for me.

Revision history for this message
John A Meinel (jameinel) wrote :

The plugin is still available for older bzr, but 0.10 should have the GPG_TTY workaround.

Changed in bzr:
assignee: nobody → jameinel
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.