-- Leo's gemini proxy

-- Connecting to retry-abort.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; lang=fr

./ code

../ Retry/Abort


Offlineimap, python3 and the gnome keyring


I'm a long time user of offlineimap. I use it via mu4e, which is my

everyday mail client. I recently upgraded the system on my home

machine to Xubuntu 20.04. And then the troubles began…


Note: this paper is not about learning to use mu4e or offlineimap. It

is about making offlineimap run on recent linux distros.


python3


Xubuntu 20.04 conforms to the Debian politics regarding python:

python3 is the default, and if you install python2, its support is

minimal. I have no rants about this as python2 support is now

discontinued.


The only problem is that many applications have not been ported yet

and run with python2, and offlineimap is one of them. And the fact is

that offlineimap is no longer included in the distribution !


offlineimap


Ok, so, is it possible to run offlineimap on Xubuntu 20.04 ? Let's

try. After cloning the repository and checked the sources, all the

necessary modules seem to be present in the distro, so lets `apt

install blah blah blah`.


First run gave a bunch of errors. Offlineimap allows you to add python

code, in particular to handle tasks such as mailbox name translation

between local names and remote names, or authentication.


That's the point: I used to write an authentication class in order to

retrieve the authentication data for each imap host from the gnome

keyring (I use extensively the gnome keyring to store all my

authentication data).


Alas ! my class relied of the `gnomekeyring` module, which does not

exist anymore.


the gnome keyring (and python)


A little snarfing on the net informed me that now I should consider

using the `keyring` module. After having a look at it, it appears

that:


- it is Python3 only: why not, but offlineimap is python2…


- it claims to support a bunch of keyrings: Kde, gnome, MacOS,

etc...


I tend to be very suspicious about software which claims to run on every

hardware whatever the software configuration is. The sequel will

acknowledge my view: I never managed to access the gnome keyring, my

little test program complained about a faulty dbus config.


So I temporarily gave up the idea of accessing the gnome keyring (I

needed to quickly have a running email configuration !), and scratched

a temporary solution using the `.authinfo.gpg` file from emacs with

a shell pipeline and a bunch of lines of python code. At least it

worked, even if not very satisfactory.


the keyring module


the gnome keyring (at last)


Finally, a couples of days ago, I stumbled across the `secretstorage`

module, which claims to allow to access to the gnome keyring. After

a quick test, I was convinced. It is simple to use, and it works !


Ok, but it's python3 only. Argh…


So… back to the offlineimap problem. Digging again on the net to find

an attempt to port it to python3, and yes, I found it. The port works,

but it also shows that unfortunately offlineimap is not in a very

active developement status. It has been abandonned by its main

maintainer, which claimed 4 years ago to work on a replacement

software, `imapfw`, but looking at the github page of this project, it

seems totally stucked for 5 years !


the secretstorage module

the python3 port of offlineimap


So, where's the code ?


Oh, yes, for those interessed, I finally wrote a small python class

which allows access entries in the gnome keyring containing

authentication information.


The class is very simple to use, and relies on the following hypotheses :


- the searched entries are in the `login` keyring.


- the entries are identified by a pair (repository name,

protocol). Both informations are encoded as attributes of the entry

(`repo` and `protocol` attributes). I choosed not to use the label

for identification. In my case all the entries have the same label,

which is "offlineimap". It helps me to spot the offlineimap

dedicated entries in the login keyring.


- Each entry, contains two other attributes : `host` (an imap host

name) and `user` (the username used for the authentication on the

imap server).


Here is the source :


src/my_keyring.py



Using this class, it very easy to write a little python script which

will populate the keyring with the entries you need. for example, the

following script will create or update an entry.


=>src/gnome-keyring-update.py


-- Response ended

-- Page fetched on Fri May 3 08:12:42 2024