This file is indexed.

/usr/share/gosa/plugins/admin/systems/services/shares/class_servNfs.inc is in gosa-plugin-goto 2.7.4+reloaded2-1+deb8u2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?php

class servnfs extends plugin
{
    /* attribute list for save action */
    var $ignore_account   = TRUE;
    var $attributes       = array("description","type","charset","path","option", "volume");
    var $objectclasses    = array("whatever");
    var $is_account       = true;

    var $name          ="";  // Name of  
    var $description   ="";  // description
    var $type          ="";  // Type FS/Samba/NCP
    var $charset       ="";  // charset
    var $host          ="";  // hostname
    var $types         =array();  // Array Types NFS/Samba/NCP/netatalk
    var $charsets      =array();  // Array with charsets
    var $path          ="";  // Path
    var $volume        ="";  // Volume
    var $option        ="";  // Options
    var $is_edit           =false;
    var $create_mount_init = false; //mount entry set for this entry (while editing)?
    var $create_mount = false; //save mount entry

    var $parent       = NULL;
    var $view_logged  = FALSE;

    function servnfs (&$config, $parent,$entry= false,$mount =false)
    {
        $this->parent = $parent;
        $dn = $parent->dn;
        plugin::plugin ($config, $dn);

        $this->types   = array("NBD" => "NBD", "CIFS" => "CIFS", "NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP");
        if($dn){
            $this->host = substr($dn, 3, strpos($dn, ',')-3);
        }
        asort($this->types);

        $this->charsets = array();

        if(!file_exists(CONFIG_DIR."/encodings")){
            msg_dialog::display(_("Error"), msgPool::fileDoesNotExist(CONFIG_DIR."/encodings"), ERROR_DIALOG);
        }else{
            if(!is_readable(CONFIG_DIR."/encodings")){
                msg_dialog::display(_("Error"), msgPool::cannotReadFile(CONFIG_DIR."/encodings"), ERROR_DIALOG);
            }else{
                $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 = explode("=",$str);
                        if(count($arr)==2){
                            $this->charsets[$arr[0]]=$arr[1];
                        }
                    }
                }
            }
        }

        if($entry){
            list($this->name, $this->description, $this->type, $this->charset,
                    $this->path, $this->option, $this->volume)= explode("|",$entry."|");
            $this->is_edit          = true;

        }else{
            $this->attributes[] = "name";
        }


        $this->create_mount_init = $mount;
    }

    function execute()
    {
        /* Call parent execute */
        plugin::execute();

        if($this->is_account && !$this->view_logged){
            $this->view_logged = TRUE;
            new log("view","server/".get_class($this),$this->dn);
        }

        /* Fill templating stuff */
        $smarty= get_smarty();

        $smarty->assign("charsets" ,set_post($this->charsets));
        $smarty->assign("types"    ,set_post($this->types));

        /* attrs to smarty*/
        foreach($this->attributes as $attr){
            $smarty->assign($attr,set_post($this->$attr));
        }

        $tmp = $this->parent->plInfo();
        foreach($tmp['plProvidedAcls'] as $name => $translation){
            $smarty->assign($name."ACL",$this->parent->getacl($name));
        }

        $smarty->assign("name",set_post($this->name));
        if($this->is_edit){
            $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->parent->getacl("appleMounts"));

        if (($this->type == "netatalk") || ($this->type == "NFS")) {
            if ($this->create_mount_init) {
                $smarty->assign("mount_checked", "checked");
            } else {
                $tmp = explode(",", $this->dn);
                $clip = $tmp[0] . ",".get_ou("servgeneric", "serverRDN");
                $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;
                              }
                }
                $ldap = $this->config->get_ldap_link();
                $ldap->cat($mountdn, array('dn'));
                $attrs = $ldap->fetch();
                if (count($attrs) > 0) {
                    $smarty->assign("mount_checked", "checked");
                }
            }        
        }

        $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE, dirname(__FILE__)));
        return($display);
    }

    function remove_from_parent()
    {
        /* This cannot be removed... */
    }


    /* Save data to object */
    function save_object()
    {
        if(isset($_POST['servnfs_posted'])){

            foreach($this->attributes as $name){
                if($this->parent->acl_is_writeable($name) && isset($_POST[$name])){
                    $this->$name = get_post($name);
                }
            }

            if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) {
                $this->create_mount = true;
            } else {
                $this->create_mount = false;
            }
        }
    }


    /* Check supplied data */
    function check()
    {
        /* Call common method to give check the hook */
        $message= plugin::check();

        if(empty($this->path)){
            $message[]= msgPool::required(_("Path"));
        }

        if($this->type == "NBD") {
            if (!preg_match('/^[a-z0-9-]+:[0-9]+$/', $this->path)){
                $message[]= _("'Path / Volume' must be of format 'server:port'!");
            }
        } else {
            if (!tests::is_path($this->path)){
                $message[]= _("'Path / Volume' must contain at least one '/'!");
            }
        }

        if(!in_array_strict($this->type,$this->types)){
            $message[]= msgPool::required(_("Type"));
        }

        // only 0-9a-z
        if(!$this->is_edit){
            if(empty($this->name)){
                $message[]= msgPool::required(_("Name"));
            }
            if(!preg_match("/^[a-z0-9\._äüö-]*$/ui",$this->name)){
                $message[]= msgPool::invalid(_("Name"),$this->name,"/[a-z0-9\._äüö-]/ui");
            }
        }

        if(!empty($this->description) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->description)){
            $message[]= msgPool::invalid(_("Description"),$this->description,"/^[a-z0-9\._äüö\+ -]*$/ui");
        }

        if(!empty($this->volume) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->volume)){
            $message[]= msgPool::invalid(_("Volume"),$this->volume,"/^[a-z0-9\._äüö\+ -]*$/ui");
        }

        if(!empty($this->option) && preg_match("/^[^a-z0-9\._äüö,=\+ -]*$/ui",$this->option)){
            $message[]= msgPool::invalid(_("Option"),$this->option,"/^[a-z0-9\._äüö\+ -]*$/ui");
        }

        /* 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"));
        while($test = $ldap->fetch()){
            if($test['dn']==$this->dn)
                continue;
            if(isset($test['goExportEntry'])){
                foreach($test['goExportEntry'] as $entry){
                    $tmp = explode("|",$entry);
                    if($tmp[0] == $this->name){
                        $message[]= msgPool::duplicated(_("Name"));
                    }
                }
            }
        }
        return ($message);
    }


    /* Save to LDAP */
    function save()
    {
        /* Everything seems perfect, lets 
           generate an new export Entry 
         */

        $s_return = "";

        $s_return.= $this->name."|";     
        $s_return.= $this->description."|";     
        $s_return.= $this->type."|";     
        $s_return.= $this->charset."|";     
        $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;
    }
}

// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>