From 003ce7d60d6b5d34282cc2f73f067b09f9ec3b73 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 01 Nov 2007 17:46:55 -0400
Subject: [PATCH] - Updated SQL dump so that the spamfilter policies are visible for clients. - Updated todo text
---
server/plugins-enabled/apache2_plugin.inc.php | 103 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 71 insertions(+), 32 deletions(-)
diff --git a/server/plugins-enabled/apache2_plugin.inc.php b/server/plugins-enabled/apache2_plugin.inc.php
index 1d4533e..2a634c8 100644
--- a/server/plugins-enabled/apache2_plugin.inc.php
+++ b/server/plugins-enabled/apache2_plugin.inc.php
@@ -33,6 +33,9 @@
var $plugin_name = 'apache2_plugin';
var $class_name = 'apache2_plugin';
+ // private variables
+ var $action = '';
+
/*
This function is called when the plugin is loaded
@@ -98,57 +101,68 @@
output_password = $ssl_password
[ req_distinguished_name ]
- C = $data[new][ssl_country]
- ST = $data[new][ssl_state]
- L = $data[new][ssl_locality]
- O = $data[new][ssl_organisation]
- OU = $data[new][ssl_organisation_unit]
+ C = ".$data['new']['ssl_country']."
+ ST = ".$data['new']['ssl_state']."
+ L = ".$data['new']['ssl_locality']."
+ O = ".$data['new']['ssl_organisation']."
+ OU = ".$data['new']['ssl_organisation_unit']."
CN = $domain
- emailAddress = webmatser@$data[new][domain]
+ emailAddress = webmatser@".$data['new']['domain']."
[ req_attributes ]
challengePassword = A challenge password";
$ssl_cnf_file = $ssl_dir."/openssl.conf";
- file_get_contents($ssl_cnf_file,$ssl_cnf);
+ file_put_contents($ssl_cnf_file,$ssl_cnf);
$rand_file = escapeshellcmd($rand_file);
$key_file = escapeshellcmd($key_file);
$key_file2 = escapeshellcmd($key_file2);
$ssl_days = 3650;
$csr_file = escapeshellcmd($csr_file);
- $config_file = escapeshellcmd($config_file);
- $crt_file escapeshellcmd($crt_file);
+ $config_file = escapeshellcmd($ssl_cnf_file);
+ $crt_file = escapeshellcmd($crt_file);
if(is_file($ssl_cnf_file)){
- exec("openssl genrsa -des3 -rand $rand_file \
- -passout pass:$ssl_password \
- -out $key_file 1024 \
- && openssl req -new -passin pass:$ssl_password \
- -passout pass:$ssl_password -key $key_file \
- -out $csr_file -days $ssl_days \
- -config $config_file \
- && openssl req -x509 -passin pass:$ssl_password \
- -passout pass:$ssl_password \
- -key $key_file -in $csr_file \
- -out $crt_file -days $ssl_days \
- -config $config_file \
- && openssl rsa -passin pass:$ssl_password \
- -in $key_file \
- -out $key_file2");
+ exec("openssl genrsa -des3 -rand $rand_file -passout pass:$ssl_password -out $key_file 1024 && openssl req -new -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -out $csr_file -days $ssl_days -config $config_file && openssl req -x509 -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -in $csr_file -out $crt_file -days $ssl_days -config $config_file && openssl rsa -passin pass:$ssl_password -in $key_file -out $key_file2");
+ $app->log("Creating SSL Cert for: $domain",LOGLEVEL_DEBUG);
}
exec("chmod 400 $key_file2");
- exec("rm -f $config_file");
- exec("rm -f $rand_file");
+ @unlink($config_file);
+ @unlink($rand_file);
$ssl_request = file_get_contents($csr_file);
$ssl_cert = file_get_contents($crt_file);
- $mod->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data["new"]["domain"]."'");
+ $app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data["new"]["domain"]."'");
+ $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'");
}
//* Save a SSL certificate to disk
if($data["new"]["ssl_action"] == 'save') {
-
+ $ssl_dir = $data["new"]["document_root"]."/ssl";
+ $domain = $data["new"]["domain"];
+ $csr_file = $ssl_dir.'/'.$domain.".csr";
+ $crt_file = $ssl_dir.'/'.$domain.".crt";
+ $bundle_file = $ssl_dir.'/'.$domain.".bundle";
+ file_put_contents($csr_file,$data["new"]["ssl_request"]);
+ file_put_contents($crt_file,$data["new"]["ssl_cert"]);
+ if(trim($data["new"]["ssl_bundle"]) != '') file_put_contents($bundle_file,$data["new"]["ssl_bundle"]);
+ $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'");
+ $app->log("Saving SSL Cert for: $domain",LOGLEVEL_DEBUG);
+ }
+
+ //* Delete a SSL certificate
+ if($data["new"]["ssl_action"] == 'del') {
+ $ssl_dir = $data["new"]["document_root"]."/ssl";
+ $domain = $data["new"]["domain"];
+ $csr_file = $ssl_dir.'/'.$domain.".csr";
+ $crt_file = $ssl_dir.'/'.$domain.".crt";
+ $bundle_file = $ssl_dir.'/'.$domain.".bundle";
+ unlink($csr_file);
+ unlink($crt_file);
+ unlink($bundle_file);
+ $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'");
+ $app->log("Deleting SSL Cert for: $domain",LOGLEVEL_DEBUG);
}
@@ -158,6 +172,7 @@
function insert($event_name,$data) {
global $app, $conf;
+ $this->action = 'insert';
// just run the update function
$this->update($event_name,$data);
@@ -168,6 +183,7 @@
function update($event_name,$data) {
global $app, $conf;
+ if($this->action != 'insert') $this->action = 'update';
if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
// This is not a vhost, so we need to update the parent record instead.
@@ -223,9 +239,14 @@
}
}
- // Copy the error pages
- $error_page_path = escapeshellcmd($data["new"]["web_document_root"])."/web/error/";
- exec("cp /usr/local/ispconfig/server/conf/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path);
+ if($this->action == 'insert') {
+ // Copy the error pages
+ $error_page_path = escapeshellcmd($data["new"]["document_root"])."/web/error/";
+ exec("cp /usr/local/ispconfig/server/conf/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path);
+
+ // copy the standard index page
+ exec("cp /usr/local/ispconfig/server/conf/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2)." ".escapeshellcmd($data["new"]["document_root"])."/web/index.html");
+ }
// Create group and user, if not exist
$app->uses("system");
@@ -267,6 +288,24 @@
$vhost_data = $data["new"];
$vhost_data["web_document_root"] = $data["new"]["document_root"]."/web";
+
+ // Check if a SSL cert exists
+ $ssl_dir = $data["new"]["document_root"]."/ssl";
+ $domain = $data["new"]["domain"];
+ $key_file = $ssl_dir.'/'.$domain.".key";
+ $crt_file = $ssl_dir.'/'.$domain.".crt";
+ $bundle_file = $ssl_dir.'/'.$domain.".bundle";
+
+ if($data["new"]["ssl"] == 'y' && @is_file($crt_file) && @is_file($key_file)) {
+ $vhost_data["ssl_enabled"] = 1;
+ $app->log("Enable SSL for: $domain",LOGLEVEL_DEBUG);
+ } else {
+ $vhost_data["ssl_enabled"] = 0;
+ $app->log("Disable SSL for: $domain",LOGLEVEL_DEBUG);
+ }
+
+ if(@is_file($bundle_file)) $vhost_data['has_bundle_cert'] = 1;
+
//$vhost_data["document_root"] = $data["new"]["document_root"]."/web";
$tpl->setVar($vhost_data);
@@ -357,7 +396,7 @@
if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
// create the symlinks, if not exist
if(is_link($tmp_symlink)) {
- unlink($tmp_symlink));
+ unlink($tmp_symlink);
$app->log("Removing symlink: ".$tmp_symlink,LOGLEVEL_DEBUG);
}
}
--
Gitblit v1.9.1