Jo Rhett wrote:
Do we really have to write a script to loop through all
of the accounts and fix the ACLs for every folder?
Well if you find yourself needing to do this (I did) the following
script will save you a lot of time. This could possibly use improvement
to look for any write permissions instead of just the specific ones
assigned to all mailboxes, but it solved our problem asap.
#!/usr/local/bin/perl
use strict;
use Cyrus::IMAP::Admin;
my $cyrus_pass = $ARGV[0];
# Flush immediately
$|=1;
my $cyrus = new Cyrus::IMAP::Admin( 'localhost' )
|| die Cyrus::IMAP::Admin->error();
$cyrus->authenticate( 'login', 'imap', '', 'root', '0', '10000',
$cyrus_pass )
|| die $cyrus->error();
my $oldrights = 'lrswipkxtea';
my $newrights = 'lrswipkxtecda';
my( @results ) = $cyrus->listmailbox( '*' );
foreach my $result ( @results ) {
my $mailbox = shift( @{ $result } );
my %rights = $cyrus->listacl( ${mailbox} );
while( my( $user, $rights ) = each %rights ) {
# Fix the flags if they have all rights
if( $rights eq $oldrights ) {
# Now do the change
print qq|Doing setacl( ${mailbox}, $user => $newrights )... |;
$cyrus->setacl( ${mailbox}, $user => $newrights )
|| die $cyrus->error();
print "done.\n";
}
}
}
exit 0;
--
Jo Rhett
Network/Software Engineer
Net Consonance
----
Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html