From c72b62038e3687b78ac2b4ef76aa4a3f262beeda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Pe=CC=81rez?= <jaime.perez@uninett.no> Date: Mon, 27 Jun 2016 17:45:53 +0200 Subject: [PATCH] bugfix: Resolve issue with incorrect self URL when using symlinks. Recent commits have introduced a new way to obtain the self URL, honouring whatever is specified in 'baseurlpath'. However, this new code breaks when accessing SimpleSAMLphp through a path containing symbolic links in the file system, since the base directory refers always to the real path while the $_SERVER contents reflect what the web server sees (symlinks included). We use realpath() to convert a path with symlinks to a canonical path that we can compare. --- lib/SimpleSAML/Utils/HTTP.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index 9de34eb6f..40304786d 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -722,7 +722,7 @@ class HTTP $url = self::getBaseURL(); $cfg = \SimpleSAML_Configuration::getInstance(); $baseDir = $cfg->getBaseDir(); - $rel_path = str_replace($baseDir.'www/', '', $_SERVER['SCRIPT_FILENAME']); + $rel_path = str_replace($baseDir.'www/', '', realpath($_SERVER['SCRIPT_FILENAME'])); $pos = strpos($_SERVER['REQUEST_URI'], $rel_path) + strlen($rel_path); return $url.$rel_path.substr($_SERVER['REQUEST_URI'], $pos); } -- GitLab