Jetzt kann man auch die Forwardings auf der Kommandozeile eintragen und muß nicht mit cms
authorheiko
Fri, 14 Jul 2006 14:32:38 +0000
branchcms
changeset 16 65695e59a6f9
parent 15 8e33564a0815
child 17 a4afc54e4b34
Jetzt kann man auch die Forwardings auf der Kommandozeile eintragen und muß nicht mit einem LDAP-Editor hantieren.
Makefile
account.pm
ma
ma.8.pod
--- a/Makefile	Tue Jul 04 21:52:14 2006 +0000
+++ b/Makefile	Fri Jul 14 14:32:38 2006 +0000
@@ -28,6 +28,7 @@
 .PHONY:	all install uninstall clean distclean dvi pdf
 
 all:	$(CHECKED) man
+	@test -x ma || chmod +x ma
 
 man:	$(MAN)
 
--- a/account.pm	Tue Jul 04 21:52:14 2006 +0000
+++ b/account.pm	Fri Jul 14 14:32:38 2006 +0000
@@ -90,6 +90,7 @@
     my $mailPrimaryAddress = $Cf->primary || $user;
     my $mailAddress = [$user, split /,/, $Cf->other || ""];
     my $mailGroup = [split /,/, $Cf->group || ""];
+    my $mailForwardingAddress = [split /,/, $Cf->forward || ""];
     my $pw = _mkpw($Cf->password || "{pwgen}");
 
 
@@ -133,6 +134,8 @@
 	$e->add((AT_PRIMARYADDRESS) => $mailPrimaryAddress);
 	$e->add(userPassword => $pw);
 	$e->add((AT_GROUP) => $mailGroup) if @$mailGroup;
+	$e->add((AT_FORWARDINGADDRESS) => $mailForwardingAddress) if @$mailForwardingAddress;
+
 	# $e->add(iusRestrictedMail => $Cf->internal) if $Cf->internal ne ":";
 
 	$e->exists("sn") or $e->add(sn => $sn);
@@ -240,6 +243,22 @@
 	    $modified++;
 	}
 
+	if (defined $Cf->forward) {
+	    my @f = split /,/, $Cf->forward;
+	    grep { /^[+-]/ } @f or $e->delete(AT_FORWARDINGADDRESS)
+		if $e->get_value(AT_FORWARDINGADDRESS);
+
+	    foreach my $f (@f) {
+		if ($f =~ s/^-//) {
+		    $e->delete((AT_FORWARDINGADDRESS) => [$f]);
+		} else {
+		    $f =~ s/^\+//;
+		    $e->add((AT_FORWARDINGADDRESS) => [$f]);
+		}
+	    }
+	    $modified++;
+	}
+
 	if (my $a = $Cf->primary) {
 	    $r = $ldap->search(base => $ubase, 
 		# filter => "(|(mailPrimaryAddress=$a)(mail=$a))");
@@ -355,6 +374,7 @@
 	my $mr = $e->get_value(AT_PRIMARYADDRESS) || "";	# ??
 	my $ml = join(", ", $e->get_value(AT_ADDRESS)) || "";	# ??
 	my $mg = join(", ", $e->get_value(AT_GROUP)) || "";	# ??
+	my $forw = join (", ", $e->get_value(AT_FORWARDINGADDRESS)) || "";
 	my $mbox = "user/$uid";
 
 	print "$uid: $cn <$mr>";
@@ -384,6 +404,7 @@
 	
 	print  wrap("\t", "\t\t", "Other Adresses: $ml\n") if $ml;
 	print wrap("\t", "\t\t", "Mail Groups: $mg\n") if $mg;
+	print wrap("\t", "\t\t", "Forwardings: $forw\n") if $forw;
 
     }
 }
--- a/ma	Tue Jul 04 21:52:14 2006 +0000
+++ b/ma	Fri Jul 14 14:32:38 2006 +0000
@@ -24,6 +24,8 @@
 		        (comma sep.)    [!$Cf->other!]
        --group:s	Mail Group(s) this account is member of
 			(comma sep.)	[!$Cf->group!]
+       --forward:s	Forwarding	[!$Cf->forward!]
+
        --fullname=s	Real Name	[!$Cf->fullname!]
        --password=s	Passwort	[!$Cf->password!]
 
@@ -52,9 +54,10 @@
 use Cyrus::IMAP::Admin;
 use AppConfig qw(:expand);
 use File::Basename;
+use FindBin;
 use Carp;
 
-use lib qw(. /usr/local/lib/ma);
+use lib ("$FindBin::RealBin/..", "$FindBin::RealBin/../lib/ma");
 use ldapBase;
 
 use constant ME => basename $0;
@@ -91,6 +94,7 @@
 
     other =>	    { ARGS => ":s" },
     group =>	    { ARGS => ":s" },
+    forward =>	    { ARGS => ":s" },
     fullname =>	    { ARGS => "=s", ALIAS => "realname" },
     address =>	    { ARGS => "=s", ALIAS => "primary" },
 
--- a/ma.8.pod	Tue Jul 04 21:52:14 2006 +0000
+++ b/ma.8.pod	Fri Jul 14 14:32:38 2006 +0000
@@ -103,6 +103,11 @@
 Es lassen sich Adressen hinzufügen und auch wieder löschen.  Die Syntax dazu entspricht der bei der 
 Gruppenzugehörigkeit.
 
+=item B<--forward>=I<Forwarding-Address>
+
+Eine Liste von Weiterleitungsadressen.  Es kann auch die Adresse des Nutzers selbst angegeben werden, dann wird
+halt eine Kopie weitergeleitet.  Die Syntax entspricht der der Gruppenzugehörigkeit.
+
 =item B<--password>=I<Passwort>
 
 Wenn beim Nutzeranlegen das Passwort nicht generiert werden soll, dann ist es hier anzugeben.