Code

Added more checks.
authorjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 25 Feb 2008 13:34:25 +0000 (13:34 +0000)
committerjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 25 Feb 2008 13:34:25 +0000 (13:34 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9105 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/server/events/siTriggered.pm

index 4cc8fdc25f2e9f653392b4e83b1ea9308092eb56..6d80ba94459925d65a30d7b29a58b512ffd8cf11 100644 (file)
@@ -162,7 +162,12 @@ sub detected_hardware {
                my $resolver=Net::DNS::Resolver->new;
                my $ipaddress= $1 if $address =~ /^([0-9\.]*?):.*$/;
                my $dnsresult= $resolver->search($ipaddress);
-               my $dnsname= (defined($dnsresult))?$dnsresult->{answer}[0]->{ptrdname}:$ipaddress;
+               my $dnsname= (
+                       defined($dnsresult) && 
+                       defined($dnsresult->{answer} &&
+                       defined($dnsresult->{answer}[0] &&
+                       defined($dnsresult->{answer}[0]->{ptrdname}
+               )?$dnsresult->{answer}[0]->{ptrdname}:$ipaddress;
                my $cn = (($dnsname =~ /^(\d){1,3}\.(\d){1,3}\.(\d){1,3}\.(\d){1,3}/) ? $dnsname : sprintf "%s", $dnsname =~ /([^\.]+)\.?/);
                my $dn = "cn=$cn,ou=incoming,$ldap_base";
                &main::daemon_log("INFO: Creating entry for $dn",5);