Skip to content

Commit 12e1193

Browse files
committed
Added: FS#730 - Congigure .bash_history for new shell user
1 parent 0ca379d commit 12e1193

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

server/plugins-available/shelluser_base_plugin.inc.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ function insert($event_name,$data) {
8989
$app->log("Executed command: ".$command,LOGLEVEL_DEBUG);
9090
$app->log("Added shelluser: ".$data['new']['username'],LOGLEVEL_DEBUG);
9191

92+
//* Create .bash_history file
93+
exec('touch '.escapeshellcmd($data['new']['dir']).'/.bash_history');
94+
exec('chmod 755 '.escapeshellcmd($data['new']['dir']).'/.bash_history');
95+
exec('chown '.escapeshellcmd($data['new']['username']).':'.escapeshellcmd($data['new']['pgroup']).' '.escapeshellcmd($data['new']['dir']).'/.bash_history');
96+
9297
//* Disable shell user temporarily if we use jailkit
9398
if($data['new']['chroot'] == 'jailkit') {
9499
$command = 'usermod -L '.escapeshellcmd($data['new']['username']);
@@ -128,6 +133,15 @@ function update($event_name,$data) {
128133
exec($command);
129134
$app->log("Executed command: $command ",LOGLEVEL_DEBUG);
130135
$app->log("Updated shelluser: ".$data['old']['username'],LOGLEVEL_DEBUG);
136+
137+
138+
//* Create .bash_history file
139+
if(!is_file($data['new']['dir']).'/.bash_history') {
140+
exec('touch '.escapeshellcmd($data['new']['dir']).'/.bash_history');
141+
exec('chmod 755 '.escapeshellcmd($data['new']['dir']).'/.bash_history');
142+
exec('chown '.escapeshellcmd($data['new']['username']).':'.escapeshellcmd($data['new']['pgroup']).' '.escapeshellcmd($data['new']['dir']).'/.bash_history');
143+
}
144+
131145
} else {
132146
// The user does not exist, so we insert it now
133147
$this->insert($event_name,$data);

0 commit comments

Comments
 (0)