Hello, everybody!
Could somebody help me to figure out how to use GPG agent in my daemon/cronjob?
I'm trying to sync my mail with OfflineIMAP via cron, it uses my own password-store utility which in turn uses python-gnupg. When I'm launching OfflineIMAP from terminal, it's popping out a GPGTools window with password prompt (I'm using Mac OS X 10.9 by the way) and syncing my mail. But for this cronjob */1 * * * * /usr/local/bin/offlineimap -qf INBOX > /Users/chuwy/logfile 2>&1, I have following traceback in my logfile:
Traceback:
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/accounts.py", line 241, in syncrunner
self.sync()
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/accounts.py", line 303, in sync
remoterepos.getfolders()
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/repository/IMAP.py", line 313, in getfolders
imapobj = self.imapserver.acquireconnection()
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/imapserver.py", line 415, in acquireconnection
self._authn_helper(imapobj)
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/imapserver.py", line 325, in _authn_helper
if func(imapobj):
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/imapserver.py", line 251, in _authn_plain
imapobj.authenticate('PLAIN', self.plainhandler)
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/imaplib2.py", line 648, in authenticate
typ, dat = self._simple_command('AUTHENTICATE', mechanism.upper())
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/imaplib2.py", line 1615, in _simple_command
return self._command_complete(self._command(name, *args), kw)
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/imaplib2.py", line 1354, in _command
literal = literator(data, rqb)
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/imaplib2.py", line 2163, in process
ret = self.mech(self.decode(data))
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/imapserver.py", line 161, in plainhandler
passwd = self.getpassword()
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/imapserver.py", line 111, in getpassword
self.password = self.repos.getpassword() or \
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/repository/IMAP.py", line 258, in getpassword
return self.localeval.eval(passwd)
File "/usr/local/Cellar/offline-imap/6.5.5/libexec/offlineimap/localeval.py", line 45, in eval
return eval(text, names)
File "<string>", line 1, in <module>
File "/Users/chuwy/.mutt/offlineimap.py", line 7, in get_keychain_pass
return get_secret(account)
File "/Users/chuwy/workspace/mrsmith/mrsmith/api.py", line 19, in get_secret
gpg = gnupg.GPG(gnupghome=config.get('GPG', 'gnupghome'), use_agent=True)
File "/usr/local/lib/python2.7/site-packages/gnupg.py", line 664, in __init__
p = self._open_subprocess(["--version"])
File "/usr/local/lib/python2.7/site-packages/gnupg.py", line 712, in _open_subprocess
return Popen(cmd, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
I'm almost sure, it's caused by GPG Tools & python-gnupg couple, but can't figure out what exactly going on.
P.S. The same problem with launchd.