Skip to content

Commit 07bdbdf

Browse files
committed
Security mode fixes for jailkit.
1 parent 1c40af8 commit 07bdbdf

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

interface/web/sites/tools.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function getClientName($dataRecord) {
6767
$client_group_id = $dataRecord['sys_groupid'];
6868
}
6969
}
70+
7071
/* get the name of the client */
7172
$tmp = $app->db->queryOneRecord("SELECT name FROM sys_group WHERE groupid = " . $client_group_id);
7273
$clientName = $tmp['name'];

server/plugins-available/shelluser_jailkit_plugin.inc.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,16 @@ function insert($event_name,$data) {
8585
$this->app = $app;
8686
$this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
8787

88-
$this->_update_website_security_level();
89-
90-
$this->_setup_jailkit_chroot();
91-
9288
$command .= 'usermod -U '.escapeshellcmd($data['new']['username']);
9389
exec($command);
9490

91+
$this->_update_website_security_level();
92+
9593
$this->_add_jailkit_user();
94+
95+
$this->_setup_jailkit_chroot();
96+
97+
$this->_update_website_security_level();
9698
}
9799

98100
$app->log("Jailkit Plugin -> insert username:".$data['new']['username'],LOGLEVEL_DEBUG);
@@ -126,6 +128,8 @@ function update($event_name,$data) {
126128

127129
$this->_setup_jailkit_chroot();
128130
$this->_add_jailkit_user();
131+
132+
$this->_update_website_security_level();
129133
}
130134

131135
$app->log("Jailkit Plugin -> update username:".$data['new']['username'],LOGLEVEL_DEBUG);
@@ -161,6 +165,7 @@ function delete($event_name,$data) {
161165
exec($command);
162166
$app->log("Jailkit Plugin -> delete chroot home:".$data['old']['dir'].$jailkit_chroot_userhome,LOGLEVEL_DEBUG);
163167
}
168+
164169
}
165170

166171
$app->log("Jailkit Plugin -> delete username:".$data['old']['username'],LOGLEVEL_DEBUG);
@@ -280,13 +285,18 @@ function _update_website_security_level() {
280285

281286
//* If the security level is set to high
282287
if($web_config['security_level'] == 20) {
283-
exec("chmod 755 ".escapeshellcmd($web["document_root"]."/"));
284-
exec("chown root:root ".escapeshellcmd($web["document_root"]."/"));
288+
$this->_exec("chmod 755 ".escapeshellcmd($web["document_root"]));
289+
$this->_exec("chown root:root ".escapeshellcmd($web["document_root"]));
285290
}
286291

287292
}
288293

289-
294+
//* Wrapper for exec function for easier debugging
295+
private function _exec($command) {
296+
global $app;
297+
$app->log("exec: ".$command,LOGLEVEL_DEBUG);
298+
exec($command);
299+
}
290300

291301
} // end class
292302

0 commit comments

Comments
 (0)