diff --git a/README.HOWTO-recover-mailboxes.db b/README.HOWTO-recover-mailboxes.db new file mode 100644 index 0000000..b1ab5cc --- /dev/null +++ b/README.HOWTO-recover-mailboxes.db @@ -0,0 +1,31 @@ +With this rpm, you should usually find backups of your mailboxes.db +in /var/lib/imap/backup/. If you don't have them, for any reason, +you can recreate it like this. + +Note: The scripts doesn't care with different hashing schemes of +the mailspool. Adjust as needed! +And please, check the permissions mailboxes.db after creating it. + +#!/bin/sh +# + +# stop cyrus-imapd +service cyrus-imapd stop + +# backup existing mailboxes.db +mv /var/lib/imap/mailboxes.db /var/lib/imap/mailboxes.db.$$ +find /var/spool/imap/?/user -maxdepth 1 -mindepth 1 | \ + while read i; do + echo $(basename $i) + echo "user.$i<\t>default<\t>$i<\t>lrswipcda<\t>cyrus<\t>lrswipcda" >> /tmp/newmboxlist.txt + done + +# we have everyone's base directory in /tmp/newmboxlist.txt, now we +# import the new list +/usr/lib/cyrus-imapd/ctl_mboxlist -u default<\t>$i<\t>lrswipcda<\t>cyrus<\t>lrswipcda" >> /tmp/newmboxlist.txt - done - -# we have everyone's base directory in /tmp/newmboxlist.txt, now we -# import the new list -/usr/lib/cyrus-imapd/ctl_mboxlist -u = 2.59 -BuildRequires: cyrus-sasl-devel >= 2.1.15-1, perl-devel, tcp_wrappers +BuildRequires: autoconf +BuildRequires: cyrus-sasl-devel, perl-devel, tcp_wrappers BuildRequires: db4-devel, openssl-devel, pkgconfig BuildRequires: flex, bison, groff, automake BuildRequires: openldap-devel @@ -83,7 +79,7 @@ Requires(preun): chkconfig, initscripts, coreutils Requires(postun): initscripts Requires: %{name}-utils = %{version}-%{release} -Requires: cyrus-sasl-lib >= 2.1.15, file >= 3.35-1, db4-utils +Requires: file, db4-utils Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) %description @@ -159,21 +155,37 @@ one running the server. %patch20 -p1 -b .bufov %patch21 -p1 -b .nodebug +# add additional sources +mkdir doc/{m4,contrib} +%{__install} -m 644 %{SOURCE10} %{SOURCE15} %{SOURCE16} %{SOURCE17} \ + %{SOURCE18} %{SOURCE19} %{SOURCE20} %{SOURCE21} doc/contrib/ +%{__install} -m 644 %{SOURCE24} %{SOURCE33} %{SOURCE8} %{SOURCE9} doc/ +%{__install} -m 644 %{SOURCE26} %{SOURCE4} %{SOURCE27} %{SOURCE29} doc/m4/ + # only to update config.* files automake -a -f -c || : aclocal -I cmulocal autoheader autoconf -f +# Modify docs master --> cyrus-master +%{__perl} -pi -e "s@master\(8\)@cyrus-master(8)@" man/*5 man/*8 lib/imapoptions +%{__sed} -i -e 's|\([^-]\)master|\1cyrus-master|g;s|^master|cyrus-master|g;s|Master|Cyrus-master|g;s|MASTER|CYRUS-MASTER|g' \ + man/master.8 doc/man.html + +# Modify path in perl scripts +find . -type f -name "*.pl" | xargs %{__perl} -pi -e "s@/usr/local/bin/perl@%{__perl}@" + +# modify lmtp socket path in .conf files +%{__perl} -pi -e "s@/var/imap/@%{_var}/lib/imap/@" master/conf/*.conf doc/cyrusv2.mc doc/m4/%{name}-sendmail-8.12.9-cyrusv2.m4 + +# enable idled in .conf files to prevent error messages +%{__perl} -pi -e "s/# idled/ idled/" master/conf/*.conf + + %build -CPPFLAGS="-I%{_includedir}/et"; export CPPFLAGS +CPPFLAGS="$RPM_OPT_FLAGS -I%{_includedir}/et -I%{_includedir}/kerberosIV"; export CPPFLAGS CFLAGS="$RPM_OPT_FLAGS -fPIC"; export CFLAGS -if pkg-config openssl; then - CPPFLAGS="$(pkg-config --cflags-only-I openssl) $CPPFLAGS"; export CPPFLAGS - CFLAGS="$(pkg-config --cflags openssl) $CFLAGS"; export CFLAGS - LDFLAGS="$(pkg-config --libs-only-L openssl) $LDFLAGS"; export LDFLAGS -fi -CPPFLAGS="-I%{_includedir}/kerberosIV $CPPFLAGS"; export CPPFLAGS CCDLFLAGS="-rdynamic"; export CCDLFLAGS %ifnarch ppc ppc64 LDFLAGS="$LDFLAGS -pie"; export LDFLAGS @@ -202,52 +214,13 @@ LDFLAGS="$LDFLAGS -pie"; export LDFLAGS %{__make} %{__make} -C notifyd notifytest -# Modify docs master --> cyrus-master -pushd man - %{__perl} -pi -e "s@master\(8\)@cyrus-master(8)@" $(ls *5 *8) -popd -pushd doc - %{__perl} -pi -e "s@master@cyrus-master@g;" man.html -popd -pushd doc/man - %{__perl} -pi -e "s@master\(8\)@cyrus-master(8)@;" $(ls *html) -popd - -# Modify path in perl scripts -%{__perl} -pi -e "s@/usr/local/bin/perl@%{__perl}@" $(find . -type f -name "*.pl") +%install +%{__rm} -rf %{buildroot} # Fix permissions on perl programs find . -type f -name "*.pl" -exec %{__chmod} 755 {} \; -# Cleanup of doc dir -find doc perl -name CVS -type d | xargs -r %{__rm} -fr -find doc perl -name .cvsignore -type f | xargs -r %{__rm} -f -find doc -name "*~" -type f | xargs -r %{__rm} -f -find doc -name "*.html.*" -type f | xargs -r %{__rm} -f -%{__rm} -f doc/Makefile.dist* -%{__rm} -f doc/text/htmlstrip.c - -%{__install} -m 644 %{SOURCE23} doc/README.RPM -%{__install} -m 644 %{SOURCE24} doc/README.HOWTO-recover-mailboxes.db -%{__install} -m 644 %{SOURCE33} doc/README.skiplist_recovery -%{__install} -m 644 %{SOURCE8} doc/README.autocreate -%{__install} -m 644 %{SOURCE9} doc/README.autosievefolder -%{__install} -d doc/m4 -%{__install} -m 644 %{SOURCE26} doc/m4/cyrus-procmailrc -%{__install} -m 644 %{SOURCE4} doc/m4/cyrus-user-procmailrc.template -%{__install} -m 644 %{SOURCE27} doc/m4/%{name}-procmail+cyrus.mc -%{__install} -m 644 %{SOURCE29} doc/m4/%{name}-sendmail-8.12.9-cyrusv2.m4 - -# modify lmtp socket path in .conf files -%{__perl} -pi -e "s@/var/imap/@%{_var}/lib/imap/@" master/conf/*.conf doc/cyrusv2.mc doc/m4/%{name}-sendmail-8.12.9-cyrusv2.m4 - -# enable in .conf files to prevent error messages -%{__perl} -pi -e "s/# idled/ idled/" master/conf/*.conf - -%install -%{__rm} -rf %{buildroot} - -# This hack is needed to install the perl files correctly +# This is needed to install the perl files correctly pushd perl/imap %{__perl} Makefile.PL PREFIX=%{buildroot}%{_prefix} INSTALLDIRS=vendor popd @@ -283,21 +256,7 @@ done %{__install} -m 755 %{SOURCE13} %{buildroot}%{_cyrexecdir}/cvt_cyrusdb_all %{__install} -m 755 %{SOURCE28} %{buildroot}%{_cyrexecdir}/rpm_set_permissions %{__install} -m 644 %{SOURCE14} %{buildroot}%{_datadir}/%{name}/rpm/magic -%{__install} -m 644 %{SOURCE10} doc/contrib/ -%{__install} -m 644 %{SOURCE15} doc/contrib/imapcreate -%{__install} -m 644 %{SOURCE16} doc/contrib/cyrus_ldap_quota -%{__install} -m 644 %{SOURCE17} doc/contrib/batchreconstruct -%{__install} -m 644 %{SOURCE18} doc/contrib/bsd2cyrus -%{__install} -m 644 %{SOURCE19} doc/contrib/cpmsg -%{__install} -m 644 %{SOURCE20} doc/contrib/folderxfer -%{__install} -m 644 %{SOURCE21} doc/contrib/inboxfer -%{__install} -m 644 %{SOURCE30} doc/contrib/README - -# fix permissions on perl .so files -find %{buildroot}%{_libdir}/perl5/ -type f -name "*.so" -exec %{__chmod} 755 {} \; - -# Install config files -%{__install} -p -m 644 %{_cyrusconf} %{buildroot}%{_sysconfdir}/cyrus.conf +%{__install} -p -m 644 master/conf/prefork.conf %{buildroot}%{_sysconfdir}/cyrus.conf %{__install} -p -m 644 %{SOURCE6} %{buildroot}%{_sysconfdir}/imapd.conf %{__install} -p -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/pam.d/pop %{__install} -p -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/pam.d/imap @@ -306,10 +265,21 @@ find %{buildroot}%{_libdir}/perl5/ -type f -name "*.so" -exec %{__chmod} 755 {} %{__install} -p -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/pam.d/lmtp %{__install} -p -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/pam.d/nntp %{__install} -p -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/pam.d/csync -%{__install} -p -m 644 %{SOURCE12} %{buildroot}%{_sysconfdir}/sysconfig/%{name} %{__install} -p -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} -%{__install} -p -m 755 %{SOURCE25} %{buildroot}%{_sysconfdir}/cron.daily/%{name} %{__install} -p -m 755 %{SOURCE11} %{buildroot}%{_sysconfdir}/rc.d/init.d/%{name} +%{__install} -p -m 644 %{SOURCE12} %{buildroot}%{_sysconfdir}/sysconfig/%{name} +%{__install} -p -m 755 %{SOURCE25} %{buildroot}%{_sysconfdir}/cron.daily/%{name} + +# Cleanup of doc dir +find doc perl -name CVS -type d | xargs -r %{__rm} -rf +find doc perl -name .cvsignore -type f | xargs -r %{__rm} -f +%{__rm} -f doc/Makefile.dist* +%{__rm} -f doc/text/htmlstrip.c +%{__rm} -f doc/text/Makefile +%{__rm} -rf doc/man + +# fix permissions on perl .so files +find %{buildroot}%{_libdir}/perl5/ -type f -name "*.so" -exec %{__chmod} 755 {} \; # fix conflicts with uw-imap mv %{buildroot}%{_mandir}/man8/imapd.8 %{buildroot}%{_mandir}/man8/imapd.8cyrus @@ -330,24 +300,12 @@ touch %{buildroot}%{ssl_pem_file} # Rename 'master' binary and manpage to avoid clash with postfix %{__mv} -f %{buildroot}%{_cyrexecdir}/master %{buildroot}%{_cyrexecdir}/cyrus-master %{__mv} -f %{buildroot}%{_mandir}/man8/master.8 %{buildroot}%{_mandir}/man8/cyrus-master.8 -%{__mv} -f doc/man/master.8.html doc/man/cyrus-master.8.html -%{__perl} -pi -e 's/master/cyrus-master/g' %{buildroot}%{_mandir}/man8/cyrus-master.8 -%{__perl} -pi -e 's/Master/Cyrus-master/g' %{buildroot}%{_mandir}/man8/cyrus-master.8 -%{__perl} -pi -e 's/MASTER/CYRUS-MASTER/g' %{buildroot}%{_mandir}/man8/cyrus-master.8 -%{__perl} -pi -e 's/master/cyrus-master/g' doc/man/cyrus-master.8.html -%{__perl} -pi -e 's/Master/Cyrus-master/g' doc/man/cyrus-master.8.html -%{__perl} -pi -e 's/MASTER/CYRUS-MASTER/g' doc/man/cyrus-master.8.html # Rename 'fetchnews' binary and manpage to avoid clash with leafnode %{__mv} -f %{buildroot}%{_cyrexecdir}/fetchnews %{buildroot}%{_cyrexecdir}/cyrfetchnews %{__mv} -f %{buildroot}%{_mandir}/man8/fetchnews.8 %{buildroot}%{_mandir}/man8/cyrfetchnews.8 -%{__mv} -f doc/man/fetchnews.8.html doc/man/cyrfetchnews.8.html -%{__perl} -pi -e 's/fetchnews/cyrfetchnews/g' %{buildroot}%{_mandir}/man8/cyrfetchnews.8 -%{__perl} -pi -e 's/Fetchnews/Cyrfetchnews/g' %{buildroot}%{_mandir}/man8/cyrfetchnews.8 -%{__perl} -pi -e 's/FETCHNEWS/CYRFETCHNEWS/g' %{buildroot}%{_mandir}/man8/cyrfetchnews.8 -%{__perl} -pi -e 's/fetchnews/cyrfetchnews/g' doc/man/cyrfetchnews.8.html -%{__perl} -pi -e 's/Fetchnews/Cyrfetchnews/g' doc/man/cyrfetchnews.8.html -%{__perl} -pi -e 's/FETCHNEWS/CYRFETCHNEWS/g' doc/man/cyrfetchnews.8.html +%{__perl} -pi -e 's|fetchnews|cyrfetchnews|g;s|Fetchnews|Cyrfetchnews|g;s/FETCHNEWS/CYRFETCHNEWS/g' \ + %{buildroot}%{_mandir}/man8/cyrfetchnews.8 # compress manpages [ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress @@ -365,29 +323,23 @@ done %{__rm} -f %{buildroot}%{_cyrexecdir}/pop3proxyd find %{buildroot} -name "perllocal.pod" -exec %{__rm} -f {} \; find %{buildroot} -name ".packlist" -exec %{__rm} -f {} \; -%{__rm} -f doc/text/Makefile %{__rm} -f %{buildroot}%{_mandir}/man8/syncnews.8* -%{__rm} -f doc/man/syncnews.8.html find %{buildroot}%{perl_vendorarch} -name "*.bs" -exec %{__rm} -f {} \; %clean %{__rm} -rf %{buildroot} %pre -# Let postun know whether cyrus-imapd was running -if [ -e /var/lock/subsys/cyrus-imapd ]; then - /sbin/service %{name} stop >/dev/null 2>&1 || : - touch /var/lock/subsys/cyrus-imapd -fi +# Create 'cyrus' user on target host +/usr/sbin/groupadd -g %{gid} -r saslauth 2> /dev/null || : +/usr/sbin/useradd -c "Cyrus IMAP Server" -d %{_var}/lib/imap -g %{_cyrusgroup} \ + -G saslauth -s /sbin/nologin -u %{uid} -r %{_cyrususer} 2> /dev/null || : %post /sbin/chkconfig --add %{name} # Force synchronous updates, usually only on ext2 filesystems -for i in %{_var}/lib/imap/{user,quota} %{_var}/spool/imap -do - chattr -R +S $i 2>/dev/null ||: -done +chattr -R +S $i %{_var}/lib/imap/{user,quota} %{_var}/spool/imap 2>/dev/null ||: # Create SSL certificates exec > /dev/null 2> /dev/null @@ -421,13 +373,8 @@ if [ $1 != 0 ]; then /sbin/service %{name} condrestart >/dev/null 2>&1 || : fi -%pre utils -# Create 'cyrus' user on target host -/usr/sbin/groupadd -g %{gid} -r saslauth 2> /dev/null || : -/usr/sbin/useradd -c "Cyrus IMAP Server" -d %{_var}/lib/imap -g %{_cyrusgroup} \ - -G saslauth -s /sbin/nologin -u %{uid} -r %{_cyrususer} 2> /dev/null || : - %post utils +# FIXME: remove when setup > 2.8.10 is released # Add service entries if necessary if ! %{__grep} -q ^csync %{_sysconfdir}/services; then echo -e 'csync\t\t2005/tcp\t\t\t# Cyrus IMAP Replication Daemon' >> %{_sysconfdir}/services @@ -573,6 +520,9 @@ fi %{_mandir}/man1/* %changelog +* Thu Nov 26 2009 Michal Hlavinka - 2.3.15-8 +- spec cleanup + * Tue Nov 24 2009 Michal Hlavinka - 2.3.15-7 - rebuild with new db4 (#540093) - spec cleanup diff --git a/cyrus_ldap_quota.pl b/cyrus_ldap_quota.pl deleted file mode 100644 index 2fcf052..0000000 --- a/cyrus_ldap_quota.pl +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/perl -use Cyrus::IMAP::Admin; - -# This script was created by Kevin J. Menard, Jr. . -# It requires root privileges to write to a file in /etc. Best use is -# to set this up as cron job. Works for me. Hope it does for you. -# Any questions/complaints/praise/whatever, send 'em to the address -# above. -- 08/16/2001 - - -# These are the variables you might want to tweak. -my $quota_attr = "mailQuota"; -my $mail_attr = "mailRoutingAddress"; -my $user = "cyrus"; -my $passwd = "blah"; - -# These are the ones that you shouldn't have to. -my @entries = (); -my $index = 0; -my $counter = 0; -my $old_timestamp = 0; -my $timestamp = "199412161032Z"; - -# Open the /etc/cyrus_ldap_quota_time file; it's a long name, but -# shouldn't interfere with existing files :) This file contains 1 line, -# the generalized time format of the last time the script ran. This is -# used for the search, so we only update quotas that have been modified -# since then. - -{ - if (-e "/etc/cyrus_ldap_quota_time") - { - open(TIME_FILE, "/etc/cyrus_ldap_quota_time") or die "could not - open the time file: $!\n"; - - while() { $old_timestamp = $_; } - - close(TIME_FILE); - } - - # Now we deal with the case where the file doesn't exist, that is to - # say the first time the script was run. - - unless ($old_timestamp == 0) { $timestamp = $old_timestamp; } - - - # Now that we have that information, we can overwrite the file with - # the new timestamp. Maybe this overkill, but this is only a - # temporary solution anyway. - - open(TIME_FILE, ">/etc/cyrus_ldap_quota_time") or die "could not - create file: $!\n"; - - my @time = (localtime)[0..5]; - - printf TIME_FILE $time[5] + 1900; - printf TIME_FILE "%02d", $time[4] + 1; - for (my $i = 3; $i >= 0; $i--) { printf TIME_FILE "%02d", $time[$i];} - print TIME_FILE 'Z'; - - close(TIME_FILE); -} - - -# This is where we do the search and then parse the results into a -# useable form. In this case, an arry of hash entries. -{ - # Okay, this very ugly line sets up the LDAP search, and the strips - # away the meaningless stuff. This could be prettier, but I didn't - # want to add a dependency for an LDAP module, and everyone should - # have LDAP search. The greps are just to make things simpler. - - (my $query = "ldapsearch -x '(&(modifyTimestamp>=$timestamp)($quota_attr=*))' $quota_attr $mail_attr - | grep -v ^# | grep -v ^dn | grep -v ^version | grep -v ^search | grep -v ^result | grep -v ^\$") =~ s!\n!!; - - # Now actually do the commands in the above line. - my $result = `$query`; - - - # Split the output into an array, one entry per line. - my @output = split(/\n/, $result); - - # Now go through each line . . . - foreach (@output) - { - # Split on the attribute:value boundary. - (my $key, my $value) = split(/: /); - - # Handle mailRoutingAddress; strip away everything after '@'. - if ($value =~ m!@!) - { - ($value, undef) = split (/@/, $value); - } - - # Add each doctored up attribute:value pair to the entries array. - $entries[$index]{$key} = $value; - - # A crude hack to make sure each of the two attributes makes it - # into one of the entries array element. - if ($counter % 2) - { - $index++; - } - - $counter++; - } -} - -# Now here's the actual interaction with Cyrus IMAPd. It's all pretty -# self-explanatory. -{ - my $imap = Cyrus::IMAP::Admin->new('localhost') or die "imap: - cannot connect to server: $!\n"; - - $imap->send(undef, undef, "LOGIN %s %s", $user, $passwd) or die - "could not send user:pass to the server: $!\n"; - - for (my $i = 0; $i <= $#entries; $i++) - { - $imap->setquota("user." . $entries[$i]{$mail_attr}, "STORAGE", - $entries[$i]{$quota_attr}) - or die "imap: could not set quota for - user.$entries[$i]{$mail_attr}: $!\n"; - } - - $imap=undef; -} diff --git a/imapcreate.pl b/imapcreate.pl deleted file mode 100644 index b26af24..0000000 --- a/imapcreate.pl +++ /dev/null @@ -1,159 +0,0 @@ -#!/usr/bin/perl -w -# -# imapcreate: create IMAP mailboxes with quotas -# Reads user names from standard input. -# launch without argument for a short help. -# -# originally found on http://cyrus-utils.sourceforge.net -# (could not find any copyright info, thought) -# -# enhanced by Cl�ment "nodens" Hermann -# -# I'd like to consider this as GPL'd (cf www.gnu.org), but won't add any copyright without the original author's consent. -# - -use Getopt::Long; -use Cyrus::IMAP::Admin; -use strict; - - -my $debug; -my $user; -my $pass; -my $quota; -my @part; -my $useunixhierarchy; -my @mailboxes; -my $delete; -my $cyrus; - -sub usage { - print <]] - [-q quota] [-t partition:list] [-s] [-v] - -Options: - -t : the partition to use. Default to the \"default\" partition - -q ; the quota, if a quota is needed. It is normally in KiloBytes, but you can use m,M,g or G suffix to use MB or GB instead, e.g 10k, 2048M or 100g - -m : a comma-separated mailbox list - -u : your cyrus admin user (usually cyrus or cyradm) - -p : your cyrus admin password (if not provided, it will be asked for) - -s : use the unix hierarchy separator (see imapd.conf(1)) - -d : delete mailboxes instead of creating them - -v : run in debug mode, and print information on stdout - -If no password is submitted with -p, we'll prompt for one. -if no mailbox name is specified with -m, read user names from standard input - - examples: - imapcreate -u cyradm -m foo,bar,joe -q 50000 -t p1:p2 mail.testing.umanitoba.ca - cat list.txt | imapcreate -u cyradm -p 'cyruspass' -q 50M mail.testing.umanitoba.ca -EOU - exit 1; -} - -# Create a mailbox... usage : &CreateMailBox(user,partition[,quota]). -# You have to be authentified already. We use "$cyrus" as the connection name. -# partition can be 'default' -sub CreateMailBox { - my $mbuser = $_[0]; - my $mbpart = $_[1]; - my $mbquota = $_[2]; - - print "Creating $mbuser on $mbpart\n" if $debug; - if ($mbpart eq 'default') { - $cyrus->createmailbox($mbuser); - } - else { - $cyrus->createmailbox($mbuser, $mbpart); - } - warn $cyrus->error if $cyrus->error; - - # Set the quota - if ($mbquota) { - print "Setting quota for $mbuser to $mbquota\n" if $debug; - $cyrus->setquota($mbuser, 'STORAGE', $mbquota); - warn $cyrus->error if $cyrus->error; - } -} - -# Delete a mailbox. Usage: $DeleteMailBox($user) -# Assuming we use $user as the admin. -sub DeleteMailBox { - my $mbuser = $_[0]; - my $delacl = "c"; - - print "Deleting $mbuser\n" if $debug; - $cyrus->setaclmailbox($mbuser, $user, $delacl); - $cyrus->deletemailbox($mbuser); - warn $cyrus->error if $cyrus->error; -} - -GetOptions("d|delete" => \$delete, "u|user=s" => \$user, "p|pass=s" => \$pass, "m|mailboxes=s" => \@mailboxes, "q|quota=s" => \$quota, - "t|part=s" => \@part, "s|UnixHierarchy" => \$useunixhierarchy, "v|verbose" => \$debug ); -@part = split(/:/, join(':', @part)); -push @part, 'default' unless @part; -my $pn = 0; -@mailboxes = split(/,/, join(',', @mailboxes)); - -my $server = shift(@ARGV) if (@ARGV); -usage unless $server; - -# quotas formatting: -if ($quota) { - if ($quota =~ /^(\d+)([mk]?)$/i) { - my $numb = $1; - my $letter = $2; - if ($letter =~ /^m$/i) { - $quota = $numb * 1024; - print "debug: quota=$quota\n" if $debug; - } elsif ($letter =~ /^k$/i) { - $quota = $numb; - print "debug: quota=$quota\n" if $debug; - } else { - die "malformed quota: $quota (must be at least one digit eventually followed by m, M, k or K\n"; -# $quota = $numb; -# print "debug: quota=$quota\n" if $debug; - } - } else { - die "malformed quota: $quota (must be at least one digit eventually followed by m, M, k or K\n"; - } -} - -# Authenticate -$cyrus = Cyrus::IMAP::Admin->new($server); -$cyrus->authenticate(-mechanism => 'login', -user => $user, - -password => $pass); -die $cyrus->error if $cyrus->error; - -# if there isn't any mailbox defined yet, get them from standard input -if (! (defined $mailboxes[0])) { - # For all users - while (<>) { - chomp; - my $mbox = $_; - push @mailboxes, $mbox; - } -} - -# create/delete mailboxes for each user -foreach my $mailbox (@mailboxes) { - if ($useunixhierarchy) { - $mailbox = 'user/' . $mailbox; - } else { - $mailbox = 'user.' . $mailbox; - } - - if ($delete) { - &DeleteMailBox($mailbox) - } else { - # Select the partition - my $pt = $part[$pn]; - $pn += 1; - $pn = 0 unless $pn < @part; - &CreateMailBox($mailbox,$pt,$quota) - } -} -