Hiago Prata
Hiago Prata

Reputation: 117

Cyrus-IMAP administration with Python IMAPlib

I have some legacy applications used to administrate some Cyrus-IMAPd servers. They use a third party wrapper for the native IMAPlib Python module.

Since I started to migrate the mailboxes stored in these servers to others running the most recent version of cyrus-imapd on Debian Stretch (2.5.10-3), some of the new servers stopped working with these applications.

I've done some investigation already, and found some useful information. I started by dumping the communication between the application and the servers. After a login is successfully made, the application sends the following command to the server:

TAG DUMP NIL

which is answered with:

TAG NO permission denied

for the servers that stopped working, and:

TAG NO Mailbox does not exist

for the ones still working. Where TAG is the IMAP command tag prepended automatically by the application.

Strangely, if the command is run directly on the server, it responds with the same answer given by the working servers. That means it has something to do with the wrapper used. And here is what I found in the login part of the source code:

def login(self, username, password, forceNoAdmin = False):
    if self.AUTH:
        self.__doexception("LOGIN", self.ERROR.get("AUTH")[1])
    try:
        res, msg = self.m.login(username, password)
        admin = self.m.isadmin()
    except Exception, info:
        error = info.args[0].split(':').pop().strip()
        self.__doexception("LOGIN", error)
    if admin or forceNoAdmin:
        self.ADMIN = username
    else:
        self.__doexception("LOGIN", self.ERROR.get("ADMIN")[1])
    self.SEP = self.m.getsep()
    self.AUTH = True
    self.__verbose( '[LOGIN %s] %s: %s' % (username, res, msg[0]) )

def isadmin(self):
        ### A trick to check if the user is admin or not
        ### normal users cannot use dump command
        try:
            res, msg = self._simple_command('DUMP', 'NIL')
            if msg[0].lower().find('denied') == -1:
                return True
        except:
            pass
        return False

This isadmin() function is the one that sends the DUMP NIL command to the server, but it doesn't seem to have anything wrong.

I tried to find out what the DUMP NIL stands for, with no success.

So I need help to successfully authenticate as administrator on the servers, or to find another application that let me administrate the servers.

Upvotes: 0

Views: 337

Answers (0)

Related Questions