summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fab46c8)
raw | patch | inline | side by side (parent: fab46c8)
author | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 30 Jan 2008 11:39:05 +0000 (11:39 +0000) | ||
committer | janw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 30 Jan 2008 11:39:05 +0000 (11:39 +0000) |
Capture Device gets saved in ArpHandler hosts_database.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8658 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8658 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server | patch | blob | history | |
gosa-si/modules/ArpHandler.pm | patch | blob | history |
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 4f298ee037090503f58969c258015af484f8a1b7..515fe6ef25f90d093f34331d1b4c4dacac2d130c 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
next;
}
- if( $no_arp > 0 ) {
- if( $file =~ /ArpHandler.pm/ ) {
- next;
- }
- }
+ if( $no_arp > 0 ) {
+ if( $file =~ /ArpHandler.pm/ ) {
+ next;
+ }
+ }
eval { require $file; };
if ($@) {
daemon_log("ERROR: gosa-si-server could not load module $file", 1);
daemon_log("$@", 5);
- } else {
- my $mod_name = $1;
- my $info = eval($mod_name.'::get_module_info()');
- my ($input_address, $input_key, $input, $input_active, $input_type) = @{$info};
- $known_modules->{$mod_name} = $info;
-
- daemon_log("module $mod_name loaded", 1);
- }
+ } else {
+ my $mod_name = $1;
+ my $info = eval($mod_name.'::get_module_info()');
+
+ # Only load module if get_module_info() returns a non-null object
+ if(defined($info)) {
+ my ($input_address, $input_key, $input, $input_active, $input_type) = @{$info};
+ $known_modules->{$mod_name} = $info;
+ daemon_log("module $mod_name loaded", 1);
+ }
+ }
}
# for debugging
index d0cba19248af5299726fe1c84db42776841d8d71..d4e70eaff59c7ef21ac837a88c822d42d8880e70 100644 (file)
my $resolver=Net::DNS::Resolver->new;
$ldap_base = "dc=gonicus,dc=de" ;
-$interface = "all";
+$interface = "eth1";
sub get_module_info {
my @info = (undef,
}
# If device has a valid mac address
+ # TODO: Check if this should be the right way
if(not(&get_mac($device) eq "00:00:00:00:00:00")) {
&main::daemon_log("Starting ArpWatch on $device", 1);
POE::Session->create(
}
sub got_packet {
- my $packet = $_[ARG0];
+ my ($kernel, $heap, $sender, $packet) = @_[KERNEL, HEAP, SENDER, ARG0];
if( $packet->{source_haddr} eq "00:00:00:00:00:00" ||
$packet->{source_haddr} eq "ff:ff:ff:ff:ff:ff" ||
$packet->{source_ipaddr} eq "0.0.0.0") {
return;
}
+
+ my $capture_device = sprintf "%s", $kernel->alias_list($sender) =~ /^arp_watch_(.*)$/;
if(!exists($hosts_database->{$packet->{source_haddr}})) {
my $dnsresult= $resolver->search($packet->{source_ipaddr});
": ".$hosts_database->{$packet->{source_haddr}}->{ipHostNumber}.
"/".$hosts_database->{$packet->{source_haddr}}->{macAddress},4);
}
+ $hosts_database->{$packet->{source_haddr}}->{device}= $capture_device;
} else {
if(!($hosts_database->{$packet->{source_haddr}}->{ipHostNumber} eq $packet->{source_ipaddr})) {
&main::daemon_log(
"->".$packet->{source_ipaddr}, 4);
$hosts_database->{$packet->{source_haddr}}->{ipHostNumber}= $packet->{source_ipaddr};
}
- &main::daemon_log("Host already in cache (".($hosts_database->{$packet->{source_haddr}}->{dnsname}).")",6);
+ &main::daemon_log("Host already in cache (".($hosts_database->{$packet->{source_haddr}}->{device})."->".($hosts_database->{$packet->{source_haddr}}->{dnsname}).")",6);
}
}
"(|(macAddress=$mac)(dhcpHWAddress=ethernet $mac))"
);
- if($ldap_result->count==1) {
+ if(defined($ldap_result) && $ldap_result->count==1) {
if(exists($ldap_result->{entries}[0]) &&
exists($ldap_result->{entries}[0]->{asn}->{objectName}) &&
exists($ldap_result->{entries}[0]->{asn}->{attributes})) {
# SEE ALSO: n/a
#===============================================================================
sub search_ldap_entry {
- my ($ldap_tree, $sub_tree, $search_string) = @_;
- my $msg = $ldap_tree->search( # perform a search
- base => $sub_tree,
- filter => $search_string,
- ) or daemon_log("cannot perform search at ldap: $@", 1);
+ my ($ldap_tree, $sub_tree, $search_string) = @_;
+ my $msg;
+ if(defined($ldap_tree)) {
+ my $msg = $ldap_tree->search( # perform a search
+ base => $sub_tree,
+ filter => $search_string,
+ ) or daemon_log("cannot perform search at ldap: $@", 1);
# if(defined $msg) {
# print $sub_tree."\t".$search_string."\t";
# print $msg->count."\n";
# foreach my $entry ($msg->entries) { $entry->dump; };
# }
-
- return $msg;
+ }
+ return $msg;
}