Skip to content

Commit fb6c56e

Browse files
author
Till Brehm
committed
Added code to installer to apply updates to the security_settings.ini
1 parent e23c47d commit fb6c56e

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

install/dist/lib/fedora.lib.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,9 +833,30 @@ public function install_ispconfig()
833833
$command = "cp -rf ../server $install_dir";
834834
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
835835

836+
//* Make a backup of the security settings
837+
if(is_file('/usr/local/ispconfig/security/security_settings.ini')) copy('/usr/local/ispconfig/security/security_settings.ini','/usr/local/ispconfig/security/security_settings.ini~');
838+
836839
//* copy the ISPConfig security part
837840
$command = 'cp -rf ../security '.$install_dir;
838841
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
842+
843+
//* Apply changed security_settings.ini values to new security_settings.ini file
844+
if(is_file('/usr/local/ispconfig/security/security_settings.ini~')) {
845+
$security_settings_old = ini_to_array(file_get_contents('/usr/local/ispconfig/security/security_settings.ini~'));
846+
$security_settings_new = ini_to_array(file_get_contents('/usr/local/ispconfig/security/security_settings.ini'));
847+
if(is_array($security_settings_new) && is_array($security_settings_old)) {
848+
foreach($security_settings_new as $section => $sval) {
849+
if(is_array($sval)) {
850+
foreach($sval as $key => $val) {
851+
if(isset($security_settings_old[$section]) && isset($security_settings_old[$section][$key])) {
852+
$security_settings_new[$section][$key] = $security_settings_old[$section][$key];
853+
}
854+
}
855+
}
856+
}
857+
file_put_contents('/usr/local/ispconfig/security/security_settings.ini',array_to_ini($security_settings_new));
858+
}
859+
}
839860

840861
//* Create a symlink, so ISPConfig is accessible via web
841862
// Replaced by a separate vhost definition for port 8080

install/dist/lib/gentoo.lib.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,30 @@ public function install_ispconfig()
749749
$command = "cp -rf ../server $install_dir";
750750
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
751751

752+
//* Make a backup of the security settings
753+
if(is_file('/usr/local/ispconfig/security/security_settings.ini')) copy('/usr/local/ispconfig/security/security_settings.ini','/usr/local/ispconfig/security/security_settings.ini~');
754+
752755
//* copy the ISPConfig security part
753756
$command = 'cp -rf ../security '.$install_dir;
754757
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
758+
759+
//* Apply changed security_settings.ini values to new security_settings.ini file
760+
if(is_file('/usr/local/ispconfig/security/security_settings.ini~')) {
761+
$security_settings_old = ini_to_array(file_get_contents('/usr/local/ispconfig/security/security_settings.ini~'));
762+
$security_settings_new = ini_to_array(file_get_contents('/usr/local/ispconfig/security/security_settings.ini'));
763+
if(is_array($security_settings_new) && is_array($security_settings_old)) {
764+
foreach($security_settings_new as $section => $sval) {
765+
if(is_array($sval)) {
766+
foreach($sval as $key => $val) {
767+
if(isset($security_settings_old[$section]) && isset($security_settings_old[$section][$key])) {
768+
$security_settings_new[$section][$key] = $security_settings_old[$section][$key];
769+
}
770+
}
771+
}
772+
}
773+
file_put_contents('/usr/local/ispconfig/security/security_settings.ini',array_to_ini($security_settings_new));
774+
}
775+
}
755776

756777

757778
//* Create the config file for ISPConfig interface

install/dist/lib/opensuse.lib.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,9 +905,30 @@ public function install_ispconfig()
905905
$command = "cp -rf ../server $install_dir";
906906
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
907907

908+
//* Make a backup of the security settings
909+
if(is_file('/usr/local/ispconfig/security/security_settings.ini')) copy('/usr/local/ispconfig/security/security_settings.ini','/usr/local/ispconfig/security/security_settings.ini~');
910+
908911
//* copy the ISPConfig security part
909912
$command = 'cp -rf ../security '.$install_dir;
910913
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
914+
915+
//* Apply changed security_settings.ini values to new security_settings.ini file
916+
if(is_file('/usr/local/ispconfig/security/security_settings.ini~')) {
917+
$security_settings_old = ini_to_array(file_get_contents('/usr/local/ispconfig/security/security_settings.ini~'));
918+
$security_settings_new = ini_to_array(file_get_contents('/usr/local/ispconfig/security/security_settings.ini'));
919+
if(is_array($security_settings_new) && is_array($security_settings_old)) {
920+
foreach($security_settings_new as $section => $sval) {
921+
if(is_array($sval)) {
922+
foreach($sval as $key => $val) {
923+
if(isset($security_settings_old[$section]) && isset($security_settings_old[$section][$key])) {
924+
$security_settings_new[$section][$key] = $security_settings_old[$section][$key];
925+
}
926+
}
927+
}
928+
}
929+
file_put_contents('/usr/local/ispconfig/security/security_settings.ini',array_to_ini($security_settings_new));
930+
}
931+
}
911932

912933
//* Create a symlink, so ISPConfig is accessible via web
913934
// Replaced by a separate vhost definition for port 8080

install/lib/installer_base.lib.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,9 +1745,30 @@ public function install_ispconfig() {
17451745
$command = 'cp -rf ../server '.$install_dir;
17461746
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
17471747

1748+
//* Make a backup of the security settings
1749+
if(is_file('/usr/local/ispconfig/security/security_settings.ini')) copy('/usr/local/ispconfig/security/security_settings.ini','/usr/local/ispconfig/security/security_settings.ini~');
1750+
17481751
//* copy the ISPConfig security part
17491752
$command = 'cp -rf ../security '.$install_dir;
17501753
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
1754+
1755+
//* Apply changed security_settings.ini values to new security_settings.ini file
1756+
if(is_file('/usr/local/ispconfig/security/security_settings.ini~')) {
1757+
$security_settings_old = ini_to_array(file_get_contents('/usr/local/ispconfig/security/security_settings.ini~'));
1758+
$security_settings_new = ini_to_array(file_get_contents('/usr/local/ispconfig/security/security_settings.ini'));
1759+
if(is_array($security_settings_new) && is_array($security_settings_old)) {
1760+
foreach($security_settings_new as $section => $sval) {
1761+
if(is_array($sval)) {
1762+
foreach($sval as $key => $val) {
1763+
if(isset($security_settings_old[$section]) && isset($security_settings_old[$section][$key])) {
1764+
$security_settings_new[$section][$key] = $security_settings_old[$section][$key];
1765+
}
1766+
}
1767+
}
1768+
}
1769+
file_put_contents('/usr/local/ispconfig/security/security_settings.ini',array_to_ini($security_settings_new));
1770+
}
1771+
}
17511772

17521773
//* Create a symlink, so ISPConfig is accessible via web
17531774
// Replaced by a separate vhost definition for port 8080

0 commit comments

Comments
 (0)