From ee8385467bfcc862a9e9cfc88666a99eea9a848a Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 3 Feb 2023 13:59:12 +0100 Subject: [PATCH] add fallback to system-hostname for faulty http-clients not setting 'Host' in the request Signed-off-by: Michael Kaufmann --- lib/Froxlor/UI/Panel/UI.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Froxlor/UI/Panel/UI.php b/lib/Froxlor/UI/Panel/UI.php index d7fc0d25..238baa93 100644 --- a/lib/Froxlor/UI/Panel/UI.php +++ b/lib/Froxlor/UI/Panel/UI.php @@ -92,6 +92,17 @@ class UI */ public static function sendHeaders() { + if (empty($_SERVER['HTTP_HOST'])) { + if (!self::$install_mode) { + // fallback to set hostname in settings + $_SERVER['HTTP_HOST'] = Settings::Get('system.hostname'); + } else { + // bad request + http_response_code(400); + exit(); + } + } + session_set_cookie_params([ 'lifetime' => self::$install_mode ? 7200 : 600, // will be renewed based on settings in lib/init.php 'path' => '/',