From 6b029af653ce96709aedea68b72c96b4765e9db8 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sun, 05 Jul 2009 07:39:20 -0400
Subject: [PATCH] Added security levels for apache.
---
server/plugins-available/apache2_plugin.inc.php | 40 ++++++++++++++++++++++++++++++++++++----
1 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 665a8dd..bfdc6bf 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -443,7 +443,7 @@
$username = escapeshellcmd($data["new"]["system_user"]);
if($data["new"]["system_user"] != '' && !$app->system->is_user($data["new"]["system_user"])) {
- exec("useradd -d ".escapeshellcmd($data["new"]["document_root"])." -g $groupname $username -s /bin/false");
+ exec("useradd -d ".escapeshellcmd($data["new"]["document_root"])." -g $groupname -G sshusers $username -s /bin/false");
$app->log("Adding the user: $username",LOGLEVEL_DEBUG);
}
@@ -459,7 +459,6 @@
exec("setquota -T -u $username 604800 604800 -a &> /dev/null");
}
-
if($this->action == 'insert') {
// Chown and chmod the directories below the document root
exec("chown -R $username:$groupname ".escapeshellcmd($data["new"]["document_root"]));
@@ -468,8 +467,40 @@
exec("chown root:root ".escapeshellcmd($data["new"]["document_root"]));
}
- // make temp direcory writable for the apache user and the website user
- exec("chmod 777 ".escapeshellcmd($data["new"]["document_root"]."/tmp"));
+
+
+ // If the security level is set to high
+ if($web_config['security_level'] == 20) {
+
+ exec("chmod 711 ".escapeshellcmd($data["new"]["document_root"]."/"));
+ exec("chmod 711 ".escapeshellcmd($data["new"]["document_root"]."/*"));
+ exec("chmod 710 ".escapeshellcmd($data["new"]["document_root"]."/web"));
+
+ //* Change the home directory and group of the website user
+ $command = 'usermod';
+ $command .= ' --groups sshusers,'.escapeshellcmd($web_config['group']);
+ $command .= ' '.escapeshellcmd($data["new"]["system_user"]);
+ exec($command);
+ $app->log("Modifying user: $command",LOGLEVEL_DEBUG);
+
+ // make temp direcory writable for the apache user and the website user
+ // exec("chmod 777 ".escapeshellcmd($data["new"]["document_root"]."/tmp"));
+ // If the security Level is set to medium
+ } else {
+
+ exec("chmod 755 ".escapeshellcmd($data["new"]["document_root"]."/"));
+ exec("chmod 755 ".escapeshellcmd($data["new"]["document_root"]."/*"));
+
+ //* Change the home directory and group of the website user
+ $command = 'usermod';
+ $command .= ' --groups sshusers ';
+ $command .= ' '.escapeshellcmd($data["new"]["system_user"]);
+ exec($command);
+ $app->log("Modifying user: $command",LOGLEVEL_DEBUG);
+
+ // make temp direcory writable for the apache user and the website user
+ exec("chmod 777 ".escapeshellcmd($data["new"]["document_root"]."/tmp"));
+ }
// Create the vhost config file
@@ -482,6 +513,7 @@
$vhost_data["web_document_root"] = $data["new"]["document_root"]."/web";
$vhost_data["web_document_root_www"] = $web_config["website_basedir"]."/".$data["new"]["domain"]."/web";
$vhost_data["web_basedir"] = $web_config["website_basedir"];
+ $vhost_data["security_level"] = $web_config["security_level"];
// Check if a SSL cert exists
$ssl_dir = $data["new"]["document_root"]."/ssl";
--
Gitblit v1.9.1