X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Fsystems%2Fadmin%2Fsystems%2Fclass_termDNS.inc;h=c3806820105ab012dc51e1928edf2d20c0de74eb;hb=e9d5e9913de62425bb7dfd4d993fbcd8ac609aa4;hp=410b34b3d4fafa40ac0275acc4ac9f480e706278;hpb=6a4b2a32dd6c06f040fbc24fc762363984ca531e;p=gosa.git diff --git a/gosa-plugins/systems/admin/systems/class_termDNS.inc b/gosa-plugins/systems/admin/systems/class_termDNS.inc index 410b34b3d..c38068201 100644 --- a/gosa-plugins/systems/admin/systems/class_termDNS.inc +++ b/gosa-plugins/systems/admin/systems/class_termDNS.inc @@ -79,7 +79,9 @@ class termDNS extends plugin $this->IPisMust = $IPisMust; $this->namingAttr = $namingAttr; - plugin::plugin ($config, $parent->dn); + plugin::plugin ($config, $parent->dn, $this->parent); + + $this->attrs = &$this->parent->attrs; if(isset($this->attrs[$namingAttr][0])){ $this->OrigCn = preg_replace("/\\\$\$/","",$this->attrs[$namingAttr][0]); @@ -154,9 +156,10 @@ class termDNS extends plugin */ $this->dnsEntry = DNS::getDNSHostEntries($config,$this->OrigCn); + $ptr = DNS::FlipIp($this->get_pTRRecord()); + /* Remove A record which equals $this->ipHostNumber */ - $ptr = $this->get_pTRRecord(); foreach($this->dnsEntry['RECORDS'] as $key => $rec){ if(($rec['type'] == "aRecord") && ($rec['value'] == $this->ipHostNumber)){ unset($this->dnsEntry['RECORDS'][$key]); @@ -233,7 +236,7 @@ class termDNS extends plugin function netmaskIsCoherent($idZone) { - $netmask = DNS::FlipIp(str_replace(".in-addr.arpa","",DNS::getNameFromMix($idZone))); + $netmask = DNS::FlipIp(str_replace(".in-addr.arpa.","",DNS::getNameFromMix($idZone))); if(!strstr($this->ipHostNumber, $netmask)){ return false; }else{ @@ -256,7 +259,7 @@ class termDNS extends plugin { /* Call parent execute */ $smarty= get_smarty(); - $smarty->assign("autonetACL",$this->acl_is_writeable("macAddress").$this->acl_is_writeable("ipHostNumber")); + $smarty->assign("autonetACL",$this->acl_is_writeable("macAddress") && $this->acl_is_writeable("ipHostNumber")?"rw":""); $tmp = $this->plInfo(); foreach($tmp['plProvidedAcls'] as $name => $translation){ @@ -390,7 +393,7 @@ class termDNS extends plugin if(isset($_POST['propose_ip']) && $this->acl_is_writeable("ipHostNumber")){ foreach($this->Zones as $key => $name){ if($name == $this->dnsEntry['zoneName']){ - $net = DNS::FlipIp(str_replace(".in-addr.arpa","",DNS::getNameFromMix($key))); + $net = DNS::FlipIp(str_replace(".in-addr.arpa.","",DNS::getNameFromMix($key))); $this->ipHostNumber = $this->generateRandomIP($net); } } @@ -457,7 +460,7 @@ class termDNS extends plugin $smarty->assign("changeStateForRecords",$changeStateForRecords); $smarty->assign("staticAddress","*"); - $smarty->assign("autonetACL",$this->acl_is_writeable("macAddress").$this->acl_is_writeable("ipHostNumber")); + $smarty->assign("autonetACL",$this->acl_is_writeable("macAddress") && $this->acl_is_writeable("ipHostNumber")?"rw":""); $display.= $smarty->fetch(get_template_path('network.tpl', TRUE)); } @@ -719,7 +722,7 @@ class termDNS extends plugin } /* Do not add the objectClass ipHost if no ip address is given */ - if(!$this->attrs['ipHostNumber']){ + if(!isset($this->attrs['ipHostNumber'])){ $this->attrs['objectClass'] = array_remove_entries(array("ipHost"),$this->attrs['objectClass']); } @@ -748,6 +751,15 @@ class termDNS extends plugin if(count($this->dhcpHostEntry['dhcpOption']) == 0){ $this->dhcpHostEntry['dhcpOption']= array("host-name ".$this->cn); } + }else{ + + // Updated Host-Name entry + foreach($this->dhcpHostEntry['dhcpOption'] as $key => $entry){ + if(preg_match("/^host-name/", $entry)){ + $this->dhcpHostEntry['dhcpOption'][$key] = "host-name ".$this->cn; + break; + } + } } /* Write mac address to dhcp settings */ @@ -881,6 +893,10 @@ class termDNS extends plugin $this->dnsEntry['exists'] = $this->DNS_is_account; $tmp = DNS::getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn); } + + /* Update SOA record if needed + */ + $this->updateSOARecord(); /* move follwoing entries */ @@ -1096,7 +1112,7 @@ class termDNS extends plugin $attrs = $ldap->fetch(); $tmp = array_flip($this->Zones); $tmp = preg_replace("/^[^\/]*+\//","",$tmp[$this->dnsEntry['zoneName']]); - $tmp = trim(preg_replace("/\.in-addr.arpa$/","",$tmp)); + $tmp = trim(preg_replace("/\.in-addr.arpa\.$/","",$tmp)); $ptr = preg_replace("/^".preg_quote(DNS::FlipIp($tmp), '/')."\./","",$this->ipHostNumber); return($ptr); }else{ @@ -1121,9 +1137,11 @@ class termDNS extends plugin "(objectClass=gotoPrinter)". "(objectClass=ipHost)"; $list = array(); - $ldap->search("(&(|{$ocs})(ipHostNumber={$net}*))",array("ipHostNumber")); + $ldap->search("(&(|{$ocs})(ipHostNumber=*))",array("ipHostNumber")); while($attrs = $ldap->fetch()){ - $list[] = $attrs['ipHostNumber'][0]; + if (preg_match("/^$net\./", $attrs['ipHostNumber'][0])) { + $list[] = $attrs['ipHostNumber'][0]; + } } // Set starting ip. @@ -1181,6 +1199,15 @@ class termDNS extends plugin } } } + + function updateSOARecord() + { + $oldEntries = DNS::getDNSHostEntries($this->config,$this->OrigCn); + $newEntries = $this->dnsEntry; + if(array_differs($newEntries['RECORDS'],$oldEntries['RECORDS'])){ + DNS::touchDNSZone($this->config,$this->dnsEntry['zoneName']); + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: