X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Fsystems%2Fadmin%2Fsystems%2Fclass_termDNS.inc;h=c3806820105ab012dc51e1928edf2d20c0de74eb;hb=e9d5e9913de62425bb7dfd4d993fbcd8ac609aa4;hp=6fd06d3c602077beda626330b3699d2c0657c0e4;hpb=abc050029569b93dac5d8e4076ae9cc3bed64cff;p=gosa.git diff --git a/gosa-plugins/systems/admin/systems/class_termDNS.inc b/gosa-plugins/systems/admin/systems/class_termDNS.inc index 6fd06d3c6..c38068201 100644 --- a/gosa-plugins/systems/admin/systems/class_termDNS.inc +++ b/gosa-plugins/systems/admin/systems/class_termDNS.inc @@ -65,10 +65,11 @@ class termDNS extends plugin var $dnsEntry = array(); var $DNSenabled = false; var $hide_dns_check_box = FALSE; + var $namingAttr = "cn"; /* Terminal dns */ - function termDNS (&$config, $parent,$objectClasses,$IPisMust = false) + function termDNS (&$config, $parent,$objectClasses,$IPisMust = false,$namingAttr = "cn") { /* We need to know which objectClasses are used, to store the ip/mac * Because of different type of devices @@ -76,12 +77,15 @@ class termDNS extends plugin $this->parent = $parent; $this->objectclasses = $objectClasses; $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['cn'][0])){ - $this->OrigCn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]); - $this->cn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]); + if(isset($this->attrs[$namingAttr][0])){ + $this->OrigCn = preg_replace("/\\\$\$/","",$this->attrs[$namingAttr][0]); + $this->cn = preg_replace("/\\\$\$/","",$this->attrs[$namingAttr][0]); } /* Create list of additional ipHostNumber. @@ -98,7 +102,7 @@ class termDNS extends plugin ************/ /* Hide all dhcp specific code, if dhcp plugin is not present in config */ - $dhcpEnabled = FALSE; + $this->dhcpEnabled = FALSE; if($this->config->search("servdhcp","class",array("tabs"))){ $this->dhcpEnabled = TRUE; } @@ -152,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]); @@ -231,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{ @@ -254,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){ @@ -322,7 +327,7 @@ class termDNS extends plugin $this->dialog->read_only = !$this->acl_is_writeable("dhcpSetup"); $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress; if(!empty($this->ipHostNumber)){ - $this->dialog->statements['fixed-address'] = $this->ipHostNumber; + $this->dialog->statements->set('fixed-address', $this->ipHostNumber); } } @@ -330,7 +335,7 @@ class termDNS extends plugin $this->dialog = FALSE; } - if(isset($_POST['save_dhcp']) && $this->acl_is_writeable("dhcpSetup")){ + if(isset($_POST['save_dhcp']) && $this->acl_is_writeable("dhcpSetup") && is_object($this->dialog)){ $this->dialog->save_object(); $msgs = $this->dialog->check(array()); if(count($msgs)){ @@ -388,8 +393,8 @@ 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))); - $this->ipHostNumber = $this->generateRandomIp($net); + $net = DNS::FlipIp(str_replace(".in-addr.arpa.","",DNS::getNameFromMix($key))); + $this->ipHostNumber = $this->generateRandomIP($net); } } } @@ -423,7 +428,7 @@ class termDNS extends plugin /* Assign smarty all DNS attributes */ foreach($this->DNSattributes as $attr){ - $smarty->assign($attr,$this->dnsEntry[$attr]); + $smarty->assign($attr,htmlentities($this->dnsEntry[$attr])); } /* Assign all needed vars */ @@ -455,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)); } @@ -539,11 +544,15 @@ class termDNS extends plugin DNS posts ******/ - /* Check if DNS should be enabled / disabled */ - if($this->DNS_is_account && $this->acl_is_writeable("dnsSetup") && !isset($_POST['DNS_is_account'])){ - $this->DNS_is_account = false; - }elseif(!$this->DNS_is_account && $this->acl_is_writeable("dnsSetup") && isset($_POST['DNS_is_account'])){ - $this->DNS_is_account = true; + /* Check if DNS should be enabled / disabled + * -skip this, if the dns account is enforced. + */ + if(!$this->hide_dns_check_box){ + if($this->DNS_is_account && $this->acl_is_writeable("dnsSetup") && !isset($_POST['DNS_is_account'])){ + $this->DNS_is_account = false; + }elseif(!$this->DNS_is_account && $this->acl_is_writeable("dnsSetup") && isset($_POST['DNS_is_account'])){ + $this->DNS_is_account = true; + } } /* Get dns attributes */ @@ -559,7 +568,7 @@ class termDNS extends plugin } /* Check if value has changed */ if(isset($_POST['RecordValue_'.$key])){ - $this->dnsEntry['RECORDS'][$key]['value'] = $_POST['RecordValue_'.$key]; + $this->dnsEntry['RECORDS'][$key]['value'] = get_post('RecordValue_'.$key); } } } @@ -567,7 +576,7 @@ class termDNS extends plugin /* Get all basic DNS attributes (TTL, Clas ..)*/ foreach($this->DNSattributes as $attr){ if(isset($_POST[$attr])){ - $this->dnsEntry[$attr] = $_POST[$attr]; + $this->dnsEntry[$attr] = get_post($attr); } } } @@ -712,6 +721,11 @@ class termDNS extends plugin $this->attrs['ipHostNumber'][] = $value; } + /* Do not add the objectClass ipHost if no ip address is given */ + if(!isset($this->attrs['ipHostNumber'])){ + $this->attrs['objectClass'] = array_remove_entries(array("ipHost"),$this->attrs['objectClass']); + } + /* Write back to ldap */ $ldap->cd($this->dn); $this->cleanup(); @@ -729,7 +743,7 @@ class termDNS extends plugin $this->dialog->cn = $this->cn; $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress; if(!empty($this->ipHostNumber)){ - $this->dialog->statements['fixed-address'] = $this->ipHostNumber; + $this->dialog->statements->set('fixed-address', $this->ipHostNumber); } $this->dialog->execute(); $this->dialog->save_object(); @@ -737,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 */ @@ -749,7 +772,7 @@ class termDNS extends plugin } /* Updated IP host number */ - if($this->dhcp_is_Account){ + if($this->dhcp_is_Account && $this->dhcpHostEntry['dhcpStatements']){ foreach($this->dhcpHostEntry['dhcpStatements'] as $id => $value){ if(preg_match("/^fixed-address/",$value)){ $this->dhcpHostEntry['dhcpStatements'][$id] = "fixed-address ".$this->ipHostNumber; @@ -798,7 +821,7 @@ class termDNS extends plugin if(($this->initial_dhcpParentNode != $this->dhcpParentNode) || ($this->cn != $this->OrigCn)){ $attrs = $this->dhcpHostEntry; - $attrs['cn'] = $this->cn; + $attrs[$this->namingAttr] = $this->cn; unset($attrs['dn']); unset($attrs['MODIFIED']); $ldap->cd("cn=".$this->cn.",".$this->dhcpParentNode); @@ -870,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 */ @@ -933,7 +960,7 @@ class termDNS extends plugin $str.="