From c6b017ce9e85e7a27f65429ba41d3642bd6dc393 Mon Sep 17 00:00:00 2001
From: Maximilian Bosch <maximilian@mbosch.me>
Date: Tue, 2 Apr 2019 16:20:50 +0200
Subject: [PATCH] Don't resolve symlinks when trying to find INSTALL_PATH

Nix specific patch. This behavior breaks roundcube setups where plugins
are in a store path with symlinks to the actual source.

Also, __DIR__ resolves the symlink from `buildEnv`, so we do
$_SERVER['SCRIPT_FILENAME'] instead.
---
 bin/update.sh          | 2 +-
 public_html/index.php  | 1 +
 public_html/static.php | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/bin/update.sh b/bin/update.sh
index 4d8e829cc..3810aa2b9 100755
--- a/bin/update.sh
+++ b/bin/update.sh
@@ -19,7 +19,7 @@
  +-----------------------------------------------------------------------+
 */
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/');
+define('INSTALL_PATH', dirname(dirname($argv[0])).'/');
 
 require_once INSTALL_PATH . 'program/include/clisetup.php';
 
diff --git a/public_html/index.php b/public_html/index.php
index f8a0c4973..5fd1c57ec 100644
--- a/public_html/index.php
+++ b/public_html/index.php
@@ -36,6 +36,7 @@
  +-------------------------------------------------------------------------+
 */
 
+define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']) . '/../');
 // include environment
 require_once __DIR__ . '/../program/include/iniset.php';
 
diff --git a/public_html/static.php b/public_html/static.php
index f954ef365..a2cc3c24c 100644
--- a/public_html/static.php
+++ b/public_html/static.php
@@ -54,7 +54,7 @@ const ALLOWED_PATHS = [
     'skins/',
 ];
 
-define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/');
+define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']) . '/../');
 
 $path = validateStaticFile($_SERVER['PATH_INFO']);
 
-- 
2.51.2

