scripted delete mailbox for cyradm

Aleksandar Milivojevic amilivojevic at pbl.ca
Thu Feb 10 14:18:59 EST 2005


Craig White wrote:
> OK - I think I can deal with this but...
> 
> #cyradm localhost
> IMAP Password:
> <localhost.localdomain> lm user.public
> user.public (\HasNoChildren)
> 
> and
> # ./ldap_useradmin.deluser
> Failed to delete mailbox at ./ldap_useradmin.deluser line 11.
> 
> means we died and didn't delete the mailbox.

You need to add +c to cyrus on that mailbox, before deleting it.  On
command line, you would do "sam user.public cyrus +c".  From Perl, I
believe it should be something like:

    $imap->setacl("user.public", "cyrus" => "+c")
       or die $imap->error;

> and lastly, since this is perl and I'm a lost duck, is there a way to
> direct standard and error out on this to a file? I love to have a means
> to keep track of what happened when I call from another process and
> don't have a terminal to work with.

I'm not Perl expert myself.  I heavilly use trial&error + www.perl.com
documentation even for simple scripts ;-)

You can do it from a calling program.  Or you can have script log errors
using syslog.  This is from head, might not work as expected.

    use Sys::Syslog;
    openlog("your_script_name", "pid", "local1");

    $rc = $imap->setacl("user.public", "cyrus" => "+c")
    if (! defined $rc) {
       syslog("err", "Failed to set ACL: $imap->error");
       die "Failed to set ACL: $imap->error";
    }

There's a comment in man page for Cyrus::IMAP::Admin that you'll
probably need to use setacl method before deleting mailbox (if doing it
as cyrus user).  In Cyrus, administrator doesn't have the right to
delete folders by default.  This is kind of failsafe to prevent you
accidentally deleting users.  Hmmm...  I always wondered if "dm user"
would do what I think it would (delete all the users).

-- 
Aleksandar Milivojevic <amilivojevic at pbl.ca>    Pollard Banknote Limited
Systems Administrator                           1499 Buffalo Place
Tel: (204) 474-2323 ext 276                     Winnipeg, MB  R3T 1L7

---
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html




More information about the Info-cyrus mailing list