Skiplist errors on Cyrus 2.3.12
Reinhard Zierke
zierke at informatik.uni-hamburg.de
Fri Jul 11 09:10:10 EDT 2008
Hi Bron,
> Are you able to send me the exact sequence of commands your script runs?
> Is there anything else between the deletes? I'll go have a look at the
> source code.
My script removemailboxes is attached. An example for its invocation is:
-------------------------------------------------------------------
cyrus at mailhost% removemailboxes
Password:
Lösche Mailbox user.4jacobse (j/n/q) ? j
... gelöscht
Lösche Mailbox user.4kail (j/n/q) ? j
... setacl error:cyrus: c:
1 von 2 Mailboxen gelöscht
-------------------------------------------------------------------
Thank you,
Reinhard
--
Reinhard Zierke Universität Hamburg, MIN-Fakultät,
zierke at informatik.uni-hamburg.de Department Informatik
postmaster at informatik.uni-hamburg.de Vogt-Kölln-Straße 30, D-22527 Hamburg
Tel.: (040) 42883-2295/2276 Fax: -2241
-------------- next part --------------
#!/opt/bin/perl -w
#
# removes mailboxes for non-existent / deleted users
#
use strict;
use Cyrus::IMAP::Admin;
use Term::ReadKey;
my $myself = (getpwuid($<))[0] || $ENV{LOGNAME};
my %admin;
my $conffile = "/etc/imapd.conf";
open CONF, $conffile or die "Can't open $conffile\n";
while (<CONF>) {
next unless /^admins:/;
chomp;
s/^admins:\s*//;
foreach (split / /, $_) {
$admin{$_} = $_;
}
}
close CONF or die "Can't close $conffile\n";
unless ($admin{$myself}) {
print "$myself ist kein IMAP-Administrator\n";
exit 1;
}
undef %admin;
my (%user, %nouser, %group, @group);
my %mailboxes; # existing Cyrus mailboxes
my @user = qw(abuse archive drei-s postmaster); # pseudo-users with mailboxes
foreach (@user) {
$user{$_} = 1;
$group{$_} = 'system';
}
my @nouser = qw(news nobody nobody4 noaccess); # users without mailboxes
foreach (@nouser) {
$nouser{$_} = 1;
}
my $file = '/etc/postfix/local_mailboxes';
open (FILE, $file) or die "Can't open file $file\n";
while (<FILE>) {
chomp;
if (/^([\w-]+)[:\s]/) {
$user{$1} = 1;
$group{$1} = 'system';
}
}
close FILE or die "Can't close file $file\n";
open GROUP, "/usr/bin/ypcat group|" or die "Can't ypcat group\n";
while (<GROUP>) {
chomp;
my ($group, $gid) = (split /:/)[0,2];
$group[$gid] = $group;
}
close GROUP or die "Can't close group\n";
open PASSWD, "/usr/bin/ypcat passwd|" or die "Can't ypcat passwd\n";
while (<PASSWD>) {
chomp;
my ($login, $uid, $gid) = (split /:/)[0,2,3];
next if ($nouser{$login});
unless (defined $group[$gid]) {
print "no group for $login, gid = $gid\n";
next;
}
$user{$login} = $uid;
$group{$login} = $group[$gid];
}
close PASSWD or die "Can't close passwd\n";
my $client = Cyrus::IMAP::Admin->new('localhost', 943);
$client->authenticate;
if ($client->error) {
print $client->error, "\n";
exit 1;
}
my ($anzahl, $gesamt) = (0, 0);
foreach my $mailbox ($client->list('%', 'user.')) {
my ($name, $attributes, $separator) = @{ $mailbox };
my $login = $name;
$login =~ s/^user\.//;
next if $user{$login};
$gesamt++;
print "Lösche Mailbox $name (j/n/q) ? ";
ReadMode 'cbreak';
my $key;
while (($key = lc ReadKey(0)) !~ /^[jynq]/) {};
ReadMode 'normal';
print "$key\n";
next if ($key eq 'n');
last if ($key eq 'q');
print "... ";
$client->setacl($name, $myself => 'c');
if ($client->error) {
print "setacl error:", $client->error, "\n";
last;
}
$client->delete($name);
if ($client->error) {
print "delete error:", $client->error, "\n";
last;
} else {
$anzahl++;
print "gelöscht\n";
}
}
print "\nKeine Mailboxen zu löschen\n" unless $gesamt;
print "\n$anzahl von $gesamt Mailboxen gelöscht\n" if $anzahl;
exit 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 193 bytes
Desc: not available
Url : http://lists.andrew.cmu.edu/pipermail/info-cyrus/attachments/20080711/0dd917fc/attachment.bin
More information about the Info-cyrus
mailing list