aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Fripost/Commands
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@fripost.org>2012-06-08 08:07:07 +0200
committerGuilhem Moulin <guilhem.moulin@fripost.org>2012-06-08 08:07:07 +0200
commit05d7924b1c44e85a379b3ff5cca7b512383df769 (patch)
tree7b480cb29372e94034bed1da91099f146aaeeded /lib/Fripost/Commands
parent93d4b1701fbef7e2173324e27adc751062ca360f (diff)
Ensure that no cycle is created when add an alias.
Diffstat (limited to 'lib/Fripost/Commands')
-rw-r--r--lib/Fripost/Commands/add_alias.pm5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Fripost/Commands/add_alias.pm b/lib/Fripost/Commands/add_alias.pm
index 7155368..8581a9f 100644
--- a/lib/Fripost/Commands/add_alias.pm
+++ b/lib/Fripost/Commands/add_alias.pm
@@ -19,6 +19,7 @@ use IO::Prompter;
use Fripost::Prompt;
use Fripost::Schema;
use Fripost::Email;
+use Fripost::Tests;
our $VERSION = '0.01';
@@ -32,6 +33,10 @@ sub main {
my @addr = @_;
@addr || push @addr, (split /, */, prompt "Alias from address(es): ");
+ my $graph = build_alias_graph ($ldap->alias->search()->entries);
+ my @path = search_path ($graph, $goto, $addr[0]);
+ die "Error: Cannot create cycle " . join (' -> ', @path) . ' -> ' . $goto . "\n"
+ if @path;
# Show goto adress
say "Goto adress: $goto";