From 9ceff3c13b9dbace5b4ee9acae2b76c8611fc603 Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Wed, 26 Jun 2019 15:44:08 +0200
Subject: [PATCH] LE Renewal issue on systems that use the relative symlink
 option for websites, fixes #5326

---
 server/lib/classes/letsencrypt.inc.php | 24 ++++++------------------
 server/lib/classes/system.inc.php      |  2 +-
 2 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/server/lib/classes/letsencrypt.inc.php b/server/lib/classes/letsencrypt.inc.php
index ea1e745a77..583e1c25bb 100644
--- a/server/lib/classes/letsencrypt.inc.php
+++ b/server/lib/classes/letsencrypt.inc.php
@@ -388,12 +388,8 @@ class letsencrypt {
 				$app->system->unlink($key_file);
 			}
 
-			if ($web_config["website_symlinks_rel"] == 'y') {
-				$app->system->create_relative_link(escapeshellcmd($key_tmp_file), escapeshellcmd($key_file));
-			} else {
-				if(@is_link($key_file)) $app->system->unlink($key_file);
-				if(@file_exists($key_tmp_file)) exec("ln -s ".escapeshellcmd($key_tmp_file)." ".escapeshellcmd($key_file));
-			}
+			if(@is_link($key_file)) $app->system->unlink($key_file);
+			if(@file_exists($key_tmp_file)) exec("ln -s ".escapeshellcmd($key_tmp_file)." ".escapeshellcmd($key_file));
 
 			if(is_file($crt_file)) {
 				$app->system->copy($crt_file, $crt_file.'.old.'.$date);
@@ -401,12 +397,8 @@ class letsencrypt {
 				$app->system->unlink($crt_file);
 			}
 
-			if($web_config["website_symlinks_rel"] == 'y') {
-				$app->system->create_relative_link(escapeshellcmd($crt_tmp_file), escapeshellcmd($crt_file));
-			} else {
-				if(@is_link($crt_file)) $app->system->unlink($crt_file);
-				if(@file_exists($crt_tmp_file))exec("ln -s ".escapeshellcmd($crt_tmp_file)." ".escapeshellcmd($crt_file));
-			}
+			if(@is_link($crt_file)) $app->system->unlink($crt_file);
+			if(@file_exists($crt_tmp_file))exec("ln -s ".escapeshellcmd($crt_tmp_file)." ".escapeshellcmd($crt_file));
 
 			if(is_file($bundle_file)) {
 				$app->system->copy($bundle_file, $bundle_file.'.old.'.$date);
@@ -414,12 +406,8 @@ class letsencrypt {
 				$app->system->unlink($bundle_file);
 			}
 
-			if($web_config["website_symlinks_rel"] == 'y') {
-				$app->system->create_relative_link(escapeshellcmd($bundle_tmp_file), escapeshellcmd($bundle_file));
-			} else {
-				if(@is_link($bundle_file)) $app->system->unlink($bundle_file);
-				if(@file_exists($bundle_tmp_file)) exec("ln -s ".escapeshellcmd($bundle_tmp_file)." ".escapeshellcmd($bundle_file));
-			}
+			if(@is_link($bundle_file)) $app->system->unlink($bundle_file);
+			if(@file_exists($bundle_tmp_file)) exec("ln -s ".escapeshellcmd($bundle_tmp_file)." ".escapeshellcmd($bundle_file));
 			
 			return true;
 		} else {
diff --git a/server/lib/classes/system.inc.php b/server/lib/classes/system.inc.php
index f4d94743a1..5c277ada1a 100644
--- a/server/lib/classes/system.inc.php
+++ b/server/lib/classes/system.inc.php
@@ -918,7 +918,7 @@ class system{
 
 		// Add ($cnt_to-1) number of "../" elements to left side of $cfrom
 		for ($c = 0; $c < (count($a2)-1); $c++) { $cfrom = '../'.$cfrom; }
-		if(strstr($to,'/etc/letsencrypt/archive/')) $to = str_replace('/etc/letsencrypt/archive/','/etc/letsencrypt/live/',$to);
+		//if(strstr($to,'/etc/letsencrypt/archive/')) $to = str_replace('/etc/letsencrypt/archive/','/etc/letsencrypt/live/',$to);
 
 		return symlink($cfrom, $to);
 	}
-- 
GitLab