Auth_model->enforce_policy('web_admin','administer', 'admin'); load_lang("bubba",THEME.'/i18n/'.LANGUAGE); } function _renderfull($content, $head = '/disk/disk_head_view', $data = ''){ $navdata["menu"] = $this->menu->retrieve($this->session->userdata('user'),$this->uri->uri_string()); $mdata["navbar"]=$this->load->view(THEME.'/nav_view',$navdata,true); $mdata["dialog_menu"] = $this->load->view(THEME.'/menu_view',$this->menu->get_dialog_menu(),true); $mdata["head"] = $this->load->view(THEME.$head,$data,true); $mdata["content"]=$content; $this->load->view(THEME.'/main_view',$mdata); } function _list_mounts($haspass){ $fstab = file('/etc/fstab'); $fstab = preg_grep ('/^\s*#/',$fstab,PREG_GREP_INVERT); $fstab = preg_grep ('/\secryptfs\s/',$fstab); sort($fstab); $mtab = file('/etc/mtab'); $mtab = preg_grep ('/^\s*#/',$mtab,PREG_GREP_INVERT); $mtab = preg_grep ('/\secryptfs\s/',$mtab); sort($mtab); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; foreach($fstab as $num => $line){ $fields = preg_split('/\s+/',$line); $ck = preg_quote($fields[0],'/'); $is_mounted = count(preg_grep("/^$ck\s/",$mtab)); echo ''; echo ''; if($is_mounted){ echo ''; }else{ if($haspass && $this->_mount($fields[1])){ echo ''; }else{ echo ''; } } echo ''; } echo ''; echo '
eCryptfs Mount Points
MountpointMounted
'.htmlspecialchars($fields[1]).'mountednow mountednot mounted
'; echo '
'; echo '
'; echo 'Provide passphrase'; echo ''; echo ''; echo '
'; echo '
'; } function _passadd($pass){ $fstab = file('/etc/fstab'); $fstab = preg_grep ('/^\s*#/',$fstab,PREG_GREP_INVERT); $fstab = preg_grep ('/\secryptfs\s/',$fstab); sort($fstab); $mtab = file('/etc/mtab'); $mtab = preg_grep ('/^\s*#/',$mtab,PREG_GREP_INVERT); $mtab = preg_grep ('/\secryptfs\s/',$mtab); sort($mtab); $fh = popen('/usr/bin/ecryptfs-add-passphrase --fnek -','w'); if(!$fh) { echo '

Failed to run the ecryptfs-add-passphrase command.

'; return false; } fwrite($fh,$pass); $ok = pclose($fh); if($ok !== 0){ echo '

Something went wrong during passphrase add.

'; return false; } echo '

Passphrase added to kernel keyring.

'; return true; } function _mount($mp){ $ok = 0; $out = array(); exec('/bin/mount -i '.escapeshellarg($mp),$out,$ok); if($ok == 0){ return true; }else{ return false; } } function index(){ ob_start(); if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'){ echo '

Please access this page via HTTPS only

'; }else{ $haspass = false; if(isset($_POST['pass']) && $_POST['pass']){ $haspass = $this->_passadd($_POST['pass']); } $this->_list_mounts($haspass); } $content = ob_get_contents(); ob_end_clean(); $this->_renderfull($content); } }