aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfripost-newalias12
-rwxr-xr-xfripost-searchalias8
-rw-r--r--lib/Fripost/Schema/Type/Alias.pm5
3 files changed, 17 insertions, 8 deletions
diff --git a/fripost-newalias b/fripost-newalias
index e00adcb..0ca009b 100755
--- a/fripost-newalias
+++ b/fripost-newalias
@@ -12,7 +12,7 @@ fripost-newalias - Add a new alias to the system
=head1 SYNOPSIS
B<fripost-newalias> [B<--verbose>] [B<--debug>] [B<--pretend>]
-[I<goto> [I<from>...]]
+[B<--force>] [I<goto> [I<from>...]]
=head1 DESCRIPTION
@@ -32,6 +32,11 @@ B<fripost-newalias> raises an error.
Only simulates the insertion. (But still query the LDAP server to ensure
that the virtual domains of aliases are know, for example.)
+=item B<--force>
+
+Force creating the creation, even if I<from> is already an alias. Also,
+disable the sending of the confirmation.
+
=item B<--server_host=>I<host>
The LDAP URI to connect to.
@@ -127,6 +132,7 @@ GetOptions(
'bind_dn=s' => \$conf->{bind_dn},
'bind_pw=s' => \$conf->{bind_pw},
'pretend' => \$conf->{pretend},
+ 'force' => \$conf->{force},
'debug' => \$conf->{debug},
'v|verbose' => \$conf->{verbose},
'man' => sub { pod2usage(-exitstatus => 0,
@@ -178,7 +184,7 @@ confirm_or_abort();
## Insert alias into database
for my $addr (@addr) {
my $rs = $ldap->alias->search({ address => $addr });
- if (!$rs->count) {
+ if (!$rs->count or defined $conf->{force}) {
if (!$ldap->user->search({ username => $addr })->count) {
if (!$conf->{pretend}) {
$ldap->alias->add({ address => $addr, goto => $goto,
@@ -218,7 +224,7 @@ my $msg = MIME::Lite->new(
Encoding => 'quoted-printable',
);
-{
+unless (defined $conf->{force}) {
my ($vars, $data);
$vars = {
addrs => \@addr,
diff --git a/fripost-searchalias b/fripost-searchalias
index 2e5d35f..1c674fe 100755
--- a/fripost-searchalias
+++ b/fripost-searchalias
@@ -17,8 +17,8 @@ B<fripost-searchalias> [B<--debug>] [I<goto> [I<from>]]
B<fripost-seardomain> list virtual aliases matching exactly I<from>,
targetting to I<goto>.
-Wildcards I<*> can appear in I<goto> or I<from>, to match zero or more
-characters.
+Wildcards I<*> can appear in the login part of I<from>, to match zero
+or more characters.
If no I<from> is given, list all aliases whose target matches I<goto>.
If neither I<goto> nor I<from> are given, B<fripost-searchalias> list
all existing virtual aliases.
@@ -115,8 +115,8 @@ GetOptions(
my $ldap = Fripost::Schema->new( $conf );
my %alias;
-$alias{goto} = $ARGV[0] if defined $ARGV[0];
-$alias{address} = $ARGV[1] if defined $ARGV[1];
+$alias{goto} = $ARGV[0] if (defined $ARGV[0]) and $ARGV[0] ne '';
+$alias{address} = $ARGV[1] if (defined $ARGV[1]) and $ARGV[1] ne '';
if (defined $alias{address}) {
my ($u,$d) = split /\@/, $alias{address}, 2;
diff --git a/lib/Fripost/Schema/Type/Alias.pm b/lib/Fripost/Schema/Type/Alias.pm
index 8c0b25e..dee2fbc 100644
--- a/lib/Fripost/Schema/Type/Alias.pm
+++ b/lib/Fripost/Schema/Type/Alias.pm
@@ -21,7 +21,10 @@ sub search {
my ($username, $domain);
($username, $domain) = split /\@/, $alias->{address}, 2
if defined $alias->{address};
- $domain = $username if (defined $username) and not (defined $domain);
+ if ((defined $username) and not (defined $domain)) {
+ $domain = $username;
+ undef $username;
+ }
my $base = $self->{_options}->{base_dn};
$base = join ',', ( 'dc='.$domain, $base )