From d2212dda734bb8c4b899faab848fa1bd7c1bf66e Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sun, 19 Sep 2010 08:01:47 -0400
Subject: [PATCH] Fixed bug in maildirmake function: http://www.howtoforge.com/forums/showthread.php?t=48890

---
 server/plugins-available/shelluser_base_plugin.inc.php |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/server/plugins-available/shelluser_base_plugin.inc.php b/server/plugins-available/shelluser_base_plugin.inc.php
index c3e112c..69348f5 100755
--- a/server/plugins-available/shelluser_base_plugin.inc.php
+++ b/server/plugins-available/shelluser_base_plugin.inc.php
@@ -89,9 +89,15 @@
 				$app->log("Executed command: ".$command,LOGLEVEL_DEBUG);
 				$app->log("Added shelluser: ".$data['new']['username'],LOGLEVEL_DEBUG);
 				
+				//* Create .bash_history file
+				touch(escapeshellcmd($data['new']['dir']).'/.bash_history');
+				chmod(escapeshellcmd($data['new']['dir']).'/.bash_history', 0755);
+				chown(escapeshellcmd($data['new']['dir']).'/.bash_history', escapeshellcmd($data['new']['username']));
+				chgrp(escapeshellcmd($data['new']['dir']).'/.bash_history', escapeshellcmd($data['new']['pgroup']));
+				
 				//* Disable shell user temporarily if we use jailkit
 				if($data['new']['chroot'] == 'jailkit') {
-					$command = 'usermod -L '.escapeshellcmd($data['new']['username']);
+					$command = 'usermod -s /bin/false -L '.escapeshellcmd($data['new']['username']);
 					exec($command);
 					$app->log("Disabling shelluser temporarily: ".$command,LOGLEVEL_DEBUG);
 				}
@@ -100,7 +106,7 @@
 				$app->log("UID = $uid for shelluser:".$data['new']['username']." not allowed.",LOGLEVEL_ERROR);
 			}
 		} else {
-			$app->log("Skippung insert of user:".$data['new']['username'].", parent user ".$data['new']['puser']." does not exist.",LOGLEVEL_WARN);
+			$app->log("Skipping insertion of user:".$data['new']['username'].", parent user ".$data['new']['puser']." does not exist.",LOGLEVEL_WARN);
 		}
 	}
 	
@@ -128,6 +134,16 @@
 					exec($command);
 					$app->log("Executed command: $command ",LOGLEVEL_DEBUG);
 					$app->log("Updated shelluser: ".$data['old']['username'],LOGLEVEL_DEBUG);
+					
+					
+					//* Create .bash_history file
+					if(!is_file($data['new']['dir']).'/.bash_history') {
+						touch(escapeshellcmd($data['new']['dir']).'/.bash_history');
+						chmod(escapeshellcmd($data['new']['dir']).'/.bash_history', 0755);
+						chown(escapeshellcmd($data['new']['dir']).'/.bash_history',escapeshellcmd($data['new']['username']));
+						chgrp(escapeshellcmd($data['new']['dir']).'/.bash_history',escapeshellcmd($data['new']['pgroup']));
+					}
+					
 				} else {
 					// The user does not exist, so we insert it now
 					$this->insert($event_name,$data);
@@ -136,7 +152,7 @@
 				$app->log("UID = $uid for shelluser:".$data['new']['username']." not allowed.",LOGLEVEL_ERROR);
 			}
 		} else {
-			$app->log("Skippung update for user:".$data['new']['username'].", parent user ".$data['new']['puser']." does not exist.",LOGLEVEL_WARN);
+			$app->log("Skipping update for user:".$data['new']['username'].", parent user ".$data['new']['puser']." does not exist.",LOGLEVEL_WARN);
 		}
 	}
 	
@@ -172,4 +188,4 @@
 
 } // end class
 
-?>
\ No newline at end of file
+?>

--
Gitblit v1.9.1