From 23ec67e0094fa55c5fd2066d17efd25803947ad4 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 25 Sep 2007 07:49:47 +0000 Subject: [PATCH] Updated dhcp service. Don't save dhcpOption: server-name for service base object (cn=dhcp,cn=server...). Save this attribute to all child objects instead. (host,group,subnet,sharedNetwork). Fixed saving for newly created savers with dhcp service, some attributes were not available while editing an entry like cn and dn. This caused PHP Warnings and empty server-name options git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7396 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_dhcpService.inc | 2 +- plugins/admin/systems/class_servDHCP.inc | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/admin/systems/class_dhcpService.inc b/plugins/admin/systems/class_dhcpService.inc index b3d7e0b0b..57f76cc9e 100644 --- a/plugins/admin/systems/class_dhcpService.inc +++ b/plugins/admin/systems/class_dhcpService.inc @@ -171,7 +171,7 @@ class dhcpService extends dhcpPlugin $this->attrs['dhcpPrimaryDN']= array($this->dhcpPrimaryDN); $this->removeOption('server-name'); - $this->attrs['dhcpOption'][]= "server-name $server_name"; +# $this->attrs['dhcpOption'][]= "server-name $server_name"; return ($this->attrs); } diff --git a/plugins/admin/systems/class_servDHCP.inc b/plugins/admin/systems/class_servDHCP.inc index d883bf4ae..d5048eea9 100644 --- a/plugins/admin/systems/class_servDHCP.inc +++ b/plugins/admin/systems/class_servDHCP.inc @@ -462,6 +462,27 @@ class servdhcp extends plugin continue; } + /* Opdate dhcp option 'server-name' to actual server name */ + if($this->dn != $this->orig_dn){ + $fixed = FALSE; + foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){ + if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){ + foreach($data['dhcpOption'] as $key => $option){ + if(preg_match("/^server-name /",$option)){ + $data['dhcpOption'][$key] = "server-name ".$this->cn; + $data['MODIFIED'] = TRUE; + break; + } + } + } + + /* Skip next loops if entry is updated */ + if($fixed){ + break; + } + } + } + /* Modify existing entry? */ if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){ -- 2.30.2