/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2016-02-28 13:09:43 UTC
  • Revision ID: teddy@recompile.se-20160228130943-6ofi0xgek1xd7qmy
Use GnuPG 2 if available

* debian/control (Package: mandos/Depends): Change "gnupg (<< 2)" to
                                            "gnupg".
  (Package: mandos-client/Depends): Remove "gnupg (<< 2)"; it will be
                                    depended on by libgpgme11, which
                                    will be added automatically by
                                    ${shlibs:Depends}.
* mandos (PGPEngine.__init__): Try to run "gpgconf" and set 'self.gpg'
                               to any binary found.  Also change
                               "--home" to "--homedir".
  (PGPEngine.encrypt, PGPEngine.decrypt): Use the 'self.gpg' attribute
                                          instead of "gpg".

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
    
152
152
    def __init__(self):
153
153
        self.tempdir = tempfile.mkdtemp(prefix="mandos-")
 
154
        self.gpg = "gpg"
 
155
        try:
 
156
            output = subprocess.check_output(["gpgconf"])
 
157
            for line in output.splitlines():
 
158
                name, text, path = line.split(":")
 
159
                if name == "gpg":
 
160
                    self.gpg = path
 
161
                    break
 
162
        except OSError as e:
 
163
            if e.errno != errno.ENOENT:
 
164
                raise
154
165
        self.gnupgargs = ['--batch',
155
 
                          '--home', self.tempdir,
 
166
                          '--homedir', self.tempdir,
156
167
                          '--force-mdc',
157
168
                          '--quiet',
158
169
                          '--no-use-agent']
197
208
                dir=self.tempdir) as passfile:
198
209
            passfile.write(passphrase)
199
210
            passfile.flush()
200
 
            proc = subprocess.Popen(['gpg', '--symmetric',
 
211
            proc = subprocess.Popen([self.gpg, '--symmetric',
201
212
                                     '--passphrase-file',
202
213
                                     passfile.name]
203
214
                                    + self.gnupgargs,
215
226
                dir = self.tempdir) as passfile:
216
227
            passfile.write(passphrase)
217
228
            passfile.flush()
218
 
            proc = subprocess.Popen(['gpg', '--decrypt',
 
229
            proc = subprocess.Popen([self.gpg, '--decrypt',
219
230
                                     '--passphrase-file',
220
231
                                     passfile.name]
221
232
                                    + self.gnupgargs,