Skip to content

Commit 7bf3c54

Browse files
author
Marius Burkard
committed
- moved splitting for programs and sections (jailkit) to lib
- fixed warning in chmod
1 parent 9387f02 commit 7bf3c54

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

server/lib/classes/system.inc.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,6 +2136,8 @@ public function create_jailkit_user($username, $home_dir, $user_home_dir, $shell
21362136
public function create_jailkit_programs($home_dir, $programs = array()) {
21372137
if(empty($programs)) {
21382138
return true;
2139+
} elseif(is_string($programs)) {
2140+
$programs = preg_split('/[\s,]+/', $programs);
21392141
}
21402142
$program_args = '';
21412143
foreach($programs as $prog) {
@@ -2151,6 +2153,8 @@ public function create_jailkit_programs($home_dir, $programs = array()) {
21512153
public function create_jailkit_chroot($home_dir, $app_sections = array()) {
21522154
if(empty($app_sections)) {
21532155
return true;
2156+
} elseif(is_string($app_sections)) {
2157+
$app_sections = preg_split('/[\s,]+/', $app_sections);
21542158
}
21552159

21562160
// Change ownership of the chroot directory to root
@@ -2170,11 +2174,11 @@ public function create_jailkit_chroot($home_dir, $app_sections = array()) {
21702174
if(!is_dir($home_dir . '/tmp')) {
21712175
$this->mkdirpath($home_dir . '/tmp', 0777);
21722176
} else {
2173-
$this->chmod($home_dir . '/tmp', 0777);
2177+
$this->chmod($home_dir . '/tmp', 0777, true);
21742178
}
21752179

21762180
// Fix permissions of the root firectory
2177-
$this->chmod($home_dir . '/bin', 0755); // was chmod g-w $CHROOT_HOMEDIR/bin
2181+
$this->chmod($home_dir . '/bin', 0755, true); // was chmod g-w $CHROOT_HOMEDIR/bin
21782182

21792183
// mysql needs the socket in the chrooted environment
21802184
$this->mkdirpath($home_dir . '/var/run/mysqld');

server/plugins-available/cron_jailkit_plugin.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function _setup_jailkit_chroot()
216216
//check if the chroot environment is created yet if not create it with a list of program sections from the config
217217
if (!is_dir($this->parent_domain['document_root'].'/etc/jailkit'))
218218
{
219-
$app->system->create_jailkit_chroot($this->parent_domain['document_root'], preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_app_sections']));
219+
$app->system->create_jailkit_chroot($this->parent_domain['document_root'], $this->jailkit_config['jailkit_chroot_app_sections']);
220220

221221
$this->app->log("Added jailkit chroot", LOGLEVEL_DEBUG);
222222

@@ -256,10 +256,10 @@ function _add_jailkit_programs()
256256
global $app;
257257

258258
//copy over further programs and its libraries
259-
$app->system->create_jailkit_programs($this->parent_domain['document_root'], preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_app_programs']));
259+
$app->system->create_jailkit_programs($this->parent_domain['document_root'], $this->jailkit_config['jailkit_chroot_app_programs']);
260260
$this->app->log("Added app programs to jailkit chroot", LOGLEVEL_DEBUG);
261261

262-
$app->system->create_jailkit_programs($this->parent_domain['document_root'], preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_cron_programs']));
262+
$app->system->create_jailkit_programs($this->parent_domain['document_root'], $this->jailkit_config['jailkit_chroot_cron_programs']);
263263
$this->app->log("Added cron programs to jailkit chroot", LOGLEVEL_DEBUG);
264264
}
265265

server/plugins-available/shelluser_jailkit_plugin.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ function _setup_jailkit_chroot()
273273
//check if the chroot environment is created yet if not create it with a list of program sections from the config
274274
if (!is_dir($this->data['new']['dir'].'/etc/jailkit'))
275275
{
276-
$app->system->create_jailkit_chroot($this->data['new']['dir'], preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_app_sections']));
276+
$app->system->create_jailkit_chroot($this->data['new']['dir'], $this->jailkit_config['jailkit_chroot_app_sections']);
277277
$this->app->log("Added jailkit chroot", LOGLEVEL_DEBUG);
278278

279279
$this->_add_jailkit_programs();

0 commit comments

Comments
 (0)