From 4569cae57f127afd093794310ccd290d2d9fdf36 Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Wed, 20 Apr 2016 10:58:46 -0400
Subject: [PATCH] Merge branch 'stable-3.1'

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

diff --git a/server/plugins-available/shelluser_jailkit_plugin.inc.php b/server/plugins-available/shelluser_jailkit_plugin.inc.php
index aabbcde..5645953 100755
--- a/server/plugins-available/shelluser_jailkit_plugin.inc.php
+++ b/server/plugins-available/shelluser_jailkit_plugin.inc.php
@@ -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);

--
Gitblit v1.9.1