diff --git a/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc b/gosa-plugins/dns/admin/systems/services/dns/class_DNS.inc
index 77585838019f2ede80288aef58cd79f052614ede..61e492c9ab8f4377cba91b5aa7c1e5ed11a44810 100644 (file)
'a6Record' => "a6Record",
'dSRecord' => "dSRecord",
'sSHFPRecord' => "sSHFPRecord",
- 'sOARecord' => "sOARecord",
'rRSIGRecord' => "rRSIGRecord",
'nSECRecord' => "nSECRecord");
/* All available record types */
/* This fucntion is used to flip the ip address, for example
12.3.45 -> 45.3.12
- Because some entries (like zones) are store like that 45.3.12.in-addr.arpa
+ Because some entries (like zones) are store like that 45.3.12.in-addr.arpa.
but we want to display 12.3.45.
*/
static function FlipIp($ip)
{
- $tmp = array_reverse(split("\.",$ip));
+ $tmp = array_reverse(explode(".",$ip));
$new = "";
foreach($tmp as $section){
$new .= $section.".";
/* Generate SOA entry
*/
if(isset($attrs['sOARecord'][0])){
- $tmp = split("\ ",$attrs['sOARecord'][0]) ;
+ $tmp = explode(" ",$attrs['sOARecord'][0]) ;
$tmp2 = array();
/* Assign soa vars */
/* Skip some attributes
*/
- if(in_array($name,$SkipRecords)) continue;
+ if(in_array_strict($name,$SkipRecords)) continue;
/* If there is a record attribute
*/
unset($Zones[$zoneName]);
}else{
$tmp = $ldap->fetch();
- $Zones[$zoneName]['ReverseZone'] = DNS::FlipIp(str_replace(".in-addr.arpa","",$tmp['zoneName'][0]));
- $Zones[$zoneName]['InitialReverseZone'] = DNS::FlipIp(str_replace(".in-addr.arpa","",$tmp['zoneName'][0]));
+ $Zones[$zoneName]['ReverseZone'] = DNS::FlipIp(str_replace(".in-addr.arpa.","",$tmp['zoneName'][0]));
+ $Zones[$zoneName]['InitialReverseZone'] = DNS::FlipIp(str_replace(".in-addr.arpa.","",$tmp['zoneName'][0]));
}
}
return($Zones);
if(!empty($zone['InitialReverseZone'])){
if($zone['InitialReverseZone'] != $zone['ReverseZone']){
$base = "zoneName=".$zone['zoneName'].",".$HostDn;
- $oldRDn = "zoneName=". DNS::FlipIp($zone['InitialReverseZone']).".in-addr.arpa,".$base;
- $newRDn = "zoneName=". DNS::FlipIp($zone['ReverseZone']).".in-addr.arpa,".$base;
- $PrePareZoneEntries[DNS::FlipIp($zone['InitialReverseZone']).".in-addr.arpa"] = DNS::FlipIp($zone['ReverseZone']).".in-addr.arpa";
+ $oldRDn = "zoneName=". DNS::FlipIp($zone['InitialReverseZone']).".in-addr.arpa.,".$base;
+ $newRDn = "zoneName=". DNS::FlipIp($zone['ReverseZone']).".in-addr.arpa.,".$base;
+ $PrePareZoneEntries[DNS::FlipIp($zone['InitialReverseZone']).".in-addr.arpa."] = DNS::FlipIp($zone['ReverseZone']).".in-addr.arpa.";
$move [$oldRDn] = $newRDn;
}
}
/* Create Reverse Entry
* And append it to our add queue
*/
- $zone['ReverseZone'] = DNS::FlipIp($zone['ReverseZone']).".in-addr.arpa";
+ $zone['ReverseZone'] = DNS::FlipIp($zone['ReverseZone']).".in-addr.arpa.";
$base = "zoneName=".$zone['zoneName'].",".$HostDn;
$newRDn = "zoneName=".$zone['ReverseZone'].",".$base;
$rObj = $obj;
$zones = DNS::getAvailableZones($config);
$zonesArr = array();
foreach($zones as $zoneMix){
- $zoneIndex = split("/",$zoneMix);
+ $zoneIndex = explode("/",$zoneMix);
if(!array_key_exists($zoneIndex[0],$zonesArr)) {
$zonesArr[$zoneIndex[0]] = array();
}
* Or overwritten and filled with new values.
*/
foreach($newRecords as $name => $def){
- if(!in_array($name,$specialAttributes)){
+ if(!in_array_strict($name,$specialAttributes)){
$add[$stdDn][$name] = $def;
}
}
/* Delete all OLD special attributes.
*/
foreach($oldEntry['RECORDS'] as $id => $rec){
- if(in_array($rec['type'],$specialAttributes)){
+ if(in_array_strict($rec['type'],$specialAttributes)){
$deldn= "relativeDomainName=".$rec['value'].",".$baseDn;
$del[$deldn] = "";
}
static function getNameFromMix($zoneMix){
$ret = "";
if(!strstr($zoneMix, '/')) return($ret);
- $zoneIndex = split("/",$zoneMix);
+ $zoneIndex = explode("/",$zoneMix);
return($zoneIndex[1]);
}
return($ret);
}
- $zoneNameIndex = split("/",$zoneNameMix);
+ $zoneNameIndex = explode("/",$zoneNameMix);
$zoneName = $zoneNameIndex[1];
$nameServer = strtolower($zoneNameIndex[0]);
$ldap = $config->get_ldap_link();
$config->current['BASE'],array("zoneName"),GL_NO_ACL_CHECK | GL_SUBSEARCH);
foreach($tmp as $at){
- if(preg_match("/\.in\-addr\.arpa/",$at['zoneName'][0])){
+ if(preg_match("/\.in\-addr\.arpa\./",$at['zoneName'][0])){
$ReverseZones[$at['dn']] = $at;
}else{
$ForwardZones[$at['dn']] = $at;
}
return($runtime_cache['DNS']['getAvailableZones']);
}
+
+
+ static function touchDNSZone($config,$zoneName)
+ {
+ if(empty($zoneName)){
+ return null;
+ }
+
+ preg_match('@(?<server>[^/]*)/(?<name>.*)@',$zoneName,$matches);
+ $name = $matches['name'];
+ $server = strtolower($matches['server']);
+
+ // Search for the zone entry and its reverse entry.
+ $ldap = $config->get_ldap_link();
+ $ldap-> cd($config->current['BASE']);
+ $ldap->search("(&(objectClass=dNSZone)(zoneName=$name)(sOARecord=*))",array("sOARecord"));
+ if($ldap->count() != 1){
+ trigger_error("Invalid Zone ".$zoneName);
+ }else{
+ $to_update= array();
+ $forward = $ldap->fetch();
+ $to_update[$forward['dn']] = $forward;
+ $ldap->cd($forward['dn']);
+ $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@)(sOARecord=*))",array("sOARecord"));
+
+ // We may have multiple reverse zones later.
+ while($attrs = $ldap->fetch()){
+ $to_update[$attrs['dn']] = $attrs;
+ }
+
+ // Increase the sAONumber for each zone
+ foreach($to_update as $zone){
+ $tmp = explode(' ',$zone['sOARecord'][0]);
+ $sOA = $tmp[2];
+ $sOAdate = substr($sOA,0,8);
+ $sOAnumber = substr($sOA,-2);
+ $date = date('Ymd');
+ $number = '01';
+ if($sOAdate < $date){
+ $sOA = $date.$number;
+ } else {
+ $number = sprintf("%02d", $sOAnumber+1);
+ $sOA = $sOAdate.$number;
+ }
+ $tmp[2] = $sOA;
+ $zone['sOARecord'][0] = implode(' ', $tmp);
+ $attrs = array('sOARecord' => $zone['sOARecord'][0]);
+ $ldap = $config->get_ldap_link();
+ $ldap->cd($zone['dn']);
+ $ldap->modify($attrs);
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_DEL, get_class()));
+ }
+ }
+ }
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>