From 8662c5bdf4ab42b5db5af61ba1719c3eb4c03dee Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Wed, 30 Jan 2013 11:34:49 -0500
Subject: [PATCH] - Fixed: FS#2621 - OS update
---
server/plugins-available/apache2_plugin.inc.php | 45 +++++++++++++++++++++++++++++++++++----------
1 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index f8fdfcc..42b9c63 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -121,8 +121,14 @@
$this->ssl_certificate_changed = true;
//* Rename files if they exist
- if(file_exists($key_file)) $app->system->rename($key_file,$key_file.'.bak');
- if(file_exists($key_file2)) $app->system->rename($key_file2,$key_file2.'.bak');
+ if(file_exists($key_file)){
+ $app->system->rename($key_file,$key_file.'.bak');
+ $app->system->chmod($key_file.'.bak',0400);
+ }
+ if(file_exists($key_file2)){
+ $app->system->rename($key_file2,$key_file2.'.bak');
+ $app->system->chmod($key_file2.'.bak',0400);
+ }
if(file_exists($csr_file)) $app->system->rename($csr_file,$csr_file.'.bak');
if(file_exists($crt_file)) $app->system->rename($crt_file,$crt_file.'.bak');
@@ -165,11 +171,15 @@
$rand_file = escapeshellcmd($rand_file);
$key_file = escapeshellcmd($key_file);
+ if(substr($domain, 0, 2) == '*.' && strpos($key_file, '/ssl/\*.') != false) $key_file = str_replace('/ssl/\*.', '/ssl/*.', $key_file); // wildcard certificate
$key_file2 = escapeshellcmd($key_file2);
+ if(substr($domain, 0, 2) == '*.' && strpos($key_file2, '/ssl/\*.') != false) $key_file2 = str_replace('/ssl/\*.', '/ssl/*.', $key_file2); // wildcard certificate
$ssl_days = 3650;
$csr_file = escapeshellcmd($csr_file);
+ if(substr($domain, 0, 2) == '*.' && strpos($csr_file, '/ssl/\*.') != false) $csr_file = str_replace('/ssl/\*.', '/ssl/*.', $csr_file); // wildcard certificate
$config_file = escapeshellcmd($ssl_cnf_file);
$crt_file = escapeshellcmd($crt_file);
+ if(substr($domain, 0, 2) == '*.' && strpos($crt_file, '/ssl/\*.') != false) $crt_file = str_replace('/ssl/\*.', '/ssl/*.', $crt_file); // wildcard certificate
if(is_file($ssl_cnf_file) && !is_link($ssl_cnf_file)) {
@@ -190,6 +200,7 @@
}
+ $app->system->chmod($key_file,0400);
$app->system->chmod($key_file2,0400);
@$app->system->unlink($config_file);
@$app->system->unlink($rand_file);
@@ -216,8 +227,14 @@
$bundle_file = $ssl_dir.'/'.$domain.".bundle";
//* Backup files
- if(file_exists($key_file)) $app->system->copy($key_file,$key_file.'~');
- if(file_exists($key_file2)) $app->system->copy($key_file2,$key_file2.'~');
+ if(file_exists($key_file)){
+ $app->system->copy($key_file,$key_file.'~');
+ $app->system->chmod($key_file.'~',0400);
+ }
+ if(file_exists($key_file2)){
+ $app->system->copy($key_file2,$key_file2.'~');
+ $app->system->chmod($key_file2.'~',0400);
+ }
if(file_exists($csr_file)) $app->system->copy($csr_file,$csr_file.'~');
if(file_exists($crt_file)) $app->system->copy($crt_file,$crt_file.'~');
if(file_exists($bundle_file)) $app->system->copy($bundle_file,$bundle_file.'~');
@@ -415,14 +432,16 @@
//* Check if there is already some data in the new docroot and rename it as we need a clean path to move the existing site to the new path
if(@is_dir($data['new']['document_root'])) {
- $app->system->rename($data['new']['document_root'],$data['new']['document_root'].'_bak_'.date('Y_m_d'));
- $app->log('Renaming existing directory in new docroot location. mv '.$data['new']['document_root'].' '.$data['new']['document_root'].'_bak_'.date('Y_m_d'),LOGLEVEL_DEBUG);
+ $app->system->web_folder_protection($data['new']['document_root'],false);
+ $app->system->rename($data['new']['document_root'],$data['new']['document_root'].'_bak_'.date('Y_m_d_H_i_s'));
+ $app->log('Renaming existing directory in new docroot location. mv '.$data['new']['document_root'].' '.$data['new']['document_root'].'_bak_'.date('Y_m_d_H_i_s'),LOGLEVEL_DEBUG);
}
//* Create new base directory, if it does not exist yet
if(!is_dir($new_dir)) $app->system->mkdirpath($new_dir);
- //exec('mv '.$data['old']['document_root'].' '.$new_dir);
- $app->system->rename($data['old']['document_root'],$new_dir);
+ $app->system->web_folder_protection($data['old']['document_root'],false);
+ exec('mv '.escapeshellarg($data['old']['document_root']).' '.escapeshellarg($new_dir));
+ //$app->system->rename($data['old']['document_root'],$new_dir);
$app->log('Moving site to new document root: mv '.$data['old']['document_root'].' '.$new_dir,LOGLEVEL_DEBUG);
// Handle the change in php_open_basedir
@@ -1450,8 +1469,14 @@
$bundle_file = $ssl_dir.'/'.$domain.'.bundle';
//* Backup the files that might have caused the error
- if(is_file($key_file)) $app->system->copy($key_file,$key_file.'.err');
- if(is_file($key_file2)) $app->system->copy($key_file2,$key_file2.'.err');
+ if(is_file($key_file)){
+ $app->system->copy($key_file,$key_file.'.err');
+ $app->system->chmod($key_file.'.err',0400);
+ }
+ if(is_file($key_file2)){
+ $app->system->copy($key_file2,$key_file2.'.err');
+ $app->system->chmod($key_file2.'.err',0400);
+ }
if(is_file($csr_file)) $app->system->copy($csr_file,$csr_file.'.err');
if(is_file($crt_file)) $app->system->copy($crt_file,$crt_file.'.err');
if(is_file($bundle_file)) $app->system->copy($bundle_file,$bundle_file.'.err');
--
Gitblit v1.9.1