ma
branchcms
changeset 19 b55840a1ed97
parent 17 a4afc54e4b34
child 20 67e622468c67
equal deleted inserted replaced
18:e3710b49e8e4 19:b55840a1ed97
     3 # © 2005 Heiko Schlittermann <hs@schlittermann.de>
     3 # © 2005 Heiko Schlittermann <hs@schlittermann.de>
     4 # $URL$
     4 # $URL$
     5 # $Id$
     5 # $Id$
     6 #
     6 #
     7 use constant USAGE => <<'#';
     7 use constant USAGE => <<'#';
     8 Usage: !ME! account|alias --add|--list|--modify|--delete [options] [user|alias|shared mbox]
     8 Usage: !ME! account|alias|group --add|--list|--modify|--delete [options] [user|alias|shared mbox]
     9        * common options *
     9        * common options *
    10        --ldap_server=s	LDAP-Server	[!$Cf->ldap_server!]
    10        --ldap_server=s	LDAP-Server	[!$Cf->ldap_server!]
    11        --ldap_base=s	LDAP-Basis	[!$Cf->ldap_base!]
    11        --ldap_base=s	LDAP-Basis	[!$Cf->ldap_base!]
    12        --ldap_admin=s	LDAP BIND DN	[!$Cf->ldap_admin!]
    12        --ldap_admin=s	LDAP BIND DN	[!$Cf->ldap_admin!]
    13        --ldap_password=s		[!$Cf->ldap_password!]
    13        --ldap_password=s		[!$Cf->ldap_password!]
    59 
    59 
    60 use lib ("$FindBin::RealBin/..", "$FindBin::RealBin/../lib/ma");
    60 use lib ("$FindBin::RealBin/..", "$FindBin::RealBin/../lib/ma");
    61 use ldapBase;
    61 use ldapBase;
    62 
    62 
    63 use constant ME => basename $0;
    63 use constant ME => basename $0;
    64 use constant CONFIG => (
       
    65     { CASE => 1 },
       
    66     GLOBAL => { DEFAULT => undef },
       
    67 
       
    68     # * common *
       
    69     add =>	    { ARGS => "!",  ALIAS => [qw/new create/] },
       
    70     list =>	    { ARGS => "!",  ALIAS => "ls" },
       
    71     modify =>	    { ARGS => "!",  ALIAS => "change" },
       
    72     delete =>	    { ARGS => "!",  ALIAS => "remove" },
       
    73 
       
    74     ldap_base =>    { ARGS => "=s", DEFAULT => ldapBase(qw(/etc/openldap/ldap.conf /etc/ldap/ldap.conf)) },
       
    75     ldap_server =>  { ARGS => "=s", DEFAULT => "localhost" },
       
    76     ldap_bind_dn => { ARGS => "=s", DEFAULT => "cn=admin", ALIAS => "ldap_admin" },
       
    77     ldap_password =>{ ARGS => "=s" },
       
    78 
       
    79     help =>	    { ARGS => "!" },
       
    80     debug =>	    { ARGS => "!" },
       
    81 
       
    82     description =>  { ARGS => "=s" },
       
    83 
       
    84 
       
    85     # * account *
       
    86     imap_server =>  { ARGS => "=s", DEFAULT => "localhost" },
       
    87     imap_admin =>   { ARGS => "=s", DEFAULT => $ENV{USER} },
       
    88     imap_password =>{ ARGS => "=s" },
       
    89     imap_quota =>   { ARGS => "=i", DEFAULT => 300, ALIAS => "quota" },
       
    90 
       
    91     mbox =>	    { ARGS => "!",  DEFAULT => 1 },
       
    92     password =>	    { ARGS => "=s" },
       
    93 #   internal =>	    { ARGS => "!",  DEFAULT => ":", ALIAS => "restricted" },	    
       
    94 
       
    95     other =>	    { ARGS => ":s" },
       
    96     group =>	    { ARGS => ":s" },
       
    97     forward =>	    { ARGS => ":s" },
       
    98     fullname =>	    { ARGS => "=s", ALIAS => "realname" },
       
    99     address =>	    { ARGS => "=s", ALIAS => "primary" },
       
   100 
       
   101     # * alias * group *
       
   102     members =>	    { ARGS => ":s" },
       
   103 
       
   104     # * shared *
       
   105     #access =>	    { ARGS => ":s" },
       
   106 
       
   107     # * group *
       
   108     gid_min =>	    { ARGS => "=i", DEFAULT => 60000 },
       
   109     gid_max =>	    { ARGS => "=i", DEFAULT => 60100 },
       
   110 
       
   111     # * ldap intern *
       
   112     ldap_ou_aliases =>	    { ARGS => "=s", DEFAULT => "ou=MailAliases" },
       
   113     ldap_ou_accounts =>	    { ARGS => "=s", DEFAULT => "ou=MailAccounts" },
       
   114     ldap_ou_groups =>	    { ARGS => "=s", DEFAULT => "ou=Groups" },
       
   115 
       
   116     ldap_oc_alias =>	    { ARGS => "=s", DEFAULT => "XXXmailAlias" },
       
   117     ldap_oc_recipient =>    { ARGS => "=s", DEFAULT => "XXXmailRecipient" },
       
   118     ldap_oc_accessgroup =>  { ARGS => "=s", DEFAULT => "XXXmailAccessGroup" },
       
   119 
       
   120     ldap_at_address =>	    { ARGS => "=s", DEFAULT => "XXXmailAddress" },
       
   121     ldap_at_group =>	    { ARGS => "=s", DEFAULT => "XXXmailGroup" },
       
   122     ldap_at_forwardingaddress =>
       
   123 			    { ARGS => "=s", DEFAULT => "XXXmailForwardingAddress" },
       
   124     ldap_at_primaryaddress => 
       
   125 			    { ARGS => "=s", DEFAULT => "XXXmailPrimaryAddress" },
       
   126 
       
   127 );
       
   128 our $Cf;
    64 our $Cf;
   129 
    65 
   130 sub help();
    66 sub help();
   131 
    67 
   132 my $Module = shift if @ARGV && $ARGV[0] !~ /^-/;
    68 my $Module = shift if @ARGV && $ARGV[0] !~ /^-/;
   136 $SIG{__DIE__} = sub { die "\n".ME.": ", @_ };
    72 $SIG{__DIE__} = sub { die "\n".ME.": ", @_ };
   137 
    73 
   138 
    74 
   139 MAIN: {
    75 MAIN: {
   140 
    76 
   141     $Cf = new AppConfig CONFIG or die;
    77     $Cf = new AppConfig Common::CONFIG or die;
   142 
    78 
   143     if (exists $ENV{MA_CONF} and -f $ENV{MA_CONF}) {
    79     if (exists $ENV{MA_CONF} and -f $ENV{MA_CONF}) {
   144 	my $f = $ENV{MA_CONF};
    80 	my $f = $ENV{MA_CONF};
   145 	die ": $f is group/world readable/writeable\n" if  077 & (stat _)[2];
    81 	die ": $f is group/world readable/writeable\n" if  077 & (stat _)[2];
   146 	$Cf->file($f) or die;
    82 	$Cf->file($f) or die;