Code

Fixes acls for shares
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 26 Sep 2006 04:44:12 +0000 (04:44 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 26 Sep 2006 04:44:12 +0000 (04:44 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4768 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_goShareServer.inc
plugins/admin/systems/class_servNfs.inc
plugins/admin/systems/goShareServer.tpl
plugins/admin/systems/servnfs.tpl

index 5bfe63424829bfb9c29cbc9ed582b80543dbf893..0eab8bf07f1bbd5504b65091f6b0af6f9d4dc710 100644 (file)
@@ -55,7 +55,7 @@ class goShareServer extends goService{
     $smarty = get_smarty(); 
 
 
-    if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntryList']))){
+    if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntryList'])) && ($this->acl_is_writeable("name"))){
       if($this->allow_mounts){
         foreach($_POST['goExportEntryList'] as $entry){
           $this->deleteFromMountList($this->goExportEntryList[$entry]);
@@ -66,7 +66,7 @@ class goShareServer extends goService{
       }
     }
 
-    if(isset($_POST['NewNfsAdd'])){
+    if(isset($_POST['NewNfsAdd']) && ($this->acl_is_writeable("name"))){
       $this->oldone = NULL;
       $this->o_subWindow = new servnfs($this->config, $this);
       $this->o_subWindow->set_acl_category("server");
@@ -96,6 +96,7 @@ class goShareServer extends goService{
       }else{
         $this->o_subWindow->save_object();
         $newone = $this->o_subWindow->save();
+
         $this->addToList($newone);
         if($this->allow_mounts){
           if($this->oldone) {
@@ -128,11 +129,9 @@ class goShareServer extends goService{
 
     /* Set acls */
     $tmp = $this->plInfo();
-    $acl = ""; 
     foreach($tmp['plProvidedAcls'] as $name => $translated){
-      $acl .= $this->getacl($name);
+      $smarty->assign($name."ACL",$this->getacl($name));
     }
-    $smarty->assign("goExportEntryACL",$acl);
     $smarty->assign("createable",$this->acl_is_createable());
     $smarty->assign("removeable",$this->acl_is_removeable());
 
@@ -268,20 +267,24 @@ class goShareServer extends goService{
 
   function addToMountList($entry) 
   {
-    $key =  key($entry);
-    $type = $this->get_share_type($entry[$key]);
-    if (($type == "netatalk") || ($type == "NFS")) {
-      $this->mounts_to_add[$entry[$key]] = $entry[$key];
-      unset($this->mounts_to_remove[$entry[$key]]);
+    if($this->acl_is_writeable("name")){
+      $key =  key($entry);
+      $type = $this->get_share_type($entry[$key]);
+      if (($type == "netatalk") || ($type == "NFS")) {
+        $this->mounts_to_add[$entry[$key]] = $entry[$key];
+        unset($this->mounts_to_remove[$entry[$key]]);
+      }
     }
   }
 
   function deleteFromMountList($entry) 
   {
-    $type = $this->get_share_type($entry);
-    if (($type == "netatalk") || ($type == "NFS")) {
-      $this->mounts_to_remove[$entry] = $entry;
-      unset($this->mounts_to_add[$entry]);
+    if($this->acl_is_writeable("name")){
+      $type = $this->get_share_type($entry);
+      if (($type == "netatalk") || ($type == "NFS")) {
+        $this->mounts_to_remove[$entry] = $entry;
+        unset($this->mounts_to_add[$entry]);
+      }
     }
   }
 
index 928f0052f898ad5acd108f84d29d7c3aa6bf84f5..7569e80d3db65cc3857d6b805b157f3182eef7ee 100644 (file)
@@ -34,12 +34,12 @@ class servnfs extends plugin
     $this->parent = $parent;
     $dn = $parent->dn;
     plugin::plugin ($config, $dn);
-  
+
     $this->types   = array("CIFS" => "CIFS", "NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP");
     if($dn){
       $this->host = substr($dn, 3, strpos($dn, ',')-3);
     }
-    
+
     $this->charsets = array();
 
     if(!file_exists("/etc/gosa/encodings")){
@@ -53,7 +53,7 @@ class servnfs extends plugin
         while(!feof($fp)&&$i){
           $i -- ;
           $str = trim(fgets($fp,256));
-      
+
           /* Skip comments */
           if(!preg_match("/^#/",$str)){
             $arr = split("\=",$str);
@@ -62,21 +62,19 @@ class servnfs extends plugin
             }
           }
         }
-
-    
       }
     }
 
     if($entry){
       list($this->name, $this->description, $this->type, $this->charset,
-           $this->path, $this->option, $this->volume)= split("\|",$entry."|");
+          $this->path, $this->option, $this->volume)= split("\|",$entry."|");
       $this->is_edit          = true;
 
     }else{
       $this->attributes[] = "name";
     }
 
-    
+
     $this->create_mount_init = $mount;
   }
 
@@ -103,41 +101,40 @@ class servnfs extends plugin
 
     $smarty->assign("name",$this->name);
     if($this->is_edit){
-      $smarty->assign("nameACL", preg_replace("/w/",$this->getacl("name")));
-    }
-    
+      $smarty->assign("nameACL", preg_replace("/w/","",$this->parent->getacl("name")));
+    } 
     $smarty->assign("allow_mounts", $this->parent->allow_mounts);
     $smarty->assign("mount_checked", "");
-    
+
     $smarty->assign("appleMountsACL",    $this->getacl("appleMounts"));
-  
+
     if (($this->type == "netatalk") || ($this->type == "NFS")) {
-        if ($this->create_mount_init) {
-          $smarty->assign("mount_checked", "checked");
-        } else {
+      if ($this->create_mount_init) {
+        $smarty->assign("mount_checked", "checked");
+      } else {
         $tmp = split(",", $this->dn);
         $clip = $tmp[0] . ",ou=servers,ou=systems,";
         $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip));
-          switch ($this->type) {
-            case "netatalk" : {
-              $mountdn = "cn=".$this->host.":/".$this->name.",".$mountsdn;
-              break;
-            }
-            case "NFS" : {
-              $mountdn = "cn=".$this->host.":".$this->path.",".$mountsdn;
-              break;
-            }
-            default : {
-              continue;
-            }
+        switch ($this->type) {
+          case "netatalk" : {
+            $mountdn = "cn=".$this->host.":/".$this->name.",".$mountsdn;
+            break;
+          }
+          case "NFS" : {
+            $mountdn = "cn=".$this->host.":".$this->path.",".$mountsdn;
+            break;
           }
+          default : {
+                      continue;
+                    }
+        }
         $ldap = $this->config->get_ldap_link();
         $ldap->cat($mountdn, array('dn'));
         $attrs = $ldap->fetch();
         if (count($attrs) > 0) {
-            $smarty->assign("mount_checked", "checked");
+          $smarty->assign("mount_checked", "checked");
         }
-        }        
+      }        
     }
 
     $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE));
@@ -153,7 +150,7 @@ class servnfs extends plugin
   /* Save data to object */
   function save_object()
   {
-    if(isset($_POST['path'])){
+    if(isset($_POST['servnfs_posted'])){
 
       foreach($this->attributes as $name){
         if($this->parent->acl_is_writeable($name) && isset($_POST[$name])){
@@ -198,7 +195,7 @@ class servnfs extends plugin
     if(preg_match("/[^a-z0-9._+ |-]/i",$this->volume)){
       $message[]=_("Volume contains invalid characters.");
     }
-  
+
     if(preg_match("/\|/",$this->path)){
       $message[]=_("Path contains invalid characters.");
     }
@@ -207,13 +204,13 @@ class servnfs extends plugin
       $message[]=_("Option contains invalid characters.");
     }
 
-  /* remove a / at the end of the path, we neither need it there nor
-   * do we want to check for it later.
-   */
-  if(substr($this->path, -1, 1) == '/') {
-    $this->path=substr($this->path, 0, -1);
-  }
-  
+    /* remove a / at the end of the path, we neither need it there nor
+     * do we want to check for it later.
+     */
+    if(substr($this->path, -1, 1) == '/') {
+      $this->path=substr($this->path, 0, -1);
+    }
+
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
     $ldap->search("(objectClass=goShareServer)", array("goExportEntry"));
@@ -252,7 +249,7 @@ class servnfs extends plugin
 
     return(array($this->name=>$s_return));
   }
-  
+
   function should_create_mount() {
     return $this->create_mount;
   }
index 6cb4c45a651d33bb309887831944674f0bae4399..4169f3706927a68149884c09269bbbeb35bfea44 100644 (file)
@@ -2,7 +2,7 @@
    <table summary="" style="width:100%">
     <tr>
      <td>
-{render acl=$goExportEntryACL}
+{render acl=$nameACL  mode=read_active}
         <select style="width:100%" id="goExportEntry" name="goExportEntryList[]" size=12 multiple >
             {html_options values=$goExportEntry output=$goExportEntryKeys}
             <option disabled>&nbsp;</option>
 {/render}
     <br>
        
+{render acl=$nameACL}
         <input type="submit"    value="{t}Add{/t}"     name="NewNfsAdd"   id="NewNfsAddId" {if !$createable} disabled {/if}>
-{render acl=$goExportEntryACL}
+{/render}
+{render acl=$nameACL mode=read_active}
         <input type="submit"    value="{t}Edit{/t}"     name="NewNfsEdit"  id="NewNfsEditId">
 {/render}
+{render acl=$nameACL}
         <input type="submit"    value="{t}Delete{/t}"   name="DelNfsEnt"   id="DelNfsEntId" {if !$removeable} disabled {/if}>
+{/render}
     </td>
     </tr>
    </table>
index 006f5d9c4a164ebdc45871487d836af831bb7772..c749639ddd8a70a87f3e0f2bdbbdb7bb909b595f 100644 (file)
                </td>
        </tr>
 </table>
+<input type='hidden' name='servnfs_posted' value='1'>