Code

Updated Post checks in dhcp service plugin.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Jul 2008 05:51:35 +0000 (05:51 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Jul 2008 05:51:35 +0000 (05:51 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11753 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpAdvanced.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpGroup.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpHost.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNetwork.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpService.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc
gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubnet.inc

index 9f9df65fc2f56d3c2ed2506b0f901428631ab818..755214411ca6755a50ef79febf51316bd4c0c99d 100644 (file)
@@ -42,13 +42,15 @@ class dhcpAdvanced extends plugin
 
   function execute()
   {
+       $acl_writeable = preg_match("/w/",$this->parent->getacl(""));
+
     /* Check for interaction */
-    if (isset($_POST['add_statement']) && $_POST['addstatement'] != ""){
+    if ($acl_writeable && isset($_POST['add_statement']) && $_POST['addstatement'] != ""){
       $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addstatement'));
       $val= preg_replace("/^$key\s*/", '', get_post('addstatement'));
       $this->statements[$key]= $val;
     }
-    if (isset($_POST['delete_statement']) && isset($_POST['dhcpstatements'])){
+    if ($acl_writeable && isset($_POST['delete_statement']) && isset($_POST['dhcpstatements'])){
       $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpstatements'));
       if (in_array($key, $this->autoStatements)){
        msg_dialog::display(_("Error"), _("Cannot delete automatic statements!"), ERROR_DIALOG);
@@ -56,12 +58,12 @@ class dhcpAdvanced extends plugin
         unset($this->statements[$key]);        
       }
     }
-    if (isset($_POST['add_option']) && $_POST['addoption'] != ""){
+    if ($acl_writeable && isset($_POST['add_option']) && $_POST['addoption'] != ""){
       $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addoption'));
       $val= preg_replace("/^$key\s*/", '', get_post('addoption'));
       $this->options[$key]= $val;
     }
-    if (isset($_POST['delete_option']) && isset($_POST['dhcpoptions'])){
+    if ($acl_writeable && isset($_POST['delete_option']) && isset($_POST['dhcpoptions'])){
       $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpoptions'));
       if (in_array($key, $this->autoOptions)){
        msg_dialog::display(_("Error"), _("Cannot delete automatic statements!"), ERROR_DIALOG);
index 10978700ba232070f4cc577423660bea46006bc1..6a0d78b00fe9a3f66c5ab507d790a116d14a18a3 100644 (file)
@@ -75,7 +75,7 @@ class dhcpGroup extends dhcpPlugin
   function save_object()
   {
     /* Save cn */
-    if (isset($_POST['cn'])){
+    if (preg_match("/w/",$this->parent->getacl("")) && isset($_POST['cn'])){
       $this->cn= validate(get_post('cn'));
     }
 
index 26fabb20f8aed28dfe9b025f7729531622587d44..776a3e6c1d0852da6f404d2cb05c5a148ed77a3d 100644 (file)
@@ -102,7 +102,7 @@ class dhcpHost extends dhcpPlugin
   function save_object()
   {
     /* Save remaining attributes */
-    if (isset($_POST['dhcp_host_posted'])){
+    if (isset($_POST['dhcp_host_posted']) && preg_match("/w/",$this->parent->getacl(""))){
 
       /* Assemble hwAddress */
       if (isset($_POST['dhcpHWAddress'])){
index 6054eb6965782632a35aededa43d56506f936e63..0f99ce23b3b6ec4f4b99525ef4bc26391b78b756 100644 (file)
@@ -36,10 +36,14 @@ class dhcpNetwork extends plugin
 
   function execute()
   {
+
+    $acl_writeable = preg_match("/w/",$this->parent->getacl(""));
+
     /* Check for iteraction */
-    if (isset($_POST['add_dns']) && $_POST['addserver'] != ""){
+    if ($acl_writeable && isset($_POST['add_dns']) && $_POST['addserver'] != ""){
       if (!preg_match('/^[0-9a-z.-]+$/', get_post('addserver'))){
-        msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),htmlentities(get_post('addserver')),"/[0-9a-z.-]/"), ERROR_DIALOG);
+        msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),
+              htmlentities(get_post('addserver')),"/[0-9a-z.-]/"), ERROR_DIALOG);
       } else {
         $servers= array();
         if (isset($this->options['domain-name-servers'])){
@@ -56,7 +60,7 @@ class dhcpNetwork extends plugin
         $this->options['domain-name-servers']= preg_replace('/,$/', '', $tmp);
       }
     }
-    if (isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){
+    if ($acl_writeable && isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){
       $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i", '',
           $this->options['domain-name-servers']);
       $tmp= preg_replace("/(\s*)?,(\s*)?$/", '', $tmp);
@@ -151,7 +155,7 @@ class dhcpNetwork extends plugin
   function save_object()
   {
     /* Only save, if we are "active" */
-    if (isset($_POST['routers'])){
+    if (isset($_POST['routers']) && preg_match("/w/",$this->parent->getacl(""))){
 
       /*
        * Assemble options
index c5064164925df4ff818b314d5638752adbd089e1..5260b743f0d1273edda195fe77de2347fa5212a1 100644 (file)
@@ -114,24 +114,23 @@ class dhcpService extends dhcpPlugin
   function save_object()
   {
     /* No need to save in the first time */
-    if (!isset($_POST['ddns_update_style'])){
-      return;
-    }
-
-    /* Save remaining attributes */
-    foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $val){
-      $tval= preg_replace('/_/', '-', $val);
-      if ($_POST[$val] != ""){
-        $this->statements[$tval]= validate(get_post($val));
+    if (isset($_POST['ddns_update_style']) && preg_match("/w/",$this->parent->getacl(""))){
+
+      /* Save remaining attributes */
+      foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $val){
+        $tval= preg_replace('/_/', '-', $val);
+        if ($_POST[$val] != ""){
+          $this->statements[$tval]= validate(get_post($val));
+        } else {
+          unset ($this->statements[$tval]);
+        }
+      }
+      if (isset($_POST['authoritative'])){
+        $this->statements['authoritative']= "";
       } else {
-        unset ($this->statements[$tval]);
+        unset($this->statements['authoritative']);
       }
     }
-    if (isset($_POST['authoritative'])){
-      $this->statements['authoritative']= "";
-    } else {
-      unset($this->statements['authoritative']);
-    }
 
     dhcpPlugin::save_object();
   }
index 93b0330d174e33c850b0648a51bef7b4f8e660b6..15ead8eeb2d6196a84f9463c44509522dcd395db 100644 (file)
@@ -107,7 +107,12 @@ class dhcpSharedNetwork extends dhcpPlugin
   /* Save data to object */
   function save_object()
   {
-    if (isset($_POST['cn'])){
+       /* Check permissions, don't touch anything if we do not have write permissions 
+     */
+    if (!preg_match("/w/",$this->parent->getacl(""))){
+      dhcpPlugin::save_object();
+       }elseif(isset($_POST['cn'])){
+
       $this->cn= validate(get_post('cn'));
       dhcpPlugin::save_object();
 
index c0bf218d1e8fd11f1dc219baaf9e1dc37de1a44f..2227e14f44d20ba76b12116c16e86b75259fb024 100644 (file)
@@ -110,7 +110,11 @@ class dhcpSubnet extends dhcpPlugin
   /* Save data to object */
   function save_object()
   {
-    if(isset($_POST['dhcp_subnet_posted'])){
+
+    /* Skip here if do not have write permissions here 
+        Still executed at bottom - dhcpPlugin::save_object();
+     */
+    if(isset($_POST['dhcp_subnet_posted']) && preg_match("/w/",$this->parent->getacl(""))){
       if (isset($_POST['cn'])){
         $this->cn= validate(get_post('cn'));
       } 
@@ -127,8 +131,8 @@ class dhcpSubnet extends dhcpPlugin
 
       /* Move range to internal variable */
       $this->dhcpRange= $this->range_start." ".$this->range_stop;
-      dhcpPlugin::save_object();
     }
+    dhcpPlugin::save_object();
   }
 
 
@@ -159,7 +163,11 @@ class dhcpSubnet extends dhcpPlugin
     }
 
     /* IP's? */
-    foreach(array('dhcpNetMask' => _("Netmask"), 'cn' => _("Network address"), 'range_start' => _("Range"), 'range_stop' => _("Range")) as $attr => $str){
+    foreach(array(
+          'dhcpNetMask' => _("Netmask"), 
+          'cn'          => _("Network address"),
+          'range_start' => _("Range"),
+          'range_stop'  => _("Range")) as $attr => $str){
       if ($this->$attr != "" && !tests::is_ip($this->$attr)){
         $message[]= msgPool::invalid($str,"","","192.168.0.23");
       }