From 05d7924b1c44e85a379b3ff5cca7b512383df769 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Fri, 8 Jun 2012 08:07:07 +0200 Subject: Ensure that no cycle is created when add an alias. --- lib/Fripost/Commands/add_alias.pm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/Fripost/Commands') 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"; -- cgit v1.2.3