From e942cfab4d189d1dd58e9f16ecb7f01e2adbc8c3 Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Mon, 02 Jan 2012 07:51:32 -0500 Subject: [PATCH] Fixed website permission settings, --- server/plugins-available/apache2_plugin.inc.php | 29 ++++++++++++++++++++++------- 1 files changed, 22 insertions(+), 7 deletions(-) diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index 7849aca..ffc9feb 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -553,7 +553,7 @@ //* If the security level is set to high - if($this->action == 'insert' && $data['new']['type'] == 'vhost') { + if(($this->action == 'insert' && $data['new']['type'] == 'vhost') or ($web_config['set_folder_permissions_on_update'] == 'y' && $data['new']['type'] == 'vhost')) { if($web_config['security_level'] == 20) { $this->_exec('chmod 751 '.escapeshellcmd($data['new']['document_root'])); @@ -585,8 +585,14 @@ //* add the Apache user to the client group $app->system->add_user_to_group($groupname, escapeshellcmd($web_config['user'])); - + + //* Chown all default directories $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'])); + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/cgi-bin')); + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/log')); + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/ssl')); + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/tmp')); + $this->_exec('chown -R '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/web')); /* * Workaround for jailkit: If jailkit is enabled for the site, the @@ -605,11 +611,20 @@ } else { $this->_exec('chmod 755 '.escapeshellcmd($data['new']['document_root'])); - $this->_exec('chmod 755 '.escapeshellcmd($data['new']['document_root'].'/*')); - $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root'])); - + $this->_exec('chmod 755 '.escapeshellcmd($data['new']['document_root'].'/cgi-bin')); + $this->_exec('chmod 755 '.escapeshellcmd($data['new']['document_root'].'/log')); + $this->_exec('chmod 755 '.escapeshellcmd($data['new']['document_root'].'/ssl')); + $this->_exec('chmod 755 '.escapeshellcmd($data['new']['document_root'].'/web')); + // make temp directory writable for Apache and the website users $this->_exec('chmod 777 '.escapeshellcmd($data['new']['document_root'].'/tmp')); + + $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root'])); + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/cgi-bin')); + $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root'].'/log')); + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/tmp')); + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/ssl')); + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'].'/web')); } } @@ -730,7 +745,7 @@ 'rewrite_target_ssl' => $rewrite_target_ssl); break; case '*': - $rewrite_rules[] = array( 'rewrite_domain' => $data['new']['domain'], + $rewrite_rules[] = array( 'rewrite_domain' => '(^|\.)'.$data['new']['domain'], 'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']', 'rewrite_target' => $rewrite_target, 'rewrite_target_ssl' => $rewrite_target_ssl); @@ -796,7 +811,7 @@ 'rewrite_target_ssl' => $rewrite_target_ssl); break; case '*': - $rewrite_rules[] = array( 'rewrite_domain' => $alias['domain'], + $rewrite_rules[] = array( 'rewrite_domain' => '(^|\.)'.$alias['domain'], 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':'['.$alias['redirect_type'].']', 'rewrite_target' => $rewrite_target, 'rewrite_target_ssl' => $rewrite_target_ssl); -- Gitblit v1.9.1