return message
def load_mailbox_list(self, mboxlistfile = ""):
- mboxdb = []
+ mboxdb = {}
if mboxlistfile != "":
try:
with open(mboxlistfile, 'r') as acl_file:
for line in acl_file:
- lineparts = []
- acls = []
-
+ acls = {}
linedata = MBOXFILE_LINE.match(line).groups()
- #print(linedata)
- #check this condition
+ #!!! test this condition
if len(linedata) == 0:
print("Illegal line in mailbox list dump: %s" % line)
sys.exit()
-
- lineparts.append(linedata[0])
+ key = linedata[0]
aclstr = linedata[1]
+
+ # loop through acl rights string and build dictionary of users and rights
while(aclstr != ""):
- this_acl = []
acldata = ACL_STRING.match(aclstr).groups()
if len(acldata) == 0:
print("Illegal line in mailbox list dump: %s" % line)
sys.exit()
aclstr = acldata[2]
- this_acl.append(acldata[0])
- this_acl.append(acldata[1])
- acls.append(this_acl)
-
- lineparts.append(acls)
- mboxdb.append(lineparts)
-
- #print(mboxdb)
+ acls[acldata[0]]=acldata[1]
+
+ mboxdb[key] = acls
+
except IOError:
print("Could not open mboxlist file %s." % mboxlistfile)
return mboxdb
# suggest file modification date for internaldate
yield (message, mailpath, os.path.getmtime(new_filepath))
except:
- print("Could not retrieve mail from file: %s", new_filepath)
+ print("Could not retrieve mail from file: %s" % new_filepath)
else:
if os.path.isdir(new_filepath):
# cyrus ^ vs . storage replacement
yield rcr
#print("Done with directory %s and mailbox %s." % (new_filepath, new_mailpath))
# mark mailboxes that need acl update
- print("acl %s" % mailpath)
self.acl_mailboxes.append(mailpath)
return
#
mailbox = mailbox.replace("INBOX/", "user/" + original_user + "/")
mailbox = mailbox.replace(".", "^")
mailbox = mailbox.replace("/", ".")
-
- lookfor = mailbox
- for current_folder in mailbox_list:
- # find folder to set all acls
- if current_folder[0] == lookfor:
- acl_listref = current_folder[1]
- for aclref in acl_listref:
- print(aclref[0], target_user, original_user)
- if aclref[0] != target_user and aclref[0] != original_user:
- try:
- #self.mail_con.setacl(mailbox, thisaclref[0], thisaclref[1])
- print("Set acls %s for user %s on mailbox %s." % (aclref[1], aclref[0], mailbox))
- except:
- print("Could not set acls %s for user %s on mailbox %s." % (aclref[1], aclref[0], mailbox))
- break
-
+
+ # find folder to set all acls
+ try:
+ mbox_acls = mailbox_list[mailbox]
+ except KeyError:
+ # no rights for the mailbox were found
+ return
+ for acl_user in mbox_acls:
+ print(acl_user, target_user, original_user)
+ if acl_user != target_user and acl_user != original_user:
+ try:
+ #self.mail_con.setacl(mailbox, thisaclref[0], thisaclref[1])
+ print("Set acls %s for user %s on mailbox %s." % (mbox_acls[acl_user], acl_user, mailbox))
+ except:
+ print("Could not set acls %s for user %s on mailbox %s." % (mbox_acls[acl_user], acl_user, mailbox))
+
return
def delete_mailboxes(self, deleted_mailbox):
# mailboxes marked for creating and acl update
# add acls after all subfolders or their acls will be derived from parent folder
- print(storage.created_mailboxes, storage.acl_mailboxes)
+ #print(storage.created_mailboxes, storage.acl_mailboxes)
for new_mailbox in storage.created_mailboxes:
session.create_mailbox(new_mailbox)
for acl_mailbox in storage.acl_mailboxes: