1

If you are using offlineimap to sync for example with gmail one can encrypt the password and use a python script to decrypt it on runtime. This is done via setting

remotepass = passwd('gmail.gpg')

in the offlineimaprc file, where passwd is a python function. Is the use of such python function restricted to certain keys, like remotepass in the above example or could I theoretically use python function on the right hand side for every key? The reason why I'm asking is the following: I'm trying to encrypt other values for other keys as well. However, I get an error like:

ERROR: While attempting to sync account 'gmail'
  ('http error', 401, 'Unauthorized', <httplib.HTTPMessage instance at 0x7f8ca13541b8>) (configuration is: {'client_secret': "passwd('gmail_client_secret.gpg')", 'grant_type': 'refresh_token', 'refresh_token': "passwd('gmail_rf_token.gpg')", 'client_id': "passwd('gmail_client_id.gpg')"})

and I'm not sure if the function passwd really is executed. Running the python function in a python interpreter gives the correct results.

2

As I understand it, only a few keys have the privilege of being evaled as python code. Some of these are made explicit in the configuration file by a key ending with the string "eval", such as remotepasseval, but others only have this noted in the comments, such as nametrans, which clearly has to be a function.

Since offlineimap is in python, you can probably find the sources in your distribution. In my case file /usr/lib/python2.7/site-packages/offlineimap/repository/IMAP.py has code to handle remotepasseval which is fairly easy to understand:

    passwd = self.getconf('remotepasseval', None)
    if passwd != None:
        return self.localeval.eval(passwd)

You can look for other uses of localeval to see what keys are processed in this way. And if you want other keys to be evaled, it may not be too difficult to create your own version of this program with similar calls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.