From 734a44a3de82f0b212a89cdaed0a92fa38cfb0c4 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 26 Sep 2006 04:44:12 +0000 Subject: [PATCH] Fixes acls for shares git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4768 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_goShareServer.inc | 31 ++++---- plugins/admin/systems/class_servNfs.inc | 75 +++++++++---------- plugins/admin/systems/goShareServer.tpl | 8 +- plugins/admin/systems/servnfs.tpl | 1 + 4 files changed, 60 insertions(+), 55 deletions(-) diff --git a/plugins/admin/systems/class_goShareServer.inc b/plugins/admin/systems/class_goShareServer.inc index 5bfe63424..0eab8bf07 100644 --- a/plugins/admin/systems/class_goShareServer.inc +++ b/plugins/admin/systems/class_goShareServer.inc @@ -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]); + } } } diff --git a/plugins/admin/systems/class_servNfs.inc b/plugins/admin/systems/class_servNfs.inc index 928f0052f..7569e80d3 100644 --- a/plugins/admin/systems/class_servNfs.inc +++ b/plugins/admin/systems/class_servNfs.inc @@ -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; } diff --git a/plugins/admin/systems/goShareServer.tpl b/plugins/admin/systems/goShareServer.tpl index 6cb4c45a6..4169f3706 100644 --- a/plugins/admin/systems/goShareServer.tpl +++ b/plugins/admin/systems/goShareServer.tpl @@ -2,7 +2,7 @@
-{render acl=$goExportEntryACL} +{render acl=$nameACL mode=read_active} -{render acl=$goExportEntryACL} +{/render} +{render acl=$nameACL mode=read_active} {/render} +{render acl=$nameACL} +{/render}
diff --git a/plugins/admin/systems/servnfs.tpl b/plugins/admin/systems/servnfs.tpl index 006f5d9c4..c749639dd 100644 --- a/plugins/admin/systems/servnfs.tpl +++ b/plugins/admin/systems/servnfs.tpl @@ -141,3 +141,4 @@ + -- 2.30.2