Skip to content

Commit e47d467

Browse files
committed
Fixed problems with jailkit 2.7
1 parent 723dd04 commit e47d467

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

server/plugins-available/shelluser_base_plugin.inc.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,16 @@ function insert($event_name,$data) {
7777
$uid = intval($app->system->getuid($data['new']['puser']));
7878
if($uid > $this->min_uid) {
7979
$command = 'useradd';
80-
$command .= ' --home '.escapeshellcmd($data['new']['dir']);
81-
$command .= ' --gid '.escapeshellcmd($data['new']['pgroup']);
82-
$command .= ' --non-unique ';
83-
$command .= ' --password '.escapeshellcmd($data['new']['password']);
84-
$command .= ' --shell '.escapeshellcmd($data['new']['shell']);
85-
$command .= ' --uid '.escapeshellcmd($uid);
80+
$command .= ' -d '.escapeshellcmd($data['new']['dir']);
81+
$command .= ' -g '.escapeshellcmd($data['new']['pgroup']);
82+
$command .= ' -o '; // non unique
83+
if($data['new']['password'] != '') $command .= ' -p '.escapeshellcmd($data['new']['password']);
84+
$command .= ' -s '.escapeshellcmd($data['new']['shell']);
85+
$command .= ' -u '.escapeshellcmd($uid);
8686
$command .= ' '.escapeshellcmd($data['new']['username']);
8787

8888
exec($command);
89+
$app->log("Executed command: ".$command,LOGLEVEL_DEBUG);
8990
$app->log("Added shelluser: ".$data['new']['username'],LOGLEVEL_DEBUG);
9091

9192
//* Disable shell user temporarily if we use jailkit
@@ -125,7 +126,7 @@ function update($event_name,$data) {
125126
$command .= ' '.escapeshellcmd($data['old']['username']);
126127

127128
exec($command);
128-
// $app->log("Updated shelluser: $command ",LOGLEVEL_DEBUG);
129+
$app->log("Executed command: $command ",LOGLEVEL_DEBUG);
129130
$app->log("Updated shelluser: ".$data['old']['username'],LOGLEVEL_DEBUG);
130131
} else {
131132
// The user does not exist, so we insert it now

server/plugins-available/shelluser_jailkit_plugin.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ function _add_jailkit_user()
234234
$jailkit_chroot_userhome = $this->_get_home_dir($this->data['new']['username']);
235235
$jailkit_chroot_puserhome = $this->_get_home_dir($this->data['new']['puser']);
236236

237+
if(!is_dir($this->data['new']['dir'].'/etc')) mkdir($this->data['new']['dir'].'/etc');
238+
if(!is_file($this->data['new']['dir'].'/etc/passwd')) exec('touch '.$this->data['new']['dir'].'/etc/passwd');
239+
237240
// IMPORTANT!
238241
// ALWAYS create the user. Even if the user was created before
239242
// if we check if the user exists, then a update (no shell -> jailkit) will not work

server/scripts/create_jailkit_user.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CHROOT_P_USER=$5
2222
CHROOT_P_USER_HOMEDIR=$6
2323

2424
### Add the chroot user ###
25-
jk_jailuser -s $CHROOT_SHELL -j $CHROOT_HOMEDIR $CHROOT_USERNAME
25+
jk_jailuser -n -s $CHROOT_SHELL -j $CHROOT_HOMEDIR $CHROOT_USERNAME
2626

2727
### Reconfigure the chroot home directory for the user ###
2828
usermod --home=$CHROOT_HOMEDIR/.$CHROOT_USERHOMEDIR $CHROOT_USERNAME

0 commit comments

Comments
 (0)