X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servNfs.inc;h=c7b05c3621f7a1fe0e7aa8781fee7acf93982569;hb=6a1a66d8a6cd5da5cd6b48c3e9719db322f96435;hp=ca8b1f09d73e941fef5457c6279db7bdb79618fb;hpb=eae35830da4661b09cba65a7b081936c8a10cc32;p=gosa.git diff --git a/plugins/admin/systems/class_servNfs.inc b/plugins/admin/systems/class_servNfs.inc index ca8b1f09d..c7b05c362 100644 --- a/plugins/admin/systems/class_servNfs.inc +++ b/plugins/admin/systems/class_servNfs.inc @@ -24,36 +24,36 @@ class servnfs extends plugin var $volume =""; // Volume var $option =""; // Options var $is_edit =false; - var $allow_mounts = false; //do we allow mount entries? var $create_mount_init = false; //mount entry set for this entry (while editing)? var $create_mount = false; //save mount entry - function servnfs ($config, $acl, $allow_mounts, $dn= NULL,$entry = false,$mount = false) + var $parent = NULL; + + function servnfs ($config, $parent,$entry= false,$mount =false) { + $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->acl = $acl; - $this->allow_mounts=$allow_mounts; - + $this->charsets = array(); - if(!file_exists("/etc/gosa/encodings")){ - print_red(_("The file '/etc/gosa/encodings' does not exist, can't get supported charsets.")); + if(!file_exists(CONFIG_DIR."/encodings")){ + print_red(sprintf(_("The file '%s/encodings' does not exist, can't get supported charsets."),CONFIG_DIR)); }else{ - if(!is_readable("/etc/gosa/encodings")){ - print_red(_("Can't read '/etc/gosa/encodings', please check permissions.")); + if(!is_readable(CONFIG_DIR."/encodings")){ + print_red(sprintf(_("Can't read '%s/encodings', please check permissions."),CONFIG_DIR)); }else{ - $fp = fopen("/etc/gosa/encodings","r"); + $fp = fopen(CONFIG_DIR."/encodings","r"); $i = 100; while(!feof($fp)&&$i){ $i -- ; $str = trim(fgets($fp,256)); - + /* Skip comments */ if(!preg_match("/^#/",$str)){ $arr = split("\=",$str); @@ -62,26 +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; - /* Decode if path is base64 */ - if (!preg_match('%/%', $this->path)){ - $this->path= base64_decode($this->path); - } - }else{ $this->attributes[] = "name"; } - + $this->create_mount_init = $mount; } @@ -101,49 +94,47 @@ class servnfs extends plugin $smarty->assign($attr,$this->$attr); } - $smarty->assign("nameACL",""); - $smarty->assign("name",$this->name); + $tmp = $this->parent->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->parent->getacl($name)); + } + $smarty->assign("name",$this->name); if($this->is_edit){ - $smarty->assign("nameACL"," disabled "); - } - - $smarty->assign("allow_mounts", $this->allow_mounts); + $smarty->assign("nameACL", preg_replace("/w/","",$this->parent->getacl("name"))); + } + $smarty->assign("allow_mounts", $this->parent->allow_mounts); $smarty->assign("mount_checked", ""); - - - $appleMountsACL=chkacl($this->acl,"gotoShareAppleMounts"); - $appleMountsACLset=strpos($appleMountsACL, "disabled"); - $smarty->assign("appleMountsACL", $appleMountsACL); - $smarty->assign("appleMountsACLset", $appleMountsACLset); - + + $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)); @@ -159,17 +150,19 @@ class servnfs extends plugin /* Save data to object */ function save_object() { - plugin::save_object(TRUE); - if(isset($_POST['path'])){ - foreach($this->attributes as $attr){ - $this->$attr = $_POST[$attr]; + if(isset($_POST['servnfs_posted'])){ + + foreach($this->attributes as $name){ + if($this->parent->acl_is_writeable($name) && isset($_POST[$name])){ + $this->$name = $_POST[$name]; + } } - } - - if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) { + + if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) { $this->create_mount = true; - } else { + } else { $this->create_mount = false; + } } } @@ -187,7 +180,7 @@ class servnfs extends plugin // only 0-9a-z if(!$this->is_edit){ - if(!preg_match("/^[a-z0-9\.\-_]+$/i",$this->name)){ + if(!preg_match("/^[a-z0-9\._]+$/i",$this->name)){ $message[]=_("Please specify a valid name for your share."); } if(empty($this->name)){ @@ -195,33 +188,29 @@ class servnfs extends plugin } } - if(preg_match("/[^a-z0-9._+ \|-]+/i",$this->description)){ + if(preg_match("/[^a-z0-9äöü._+ -]+/i",$this->description)){ $message[]=_("Description contains invalid characters."); } - if(preg_match("/[^a-z0-9._+ |-]/i",$this->volume)){ + if(preg_match("/[^a-z0-9._+ -]/i",$this->volume)){ $message[]=_("Volume contains invalid characters."); } - + if(preg_match("/\|/",$this->path)){ $message[]=_("Path contains invalid characters."); } - if(!preg_match("%/%",$this->path)){ - $message[]=_("Path must contain at least one slash."); + if(preg_match("/[^a-z0-9\.,=_+ -]/i",$this->option)){ + $message[]=_("Option contains invalid characters."); } - if(preg_match("/[^a-z0-9._+ \|-]/i",$this->option)){ - $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")); @@ -254,45 +243,18 @@ class servnfs extends plugin $s_return.= $this->description."|"; $s_return.= $this->type."|"; $s_return.= $this->charset."|"; - - /* Encode path if it contains non ascii letters */ - $path= $this->path; - if (!preg_match('=^[a-z0-9+_/%-]+$=i', $path)){ - $path= base64_encode($this->path); - } - - $s_return.= $path."|"; + $s_return.= $this->path."|"; $s_return.= $this->option."|"; $s_return.= $this->volume; return(array($this->name=>$s_return)); } - + function should_create_mount() { return $this->create_mount; } - /* Return plugin informations for acl handling */ - function plInfo() - { - return (array( - "plShortName" => _("NFS"), - "plDescription" => _("NFS service"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "description" => _("Description"), - "type" => _("Type"), - "charset" => _("Charset"), - "path" => _("Path"), - "option" => _("Option"), - "volume" => _("Volume")) - )); - } + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: