From c32e2ed5d180ddd3fbb739c41eeb24da71a26578 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Sun, 14 Aug 2022 10:04:55 +0200
Subject: [PATCH] Bugfix: replace /dev/null with system tmp-dir

---
 config-templates/config.php |  6 +++---
 src/SimpleSAML/Kernel.php   | 11 +++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/config-templates/config.php b/config-templates/config.php
index 8682dafd8..740a833ff 100644
--- a/config-templates/config.php
+++ b/config-templates/config.php
@@ -56,7 +56,8 @@ $config = [
     /*
      * The following settings are *filesystem paths* which define where
      * SimpleSAMLphp can find or write the following things:
-     * - 'loggingdir': Where to write logs.
+     * - 'loggingdir': Where to write logs. MUST be set to NULL when using a logging
+     *                 handler other than `file`.
      * - 'datadir': Storage of general data.
      * - 'tempdir': Saving temporary files. SimpleSAMLphp will attempt to create
      *   this directory if it doesn't exist.
@@ -323,7 +324,6 @@ $config = [
      */
 
 
-
     /**************************
      | LOGGING AND STATISTICS |
      **************************/
@@ -359,7 +359,7 @@ $config = [
      *
      * - %level: the log level (name or number depending on the handler used).
      *
-     * - %stat: if the log entry is intended for statistical purposes, it will print the string 'STAT ' (bear in mind
+-     * - %stat: if the log entry is intended for statistical purposes, it will print the string 'STAT ' (bear in mind
      *   the trailing space).
      *
      * - %trackid: the track ID, an identifier that allows you to track a single session.
diff --git a/src/SimpleSAML/Kernel.php b/src/SimpleSAML/Kernel.php
index 90dd4099d..0f25585fd 100644
--- a/src/SimpleSAML/Kernel.php
+++ b/src/SimpleSAML/Kernel.php
@@ -16,6 +16,10 @@ use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
 use Symfony\Component\HttpKernel\Kernel as BaseKernel;
 use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
 
+use function getenv;
+use function is_dir;
+use function sys_get_temp_dir;
+
 /**
  * A class to create the container and handle a given request.
  */
@@ -67,12 +71,7 @@ class Kernel extends BaseKernel
     {
         $configuration = Configuration::getInstance();
         $handler = $configuration->getString('logging.handler');
-
-        if ($handler === 'file') {
-            $loggingPath = $configuration->getString('loggingdir');
-        } else {
-            $loggingPath = '/dev/null';
-        }
+        $loggingPath = $configuration->getString('loggingdir', sys_get_temp_dir());
 
         $sysUtils = new System();
         if ($sysUtils->isAbsolutePath($loggingPath)) {
-- 
GitLab