Code

Should not map STD* if foreground.
[gosa.git] / gosa-si / gosa-si-client
index 2ee9b4d0d87eb3fd83f3c992ac571238feae9a6e..544030cdbdd2a0786cbf940193d951ffe6ff9817 100755 (executable)
@@ -35,7 +35,7 @@ use Data::Dumper;
 use Sys::Syslog qw( :DEFAULT setlogsock);
 use File::Spec;
 use Cwd;
-use NetAddr::IP::Lite;
+use NetAddr::IP;
 use GOSA::GosaSupportDaemon;
 
 
@@ -285,7 +285,7 @@ sub get_mac {
 
                         # A configured MAC Address should always override a guessed value
                         if ($client_mac_address and length($client_mac_address) > 0) {
-                                return $client_mac_address;
+                                $result= $client_mac_address;
                         }
 
                         socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
@@ -363,7 +363,7 @@ sub get_local_mac_for_remote_ip {
                $destination= sprintf("%d.%d.%d.%d", hex($a), hex($b), hex($c), hex($d));
                ($d,$c,$b,$a)=unpack('a2 a2 a2 a2', $Mask);
                $mask= sprintf("%d.%d.%d.%d", hex($a), hex($b), hex($c), hex($d));
-               if(new NetAddr::IP::Lite($server_ip)->within(new NetAddr::IP::Lite($destination, $mask))) {
+               if(new NetAddr::IP($server_ip)->within(new NetAddr::IP($destination, $mask))) {
                        # destination matches route, save mac and exit
                        $result= &get_mac($Iface);
                        last;
@@ -1254,10 +1254,11 @@ GetOptions("h|help" => \&usage,
 &read_configfile;
 &check_pid;
 
-
-open STDIN, ‘/dev/null’ or die “Can’t read /dev/null: $!”;
-open STDOUT, ‘>>/dev/null’ or die “Can’t write to /dev/null: $!”;
-open STDERR, ‘>>/dev/null’ or die “Can’t write to /dev/null: $!”;
+if ( ! $foreground ) {
+       open STDIN, '/dev/null' or die "Can’t read /dev/null: $!";
+       open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!";
+       open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!";
+}
 
 
 # restart daemon log file