Commit 7bf3c540 authored by Marius Burkard's avatar Marius Burkard
Browse files

- moved splitting for programs and sections (jailkit) to lib

- fixed warning in chmod
parent 9387f022
...@@ -2136,6 +2136,8 @@ class system{ ...@@ -2136,6 +2136,8 @@ class system{
public function create_jailkit_programs($home_dir, $programs = array()) { public function create_jailkit_programs($home_dir, $programs = array()) {
if(empty($programs)) { if(empty($programs)) {
return true; return true;
} elseif(is_string($programs)) {
$programs = preg_split('/[\s,]+/', $programs);
} }
$program_args = ''; $program_args = '';
foreach($programs as $prog) { foreach($programs as $prog) {
...@@ -2151,6 +2153,8 @@ class system{ ...@@ -2151,6 +2153,8 @@ class system{
public function create_jailkit_chroot($home_dir, $app_sections = array()) { public function create_jailkit_chroot($home_dir, $app_sections = array()) {
if(empty($app_sections)) { if(empty($app_sections)) {
return true; return true;
} elseif(is_string($app_sections)) {
$app_sections = preg_split('/[\s,]+/', $app_sections);
} }
// Change ownership of the chroot directory to root // Change ownership of the chroot directory to root
...@@ -2170,11 +2174,11 @@ class system{ ...@@ -2170,11 +2174,11 @@ class system{
if(!is_dir($home_dir . '/tmp')) { if(!is_dir($home_dir . '/tmp')) {
$this->mkdirpath($home_dir . '/tmp', 0777); $this->mkdirpath($home_dir . '/tmp', 0777);
} else { } else {
$this->chmod($home_dir . '/tmp', 0777); $this->chmod($home_dir . '/tmp', 0777, true);
} }
// Fix permissions of the root firectory // Fix permissions of the root firectory
$this->chmod($home_dir . '/bin', 0755); // was chmod g-w $CHROOT_HOMEDIR/bin $this->chmod($home_dir . '/bin', 0755, true); // was chmod g-w $CHROOT_HOMEDIR/bin
// mysql needs the socket in the chrooted environment // mysql needs the socket in the chrooted environment
$this->mkdirpath($home_dir . '/var/run/mysqld'); $this->mkdirpath($home_dir . '/var/run/mysqld');
......
...@@ -216,7 +216,7 @@ class cron_jailkit_plugin { ...@@ -216,7 +216,7 @@ class cron_jailkit_plugin {
//check if the chroot environment is created yet if not create it with a list of program sections from the config //check if the chroot environment is created yet if not create it with a list of program sections from the config
if (!is_dir($this->parent_domain['document_root'].'/etc/jailkit')) if (!is_dir($this->parent_domain['document_root'].'/etc/jailkit'))
{ {
$app->system->create_jailkit_chroot($this->parent_domain['document_root'], preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_app_sections'])); $app->system->create_jailkit_chroot($this->parent_domain['document_root'], $this->jailkit_config['jailkit_chroot_app_sections']);
$this->app->log("Added jailkit chroot", LOGLEVEL_DEBUG); $this->app->log("Added jailkit chroot", LOGLEVEL_DEBUG);
...@@ -256,10 +256,10 @@ class cron_jailkit_plugin { ...@@ -256,10 +256,10 @@ class cron_jailkit_plugin {
global $app; global $app;
//copy over further programs and its libraries //copy over further programs and its libraries
$app->system->create_jailkit_programs($this->parent_domain['document_root'], preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_app_programs'])); $app->system->create_jailkit_programs($this->parent_domain['document_root'], $this->jailkit_config['jailkit_chroot_app_programs']);
$this->app->log("Added app programs to jailkit chroot", LOGLEVEL_DEBUG); $this->app->log("Added app programs to jailkit chroot", LOGLEVEL_DEBUG);
$app->system->create_jailkit_programs($this->parent_domain['document_root'], preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_cron_programs'])); $app->system->create_jailkit_programs($this->parent_domain['document_root'], $this->jailkit_config['jailkit_chroot_cron_programs']);
$this->app->log("Added cron programs to jailkit chroot", LOGLEVEL_DEBUG); $this->app->log("Added cron programs to jailkit chroot", LOGLEVEL_DEBUG);
} }
......
...@@ -273,7 +273,7 @@ class shelluser_jailkit_plugin { ...@@ -273,7 +273,7 @@ class shelluser_jailkit_plugin {
//check if the chroot environment is created yet if not create it with a list of program sections from the config //check if the chroot environment is created yet if not create it with a list of program sections from the config
if (!is_dir($this->data['new']['dir'].'/etc/jailkit')) if (!is_dir($this->data['new']['dir'].'/etc/jailkit'))
{ {
$app->system->create_jailkit_chroot($this->data['new']['dir'], preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_app_sections'])); $app->system->create_jailkit_chroot($this->data['new']['dir'], $this->jailkit_config['jailkit_chroot_app_sections']);
$this->app->log("Added jailkit chroot", LOGLEVEL_DEBUG); $this->app->log("Added jailkit chroot", LOGLEVEL_DEBUG);
$this->_add_jailkit_programs(); $this->_add_jailkit_programs();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment