使用Python IMAPlib进行Cyrus-IMAP管理

时间:2018-02-16 17:57:31

标签: python email imap administration cyrus

我有一些遗留应用程序用于管理一些Cyrus-IMAPd服务器。他们使用third party wrapper作为本机IMAPlib Python模块。

由于我开始将存储在这些服务器中的邮箱迁移到在Debian Stretch(2.5.10-3)上运行最新版cyrus-imapd的其他邮箱,因此一些新服务器停止使用这些应用程序。

我已经做了一些调查,并找到了一些有用的信息。 我开始通过转储应用程序和服务器之间的通信。成功登录后,应用程序将以下命令发送到服务器:

  

TAG DUMP NIL

回答:

  

标签没有许可被拒绝

用于停止工作的服务器,并且:

  

标签没有邮箱不存在

对于仍在工作的人。其中 TAG 是应用程序自动预装的IMAP命令标记。

奇怪的是,如果命令直接在服务器上运行,它将使用工作服务器给出的相同答案进行响应。这意味着它与使用的包装器有关。这是我在源代码的登录部分找到的内容:

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

isadmin()函数是将DUMP NIL命令发送到服务器的函数,但它似乎没有任何错误。

我试图找出DUMP NIL代表什么,但没有成功。

所以我需要帮助才能在服务器上成功地作为管理员进行身份验证,或者找到另一个让我管理服务器的应用程序。

0 个答案:

没有答案