--- a/ma Tue Jul 31 10:46:37 2007 +0000
+++ b/ma Fri Feb 21 11:56:39 2014 +0100
@@ -5,10 +5,10 @@
# $Id$
#
use constant USAGE => <<'#';
-Usage: !ME! account|alias|group --add|--list|--modify|--delete [options] [user|alias|shared mbox]
+Usage: !ME! account|alias|group|acl --add|--list|--modify|--delete [options] [user|alias|shared mbox]
* common options *
--ldap_server=s LDAP-Server [!$Cf->ldap_server!]
- --ldap_base=s LDAP-Basis [!$Cf->ldap_base!]
+ --ldap_base=s LDAP-Base [!$Cf->ldap_base!]
--ldap_admin=s LDAP BIND DN [!$Cf->ldap_admin!]
--ldap_password=s [!$Cf->ldap_password!]
@@ -19,7 +19,8 @@
* account options *
--default_domain Default Domain [!$Cf->default_domain!]
--[no]mbox Create MBox [!$Cf->mbox!]
- --imap_quota=i Mail Quota (MB) [!$Cf->imap_quota!]
+ --imap_quota=i Mail Quota [!$Cf->imap_quota!]
+ (Bytes)
--address=s Primary Mail [!$Cf->address!]
--other:s Alternative Mail addresses
(comma sep.) [!$Cf->other!]
@@ -28,17 +29,28 @@
--forward:s Forwarding [!$Cf->forward!]
--fullname=s Real Name [!$Cf->fullname!]
- --password=s Passwort [!$Cf->password!]
+ --password=s Password [!$Cf->password!]
+
+ * acl options *
+ --acl_admin=s ACL Admin [!$Cf->acl_admin!]
+ --acl_password=s Pasword [!$Cf->acl_admin!]
+ --folder:s@ Folder(s) [!join ',', @{$Cf->folder}!]
+ --acl=s ACL list [!$Cf->acl!]
+ --[no]recursive Rekursive [!$Cf->recursive!]
* alias options *
--members=s List of Members [!$Cf->members!]
* shared mailbox options *
+ [ currently not supported ]
+
* group options *
--members=s List of Members [!$Cf->members!]
--description=s Descripton [!$Cf->description!]
+ [ currently not supported ]
+
Passwords for LDAP and IMAP can be read from environment LDAP_PASS resp. IMAP_PASS.
Options can be read from config file named in $MA_CONF [!$ENV{MA_CONF}!].
@@ -52,13 +64,12 @@
use warnings;
use IO::File;
-use Cyrus::IMAP::Admin;
use AppConfig qw(:expand);
use File::Basename;
use FindBin;
use Carp;
-use lib ("$FindBin::RealBin/..", "$FindBin::RealBin/../lib/ma");
+use lib ( "$FindBin::RealBin/..", "$FindBin::RealBin/../lib/ma" );
use Common;
use ldapBase;
@@ -68,57 +79,61 @@
sub help();
my $Module = shift if @ARGV && $ARGV[0] !~ /^-/;
- $Module ||= "UNKNOWN";
-
+$Module ||= "UNKNOWN";
-$SIG{__DIE__} = sub { die "\n".ME.": ", @_ };
-
+$SIG{__DIE__} = sub { die "\n" . ME . ": ", @_ };
MAIN: {
$Cf = new AppConfig Common::CONFIG or die;
- if (exists $ENV{MA_CONF} and -f $ENV{MA_CONF}) {
- my $f = $ENV{MA_CONF};
- die ": $f is group/world readable/writeable\n" if 077 & (stat _)[2];
- $Cf->file($f) or die;
+ if ( exists $ENV{MA_CONF} and -f $ENV{MA_CONF} ) {
+ my $f = $ENV{MA_CONF};
+ die ": $f is group/world readable/writeable\n" if 077 & ( stat _ )[2];
+ $Cf->file($f) or die;
}
- $Cf->getopt(\@ARGV) or die "Bad Usage. Try --help.\n";
+ $Cf->getopt( \@ARGV ) or die "Bad Usage. Try --help.\n";
die "Need ldap base.\n" if not $Cf->ldap_base;
- if ($Cf->ldap_admin !~ /\Q$Cf->ldap_base/) {
- $Cf->ldap_admin($Cf->ldap_admin . "," . $Cf->ldap_base);
+ if ( $Cf->ldap_admin !~ /\Q$Cf->ldap_base/ ) {
+ $Cf->ldap_admin( $Cf->ldap_admin . "," . $Cf->ldap_base );
}
- if ($Cf->help) {
- if (-t STDOUT and -x "/usr/bin/less") { open(X, "|less -FX") }
- else { open(X, ">&STDOUT"); }
- print X help();
- exit 0;
+ if ( $Cf->help ) {
+ if ( -t STDOUT and -x "/usr/bin/less" ) { open( X, "|less -FX" ) }
+ else { open( X, ">&STDOUT" ); }
+ print X help();
+ exit 0;
}
- @_ = grep { $_ =~ /^\Q$Module\E/ } qw/account alias shared group/;
+ @_ = grep { $_ =~ /^\Q$Module\E/ } qw/account acl alias shared group/;
die "Need module. Try --help\n" if @_ == 0;
die "Module ambigous. (@_)\n" if @_ > 1;
- if ($_[0] eq 'account') {
- require account;
- account::import($Cf);
- account::run();
- } elsif ($_[0] eq 'alias') {
- require alias;
- alias::import($Cf);
- alias::run();
- } elsif ($_[0] eq 'shared') {
- require shared;
- shared::import($Cf);
- shared::run();
- } elsif ($_[0] eq 'group') {
- require group;
- group::import($Cf);
- group::run();
+ if ( $_[0] eq 'account' ) {
+ require account;
+ account::import($Cf);
+ account::run();
+ } elsif ( $_[0] eq 'acl' ) {
+ require acl;
+ acl::import($Cf);
+ acl::run();
+ } elsif ( $_[0] eq 'alias' ) {
+ require alias;
+ alias::import($Cf);
+ alias::run();
+ } elsif ( $_[0] eq 'shared' ) {
+ die "Command '$_[0]' is currently not supported\n";
+ require shared;
+ shared::import($Cf);
+ shared::run();
+ } elsif ( $_[0] eq 'group' ) {
+ die "Command '$_[0]' is currently not supported\n";
+ require group;
+ group::import($Cf);
+ group::run();
} else {
- die "Shit";
+ die "Shit";
}
}
@@ -128,7 +143,7 @@
}
sub help() {
- ($_ = USAGE) =~ s/!(.*?)!/(eval $1) || ""/eg;
+ ( $_ = USAGE ) =~ s/!(.*?)!/(eval $1) || ""/eg;
return $_;
}