Skip to content

Commit f45e5fa

Browse files
author
Marius Burkard
committed
- fixed problems from implementation of vulnerability fix
1 parent 29c8d7e commit f45e5fa

File tree

3 files changed

+52
-10
lines changed

3 files changed

+52
-10
lines changed

server/lib/classes/system.inc.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,12 +2312,12 @@ public function is_allowed_path($path) {
23122312
'@^/$@',
23132313
'@^/proc(/.*)?$@',
23142314
'@^/sys(/.*)?$@',
2315-
'@^/etc(/.*)$@',
2316-
'@^/dev(/.*)$@',
2317-
'@^/tmp(/.*)$@',
2318-
'@^/run(/.*)$@',
2319-
'@^/boot(/.*)$@',
2320-
'@^/root(/.*)$@',
2315+
'@^/etc(/.*)?$@',
2316+
'@^/dev(/.*)?$@',
2317+
'@^/tmp(/.*)?$@',
2318+
'@^/run(/.*)?$@',
2319+
'@^/boot(/.*)?$@',
2320+
'@^/root(/.*)?$@',
23212321
'@^/var(/?|/backups?(/.*)?)?$@',
23222322
);
23232323

@@ -2380,6 +2380,8 @@ public function system_safe($cmd) {
23802380
}
23812381

23822382
public function create_jailkit_user($username, $home_dir, $user_home_dir, $shell = '/bin/bash', $p_user = null, $p_user_home_dir = null) {
2383+
global $app;
2384+
23832385
// Disallow operating on root directory
23842386
if(realpath($home_dir) == '/') {
23852387
$app->log("create_jailkit_user: invalid home_dir: $home_dir", LOGLEVEL_WARN);
@@ -2409,6 +2411,8 @@ public function create_jailkit_user($username, $home_dir, $user_home_dir, $shell
24092411
}
24102412

24112413
public function create_jailkit_chroot($home_dir, $app_sections = array(), $options = array()) {
2414+
global $app;
2415+
24122416
// Disallow operating on root directory
24132417
if(realpath($home_dir) == '/') {
24142418
$app->log("create_jailkit_chroot: invalid home_dir: $home_dir", LOGLEVEL_WARN);
@@ -2480,6 +2484,8 @@ public function create_jailkit_chroot($home_dir, $app_sections = array(), $optio
24802484
}
24812485

24822486
public function create_jailkit_programs($home_dir, $programs = array(), $options = array()) {
2487+
global $app;
2488+
24832489
// Disallow operating on root directory
24842490
if(realpath($home_dir) == '/') {
24852491
$app->log("create_jailkit_programs: invalid home_dir: $home_dir", LOGLEVEL_WARN);

server/plugins-available/shelluser_base_plugin.inc.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ function insert($event_name, $data) {
9797
}
9898

9999
if(is_file($data['new']['dir']) || is_link($data['new']['dir'])) {
100-
$app->log('Shell user dir must not be existing file or symlink.', LOVLEVEL_WARN);
100+
$app->log('Shell user dir must not be existing file or symlink.', LOGLEVEL_WARN);
101101
return false;
102102
} elseif(!$app->system->is_allowed_path($data['new']['dir'])) {
103-
$app->log('Shell user dir is not an allowed path: ' . $data['new']['dir'], LOVLEVEL_WARN);
103+
$app->log('Shell user dir is not an allowed path: ' . $data['new']['dir'], LOGLEVEL_WARN);
104104
return false;
105105
}
106106

@@ -216,10 +216,10 @@ function update($event_name, $data) {
216216
}
217217

218218
if(is_file($data['new']['dir']) || is_link($data['new']['dir'])) {
219-
$app->log('Shell user dir must not be existing file or symlink.', LOVLEVEL_WARN);
219+
$app->log('Shell user dir must not be existing file or symlink.', LOGLEVEL_WARN);
220220
return false;
221221
} elseif(!$app->system->is_allowed_path($data['new']['dir'])) {
222-
$app->log('Shell user dir is not an allowed path: ' . $data['new']['dir'], LOVLEVEL_WARN);
222+
$app->log('Shell user dir is not an allowed path: ' . $data['new']['dir'], LOGLEVEL_WARN);
223223
return false;
224224
}
225225

@@ -320,6 +320,14 @@ function delete($event_name, $data) {
320320
return false;
321321
}
322322

323+
if(is_file($data['old']['dir']) || is_link($data['old']['dir'])) {
324+
$app->log('Shell user dir must not be existing file or symlink.', LOGLEVEL_WARN);
325+
return false;
326+
} elseif(!$app->system->is_allowed_path($data['old']['dir'])) {
327+
$app->log('Shell user dir is not an allowed path: ' . $data['old']['dir'], LOGLEVEL_WARN);
328+
return false;
329+
}
330+
323331
if($app->system->is_user($data['old']['username'])) {
324332
// Get the UID of the user
325333
$userid = intval($app->system->getuid($data['old']['username']));

server/plugins-available/shelluser_jailkit_plugin.inc.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ function insert($event_name, $data) {
8989
return false;
9090
}
9191

92+
if(is_file($data['new']['dir']) || is_link($data['new']['dir'])) {
93+
$app->log('Shell user dir must not be existing file or symlink.', LOGLEVEL_WARN);
94+
return false;
95+
} elseif(!$app->system->is_allowed_path($data['new']['dir'])) {
96+
$app->log('Shell user dir is not an allowed path: ' . $data['new']['dir'], LOGLEVEL_WARN);
97+
return false;
98+
}
99+
100+
92101
if($app->system->is_user($data['new']['puser'])) {
93102
// Get the UID of the parent user
94103
$uid = intval($app->system->getuid($data['new']['puser']));
@@ -170,6 +179,14 @@ function update($event_name, $data) {
170179
return false;
171180
}
172181

182+
if(is_file($data['new']['dir']) || is_link($data['new']['dir'])) {
183+
$app->log('Shell user dir must not be existing file or symlink.', LOGLEVEL_WARN);
184+
return false;
185+
} elseif(!$app->system->is_allowed_path($data['new']['dir'])) {
186+
$app->log('Shell user dir is not an allowed path: ' . $data['new']['dir'], LOGLEVEL_WARN);
187+
return false;
188+
}
189+
173190
if($app->system->is_user($data['new']['puser'])) {
174191
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']);
175192

@@ -241,6 +258,14 @@ function delete($event_name, $data) {
241258
return false;
242259
}
243260

261+
if(is_file($data['old']['dir']) || is_link($data['old']['dir'])) {
262+
$app->log('Shell user dir must not be existing file or symlink.', LOGLEVEL_WARN);
263+
return false;
264+
} elseif(!$app->system->is_allowed_path($data['old']['dir'])) {
265+
$app->log('Shell user dir is not an allowed path: ' . $data['old']['dir'], LOGLEVEL_WARN);
266+
return false;
267+
}
268+
244269
if ($data['old']['chroot'] == "jailkit")
245270
{
246271
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['old']['parent_domain_id']);
@@ -518,6 +543,9 @@ private function _setup_ssh_rsa() {
518543
}
519544
//* Get the keys
520545
$existing_keys = file($sshkeys, FILE_IGNORE_NEW_LINES);
546+
if(!$existing_keys) {
547+
$existing_keys = array();
548+
}
521549
$new_keys = explode("\n", $sshrsa);
522550
$old_keys = explode("\n", $this->data['old']['ssh_rsa']);
523551

0 commit comments

Comments
 (0)