summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dc60179)
raw | patch | inline | side by side (parent: dc60179)
author | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 11 Feb 2008 10:37:52 +0000 (10:37 +0000) | ||
committer | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 11 Feb 2008 10:37:52 +0000 (10:37 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8821 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-bus | patch | blob | history |
diff --git a/gosa-si/gosa-si-bus b/gosa-si/gosa-si-bus
index b7711101e7802233739f69454bc27cb8b542aa01..f920f5a5be4a1a63f59d5981670900bc9ca725c2 100755 (executable)
--- a/gosa-si/gosa-si-bus
+++ b/gosa-si/gosa-si-bus
return $result;
}
+sub bus_matches {
+ my $target = shift;
+ my $target_ip = sprintf("%s", $target =~ /^([0-9\.]*?):.*$/);
+ my $result = 0;
+
+ if($bus_ip eq $target_ip) {
+ $result= 1;
+ } elsif ($bus_ip eq "0.0.0.0") {
+ if ($target_ip eq "127.0.0.1") {
+ $result= 1;
+ } else {
+ my $PROC_NET_ROUTE= ('/proc/net/route');
+
+ open(PROC_NET_ROUTE, "<$PROC_NET_ROUTE")
+ or die "Could not open $PROC_NET_ROUTE";
+
+ my @ifs = <PROC_NET_ROUTE>;
+
+ close(PROC_NET_ROUTE);
+
+ # Eat header line
+ shift @ifs;
+ chomp @ifs;
+ foreach my $line(@ifs) {
+ my ($Iface,$Destination,$Gateway,$Flags,$RefCnt,$Use,$Metric,$Mask,$MTU,$Window,$IRTT)=split(/\s/, $line);
+ my $destination;
+ my $mask;
+ my ($d,$c,$b,$a)=unpack('a2 a2 a2 a2', $Destination);
+ $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($target_ip)->within(new NetAddr::IP($destination, $mask))) {
+ # destination matches route, save mac and exit
+ $result= 1;
+ last;
+ }
+ }
+ }
+ } else {
+ &main::daemon_log("Target ip $target_ip does not match bus ip $bus_ip",1);
+ }
+
+ return $result;
+}
#=== FUNCTION ================================================================
# NAME: create_passwd
my $target_string = join(",", @target_l);
daemon_log("got msg '$header' with target '$target_string' from ".$heap->{'remote_ip'}, 3);
- if( 1 == length(@target_l) && $target_l[0] eq $bus_address ) {
+ if( 1 == length(@target_l) && &bus_matches($target_l[0]) ) {
# msg is for bus
#print STDERR "msg is for bus\n";
$kernel->post('gosa_si_bus_session', $header, $msg, $msg_hash);