Loss if IMAP permissions
Robin Cragg
robincragg at legendplc.com
Tue Oct 17 05:53:15 EDT 2006
Hi,
Our mailbox.db file recently became corrputed, and so I wrote a little script to generate a new one, based purely on the contents of /var/spool/imap/ . The script worked fine, and I could see all the folders in cyradm, and could log in as a user with no problem. However, my import seems to have lost all directory permissions, and as such, I could not do either a folder list of see emails when logged in as an IMAP user (though I was fine as a POP3 user with seeing emails). When I manually added permissions for the user for each folder, I regained the ability to see emails and folders.
Can anybody tell me what I did wrong?
What I did:
#!/usr/bin/perl
listdirs("user");
sub listdirs ($) {
my $dir = shift;
my @dirs = ();
opendir DIR, "/var/spool/imap/$dir";
while ($entry = readdir DIR) {
next if ($entry =~ /^\./ || ! -d "/var/spool/imap/$dir/$entry");
$cyrname = $dir;
$cyrname =~ s:/:.:g ;
if ($dir eq "user") {
$username = $entry;
} else {
$username = $dir;
$username =~ s:^user/([^/]+).*:$1: ;
}
print "${cyrname}.${entry}\tdefault\t$username\tlrswipcda\n";
# print "sam ${cyrname}.${entry} $username lrswipcda\n";
push @dirs, $entry;
}
closedir DIR;
foreach (@dirs) { listdirs("$dir/$_") ; }
}
the hashed out line has the command I pasted into cyradm to fix the permissions problem.
This generates a file with entries like this:
user.robin default robin lrswipcda
user.robin.Abuse default robin lrswipcda
user.robin.Clients default robin lrswipcda
user.robin.Sent_Mail default robin lrswipcda
(the white space is all tabs) I then used this as the import source for the new database (after firast deleting the old one and all files in db)
cat /var/imap/mailboxes.db.import | /usr/cyrus/bin/ctl_mboxlist -u
I also noticed there were one or two folders with white space in their names, and that cyradm complained about this. Does anyone know how to get it to accept these?
thanks,
Robin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.andrew.cmu.edu/pipermail/info-cyrus/attachments/20061017/8099199b/attachment.html
More information about the Info-cyrus
mailing list