From 5ca959fa688255a8de61f89fe2751eb4d24a6912 Mon Sep 17 00:00:00 2001
From: Florian Schaal <florian@schaal-24.de>
Date: Tue, 22 Mar 2016 09:22:07 -0400
Subject: [PATCH] fixed typo

---
 server/plugins-available/shelluser_jailkit_plugin.inc.php |   49 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/server/plugins-available/shelluser_jailkit_plugin.inc.php b/server/plugins-available/shelluser_jailkit_plugin.inc.php
index 3c8e294..5645953 100755
--- a/server/plugins-available/shelluser_jailkit_plugin.inc.php
+++ b/server/plugins-available/shelluser_jailkit_plugin.inc.php
@@ -80,7 +80,7 @@
 		}
 		
 		
-		$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$data['new']['parent_domain_id']);
+		$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']);
 
 		if(!$app->system->is_allowed_user($data['new']['username'], false, false)
 			|| !$app->system->is_allowed_user($data['new']['puser'], true, true)
@@ -159,7 +159,7 @@
 			return false;
 		}
 		
-		$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$data['new']['parent_domain_id']);
+		$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']);
 
 		if(!$app->system->is_allowed_user($data['new']['username'], false, false)
 			|| !$app->system->is_allowed_user($data['new']['puser'], true, true)
@@ -232,7 +232,7 @@
 			return false;
 		}
 
-		$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$data['old']['parent_domain_id']);
+		$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['old']['parent_domain_id']);
 
 		if ($data['old']['chroot'] == "jailkit")
 		{
@@ -284,7 +284,7 @@
 
 			//add bash.bashrc script
 			//we need to collect the domain name to be used as the HOSTNAME in the bashrc script
-			$web = $this->app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ".intval($this->data['new']["parent_domain_id"]));
+			$web = $this->app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ?", $this->data['new']["parent_domain_id"]);
 
 			$this->app->load('tpl');
 
@@ -301,7 +301,7 @@
 			file_put_contents($bashrc, $tpl->grab());
 			unset($tpl);
 
-			$this->app->log("Added bashrc script : ".$bashrc, LOGLEVEL_DEBUG);
+			$this->app->log("Added bashrc script: ".$bashrc, LOGLEVEL_DEBUG);
 
 			$tpl = new tpl();
 			$tpl->newTemplate("motd.master");
@@ -318,13 +318,21 @@
 
 	function _add_jailkit_programs()
 	{
-		//copy over further programs and its libraries
-		$command = '/usr/local/ispconfig/server/scripts/create_jailkit_programs.sh';
-		$command .= ' '.escapeshellcmd($this->data['new']['dir']);
-		$command .= ' \''.$this->jailkit_config['jailkit_chroot_app_programs'].'\'';
-		exec($command.' 2>/dev/null');
+		$jailkit_chroot_app_programs = preg_split("/[\s,]+/", $this->jailkit_config['jailkit_chroot_app_programs']);
+		if(is_array($jailkit_chroot_app_programs) && !empty($jailkit_chroot_app_programs)){
+			foreach($jailkit_chroot_app_programs as $jailkit_chroot_app_program){
+				$jailkit_chroot_app_program = trim($jailkit_chroot_app_program);
+				if(is_file($jailkit_chroot_app_program) || is_dir($jailkit_chroot_app_program)){			
+					//copy over further programs and its libraries
+					$command = '/usr/local/ispconfig/server/scripts/create_jailkit_programs.sh';
+					$command .= ' '.escapeshellcmd($this->data['new']['dir']);
+					$command .= ' '.$jailkit_chroot_app_program;
+					exec($command.' 2>/dev/null');
 
-		$this->app->log("Added programs to jailkit chroot with command: ".$command, LOGLEVEL_DEBUG);
+					$this->app->log("Added programs to jailkit chroot with command: ".$command, LOGLEVEL_DEBUG);
+				}
+			}
+		}
 	}
 
 	function _get_home_dir($username)
@@ -378,7 +386,10 @@
 				}
 			}*/
 
-		$app->system->usermod($this->data['new']['username'], 0, 0, $this->data['new']['dir'].'/.'.$jailkit_chroot_userhome, '/usr/sbin/jk_chrootsh');
+		$shell = '/usr/sbin/jk_chrootsh';
+		if($this->data['new']['active'] != 'y') $shell = '/bin/false';
+		
+		$app->system->usermod($this->data['new']['username'], 0, 0, $this->data['new']['dir'].'/.'.$jailkit_chroot_userhome, $shell);
 		$app->system->usermod($this->data['new']['puser'], 0, 0, $this->data['new']['dir'].'/.'.$jailkit_chroot_userhome, '/usr/sbin/jk_chrootsh');
 
 		$this->app->log("Added jailkit user to chroot with command: ".$command, LOGLEVEL_DEBUG);
@@ -407,7 +418,7 @@
 		$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
 
 		// Get the parent website of this shell user
-		$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$this->data['new']['parent_domain_id']);
+		$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->data['new']['parent_domain_id']);
 
 		//* If the security level is set to high
 		if($web_config['security_level'] == 20 && is_array($web)) {
@@ -431,11 +442,11 @@
 		global $app;
 		$this->app->log("ssh-rsa setup shelluser_jailkit", LOGLEVEL_DEBUG);
 		// Get the client ID, username, and the key
-		$domain_data = $this->app->db->queryOneRecord('SELECT sys_groupid FROM web_domain WHERE web_domain.domain_id = '.intval($this->data['new']['parent_domain_id']));
-		$sys_group_data = $this->app->db->queryOneRecord('SELECT * FROM sys_group WHERE sys_group.groupid = '.intval($domain_data['sys_groupid']));
+		$domain_data = $this->app->db->queryOneRecord('SELECT sys_groupid FROM web_domain WHERE web_domain.domain_id = ?', $this->data['new']['parent_domain_id']);
+		$sys_group_data = $this->app->db->queryOneRecord('SELECT * FROM sys_group WHERE sys_group.groupid = ?', $domain_data['sys_groupid']);
 		$id = intval($sys_group_data['client_id']);
 		$username= $sys_group_data['name'];
-		$client_data = $this->app->db->queryOneRecord('SELECT * FROM client WHERE client.client_id = '.$id);
+		$client_data = $this->app->db->queryOneRecord('SELECT * FROM client WHERE client.client_id = ?', $id);
 		$userkey = $client_data['ssh_rsa'];
 		unset($domain_data);
 		unset($client_data);
@@ -459,7 +470,7 @@
 			$userkey = $app->system->file_get_contents('/tmp/id_rsa.pub');
 
 			// save keypair in client table
-			$this->app->db->query("UPDATE client SET created_at = ".time().", id_rsa = '".$app->db->quote($app->system->file_get_contents('/tmp/id_rsa'))."', ssh_rsa = '".$app->db->quote($userkey)."' WHERE client_id = ".$id);
+			$this->app->db->query("UPDATE client SET created_at = UNIX_TIMESTAMP(), id_rsa = ? ssh_rsa = ? WHERE client_id = ?", $app->system->file_get_contents('/tmp/id_rsa'), $userkey, $id);
 
 			$app->system->unlink('/tmp/id_rsa');
 			$app->system->unlink('/tmp/id_rsa.pub');
@@ -532,10 +543,10 @@
 		global $app, $conf;
 		
 		// check if we have to delete the dir
-				$check = $app->db->queryOneRecord('SELECT shell_user_id FROM `shell_user` WHERE `dir` = \'' . $app->db->quote($homedir) . '\'');
+				$check = $app->db->queryOneRecord('SELECT shell_user_id FROM `shell_user` WHERE `dir` = ?', $homedir);
 				
 				if(!$check && is_dir($homedir)) {
-					$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($parent_domain_id));
+					$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $parent_domain_id);
 					$app->system->web_folder_protection($web['document_root'], false);
 					
 					// delete dir

--
Gitblit v1.9.1