Loss if IMAP permissions

Rudy Gevaert Rudy.Gevaert at UGent.be
Sun Dec 10 15:55:21 EST 2006


Robin Cragg wrote:
> 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?


I had to do something similar last night.  I don't know how much 
downtime we would have had when doing a full reconstruct but now our 
downtime was only 14 hours (We have nearly 800GiB of email).  Luckily it 
was in the weekend and most of it at evening and night hours.

To answer your question: put single quotes around the mailbox.  E.g.:
sam 'user.login.folder name' login lrswipcda

I also wrote a script that made the login.sub files.  In our setup these 
  where flat files.

Rudy

-- 
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Rudy Gevaert          Rudy.Gevaert at UGent.be          tel:+32 9 264 4734
Directie ICT, afd. Infrastructuur  Direction ICT, Infrastructure dept.
Groep Systemen                     Systems group
Universiteit Gent                  Ghent University
Krijgslaan 281, gebouw S9, 9000 Gent, Belgie               www.UGent.be
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --


More information about the Info-cyrus mailing list