# mailboxes to update during file traversal
acl_mailboxes = None
# acls retrieved from a file
- file_acls = None
+ _file_acls = None
def __init__(self):
"""Creates a connection and a user session."""
self.created_mailboxes = []
self.acl_mailboxes = []
- self.file_acls = {}
+ self._file_acls = {}
@classmethod
def _message_read(cls, filename):
return message
- def load_mailbox_list(self, mboxlistfile, original_user):
+ def get_mailbox_acls(self, mailbox, original_user):
+ """Get the acls loaded from a file for a given mailbox.
+ Should be used for access of mailbox acls instead of attribute"""
+
+ # translate the mailbox to internal stored format
+ internal_mailbox = mailbox.replace("INBOX/", "user/" + original_user + "/")
+ internal_mailbox = internal_mailbox.replace(".", "^")
+ internal_mailbox = internal_mailbox.replace("/", ".")
+ logging.debug("Get acls for mailbox %s translated as %s", mailbox, internal_mailbox)
+
+ # retrieve from internal dicitonary attribute of file acls
+ try:
+ mb_acls = self._file_acls[internal_mailbox]
+ except KeyError:
+ # no rights for the mailbox were found and warn if acl file loaded
+ if len(self._file_acls) > 0:
+ logging.warning("Could not find the acls for mailbox %s %s", mailbox, self._file_acls.keys())
+ mb_acls = {}
+
+ return mb_acls
+
+ def load_mailbox_list(self, mboxlistfile):
"""Load the list of mailboxes and acl rights for each from file."""
try:
aclstr = linedata[1]
# changes acls key encoding to internal cyrus format and makes it absolute (as folder).
- key = linedata[0].replace("INBOX/", "user/" + original_user + "/")
- key = key.replace(".", "^")
- key = key.replace("/", ".")
-
+ key = linedata[0]
+
# loop through acl rights string and build dictionary of users and rights
while(aclstr != ""):
try:
logging.warning("Illegal acl string in mailbox list dump: %s", line)
aclstr = ""
continue
- aclstr = acldata[2]
acls[acldata[0]] = acldata[1]
+ aclstr = acldata[2]
- self.file_acls[key] = acls
+ self._file_acls[key] = acls
except IOError:
logging.warning("Could not open mboxlist file %s", mboxlistfile)