From: janw Date: Thu, 3 Jul 2008 09:01:18 +0000 (+0000) Subject: Don't add myself to known_server. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c9770bee39e61ea9536e39867d7e6b48fca2d39a;p=gosa.git Don't add myself to known_server. closes #477 git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11519 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 4c4df6b60..a73ca11c6 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -2984,11 +2984,8 @@ daemon_log("0 INFO: found foreign server in config file and DNS: $all_foreign_se my $act_timestamp = &get_time(); foreach my $foreign_server (@foreign_server_list) { - ####################################### - # TODO for jan # do not add myself to known_server_db - # work around!!! - if ($foreign_server eq '10.89.1.31:20081') { next; } + if (&is_local($foreign_server)) { next; } ###################################### my $res = $known_server_db->add_dbentry( {table=>$known_server_tn, diff --git a/gosa-si/modules/GosaSupportDaemon.pm b/gosa-si/modules/GosaSupportDaemon.pm index e5da00754..21db30a59 100644 --- a/gosa-si/modules/GosaSupportDaemon.pm +++ b/gosa-si/modules/GosaSupportDaemon.pm @@ -26,7 +26,8 @@ my @functions = ( "get_ip", "get_interface_for_ip", "get_interfaces", - "run_as", + "is_local", + "run_as", ); @EXPORT = @functions; use strict; @@ -620,6 +621,32 @@ sub get_interfaces { } +#=== FUNCTION ================================================================ +# NAME: is_local +# PARAMETERS: Server Address +# RETURNS: true if Server Address is on this host, false otherwise +# DESCRIPTION: Checks all interface addresses, stops on first match +#=============================================================================== +sub is_local { + my $server_address = shift || ""; + my $result = 0; + + my $server_ip = $1 if $server_address =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):\d{1,6}$/; + + if(defined($server_ip) && length($server_ip) > 0) { + foreach my $interface(&get_interfaces()) { + my $ip_address= &get_ip($interface); + if($ip_address eq $server_ip) { + $result = 1; + last; + } + } + } + + return $result; +} + + #=== FUNCTION ================================================================ # NAME: run_as # PARAMETERS: uid, command