From: hickert Date: Tue, 14 Nov 2006 07:18:32 +0000 (+0000) Subject: Added patch from revision 5285 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1970a9bf457e6088de84e2768c5e94d3e553038c;p=gosa.git Added patch from revision 5285 git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5100 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/functions_dns.inc b/include/functions_dns.inc index 1eeba0c35..162caeca7 100644 --- a/include/functions_dns.inc +++ b/include/functions_dns.inc @@ -349,18 +349,25 @@ function getDNSHostEntries($config,$name,$silent = false) */ $foundIn = array(); $zones = getAvailableZones($config); - foreach($zones as $zone){ - $zoneDn = getDNSZoneDN($config,$zone); - $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=".$name.")(!(relativeDomainName=@)))", $zoneDn,$attrs = array("*")); - while($attrs = $ldap->fetch()){ - $foundIn [] = $attrs['dn']; - } + + $zonesArr = array(); + foreach($zones as $zoneMix){ + $zoneIndex = split("/",$zoneMix); + if(!array_key_exists($zoneIndex[0],$zonesArr)) $zonesArr[$zoneIndex[0]] = array(); + array_push($zonesArr[$zoneIndex[0]],$zoneIndex[1]); } - - /* Alert if there is more than one zone with an entry named like $name - */ - if((count($foundIn) > 1) && (!$silent)) { - print_red(sprintf(_("Found more than one dns zone which contains an entry named '%s'. Aborting getting dns informations for this device."),$name)); + + foreach($zonesArr as $nameServer => $nameServerArr){ + $foundInTmp = array(); + foreach($nameServerArr as $zoneArr => $zone){ + $zoneMix = $nameServer."/".$zone; + $zoneDn = getDNSZoneDN($config,$zoneMix); + $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=".$name.")(!(relativeDomainName=@)))", $zoneDn,$attrs = array("*")); + while($attrs = $ldap->fetch()){ + $foundInTmp [] = $attrs['dn']; + $foundIn [] = $attrs['dn']; + } + } } /* No zone found which contains an entry for us @@ -426,16 +433,17 @@ function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName) $zones = getAvailableZones($config); $specialAttributes = array("cNAMERecord","pTRRecord"); $newRecords = array(); // Used to remember which records are removed - $zoneName = $newEntry['zoneName']; - $zoneDn = getDNSZoneDN($config,$zoneName); + $zoneNameMix = $newEntry['zoneName']; + $zoneDn = getDNSZoneDN($config,$zoneNameMix); $tmp = array_flip($zones); + $zoneName = getNameFromMix($zoneNameMix); /* If reverseZone can't be resolved ... this * can't be a valid entry, so remove this account */ - if(isset($tmp[$zoneName])){ - $reverseName = $tmp[$zoneName]; - $reverseDn = getDNSZoneDN($config,$reverseName); + if(isset($tmp[$zoneNameMix])){ + $reverseNameMix = $tmp[$zoneNameMix]; + $reverseDn = getDNSZoneDN($config,$reverseNameMix); if(empty($reverseDn)){ $newEntry['exists'] = false; } @@ -467,7 +475,7 @@ function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName) /* Check if zoneName has changed */ if(count($newEntry['RECORDS'])){ - if($oldEntry['zoneName'] != $newEntry['zoneName']){ + if($oldEntry['zoneName'] != $zoneName){ $oldzoneDn = getDNSZoneDN($config,$oldEntry['zoneName']); $dn = "relativeDomainName=".$oldName.",".$oldzoneDn; $dn2= "relativeDomainName=".$oldName.",".$zoneDn; @@ -553,17 +561,18 @@ function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName) if($rec['type'] == "pTRRecord"){ $PTRdn= "relativeDomainName=".$rec['value'].",".$baseDn; $ptrObj = $baseObj; + $reverseName = getNameFromMix($reverseNameMix); $ptrObj['zoneName'] = $reverseName; - $ptrObj['pTRRecord'] = $newName.".".$zoneName; + $ptrObj['pTRRecord'] = $newName.".".$zoneName."."; $ptrObj['relativeDomainName'] = $rec['value']; - + $add[$PTRdn] = $ptrObj; }else if($rec['type'] == "cNAMERecord"){ $PTRdn= "relativeDomainName=".$rec['value'].",".$baseDn; $ptrObj = $baseObj; - $ptrObj['zoneName'] = $reverseName; - $ptrObj['cNAMERecord'] = $newName.".".$zoneName; + $ptrObj['zoneName'] = $zoneName; + $ptrObj['cNAMERecord'] = $newName; $ptrObj['relativeDomainName'] = $rec['value']; $add[$PTRdn] = $ptrObj; @@ -578,18 +587,37 @@ function getDNSHostEntriesDiff($config,$oldName,$newEntry,$newName) return($ret); } +function getNameFromMix($zoneMix){ + $ret = ""; + if(!strstr($zoneMix, '/')) return($ret); + $zoneIndex = split("/",$zoneMix); + return($zoneIndex[1]); +} /* returns the dn for a specified zone */ -function getDNSZoneDN($config,$zoneName){ +function getDNSZoneDN($config,$zoneNameMix){ $ret = ""; + if(!strstr($zoneNameMix, '/')) return($ret); + $zoneNameIndex = split("/",$zoneNameMix); + $zoneName = $zoneNameIndex[1]; + $nameServer = strtolower($zoneNameIndex[0]); $ldap = $config->get_ldap_link(); + + /* search for the nameserver */ $ldap-> cd($config->current['BASE']); + $ldap->search("(&(objectClass=goServer)(cn=".$nameServer."))",array("cn")); + if($ldap->count()){ + $attr = $ldap->fetch(); + } else return($ret); + + $ldap-> cd($attr['dn']); $ldap->search("(&(objectClass=dNSZone)(sOARecord=*)(zoneName=".$zoneName."))",array("zoneName")); if($ldap->count()){ $attr = $ldap->fetch(); return($attr['dn']); } + return($ret); } @@ -625,9 +653,10 @@ function getAvailableZones($config) */ foreach($ReverseZones as $Rdn => $Robj ){ if(preg_match("/".$dn."/",$Rdn)){ - $zones[$Robj['zoneName'][0]] = $obj['zoneName'][0]; + $zones[strtoupper($ldap->getCn($dn))."/".$Robj['zoneName'][0]] = + strtoupper($ldap->getCn($dn))."/".$obj['zoneName'][0]; } - } + } } return($zones); } diff --git a/plugins/admin/systems/class_servDNSeditZone.inc b/plugins/admin/systems/class_servDNSeditZone.inc index 7fcef3aa0..4d499e951 100644 --- a/plugins/admin/systems/class_servDNSeditZone.inc +++ b/plugins/admin/systems/class_servDNSeditZone.inc @@ -347,12 +347,12 @@ class servdnseditZone extends plugin /* Check if zoneName is already in use */ $usedZones = $this->getUsedZoneNames(); if(($this->isNew == true)||($this->zoneName != $this->InitialzoneName)||($this->ReverseZone != $this->InitialReverseZone)){ - if((isset($usedZones[$this->zoneName]))&&($this->zoneName != $this->InitialzoneName)){ + /* if((isset($usedZones[$this->zoneName]))&&($this->zoneName != $this->InitialzoneName)){ $message[] =_("This zoneName is already in use"); } if((in_array($this->ReverseZone,$usedZones))&&($this->ReverseZone != $this->InitialReverseZone)){ $message[] =_("This reverse zone is already in use"); - } + }*/ } if(empty($this->zoneName)){ diff --git a/plugins/admin/systems/class_termDNS.inc b/plugins/admin/systems/class_termDNS.inc index 70d38e0d6..5dfc415cf 100644 --- a/plugins/admin/systems/class_termDNS.inc +++ b/plugins/admin/systems/class_termDNS.inc @@ -337,7 +337,7 @@ class termDNS extends plugin $checkArray = array(); $onlyOnce = array(); - $onlyOnce['cNAMERecord'] = 0; + // $onlyOnce['cNAMERecord'] = 0; /* Walk through all entries and detect duplicates or mismatches */