cfoe
2012-07-11 4ce4a33ab38d0eb7a3f3f53d25913cd7d23952bb
server/plugins-available/shelluser_jailkit_plugin.inc.php
@@ -71,6 +71,7 @@
      global $app, $conf;
      
      $app->uses('system');
      $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$this->data['new']['parent_domain_id']);
      
      if($app->system->is_user($data['new']['username'])) {
      
@@ -79,6 +80,8 @@
          */
         if ($data['new']['chroot'] == "jailkit")
         {
            $app->system->web_folder_protection($web['document_root'],false);
            // load the server configuration options
            $app->uses("getconf");
            $this->data = $data;
@@ -98,6 +101,7 @@
            exec($command);
            
            $this->_update_website_security_level();
            $app->system->web_folder_protection($web['document_root'],true);
         }
      
         $app->log("Jailkit Plugin -> insert username:".$data['new']['username'],LOGLEVEL_DEBUG);
@@ -113,6 +117,7 @@
      global $app, $conf;
      
      $app->uses('system');
      $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$this->data['new']['parent_domain_id']);
      
      if($app->system->is_user($data['new']['username'])) {
      
@@ -121,6 +126,8 @@
          */
         if ($data['new']['chroot'] == "jailkit")
         {
            $app->system->web_folder_protection($web['document_root'],false);
            // load the server configuration options
            $app->uses("getconf");
            $this->data = $data;
@@ -136,6 +143,8 @@
            $this->_setup_ssh_rsa();
            
            $this->_update_website_security_level();
            $app->system->web_folder_protection($web['document_root'],true);
         }
      
         $app->log("Jailkit Plugin -> update username:".$data['new']['username'],LOGLEVEL_DEBUG);
@@ -155,6 +164,8 @@
      
      $app->uses('system');
      
      $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$this->data['old']['parent_domain_id']);
      if ($data['old']['chroot'] == "jailkit")
      {
         $app->uses("getconf");
@@ -165,12 +176,16 @@
         //commented out proved to be dangerous on config errors
         //exec('rm -rf '.$data['old']['dir'].$jailkit_chroot_userhome);
         
         $app->system->web_folder_protection($web['document_root'],false);
         if(@is_dir($data['old']['dir'].$jailkit_chroot_userhome)) {
            $command = 'userdel -f';
            $command .= ' '.escapeshellcmd($data['old']['username']);
            exec($command);
            $app->log("Jailkit Plugin -> delete chroot home:".$data['old']['dir'].$jailkit_chroot_userhome,LOGLEVEL_DEBUG);
         }
         $app->system->web_folder_protection($web['document_root'],true);
         
      }
      
@@ -376,9 +391,9 @@
         if(is_file('/root/.ssh/authorized_keys')) file_put_contents($sshkeys, file_get_contents('/root/.ssh/authorized_keys'));
      
         // Remove duplicate keys
         $existing_keys = file($sshkeys);
         $existing_keys = @file($sshkeys);
         $new_keys = explode("\n", $userkey);
         $final_keys_arr = array_merge($existing_keys, $new_keys);
         $final_keys_arr = @array_merge($existing_keys, $new_keys);
         $new_final_keys_arr = array();
         if(is_array($final_keys_arr) && !empty($final_keys_arr)){
            foreach($final_keys_arr as $key => $val){