Load HTML as HTML, resolve relative endpoint URLs
[shpub.git] / src / shpub / Config.php
index 9a2370507b0ca9fb11e53e620e59792f818c6d80..352ab99da68b8194b865e841fa2486a338762e70 100644 (file)
@@ -15,6 +15,7 @@ class Config
     protected function getConfigFilePath()
     {
         if (!isset($_SERVER['HOME'])) {
+            Log::err('Cannot determine home directory');
             return false;
         }
 
@@ -67,7 +68,14 @@ class Config
                 $str .= $hostProp . '=' . $hostVal . "\n";
             }
         }
-        file_put_contents($this->getConfigFilePath(), $str);
+        $cfgFilePath = $this->getConfigFilePath();
+        $cfgDir = dirname($cfgFilePath);
+        if (!is_dir($cfgDir)) {
+            mkdir($cfgDir, 0700);
+        }
+        file_put_contents($cfgFilePath, $str);
+        //contains sensitive data; nobody else may read that
+        chmod($cfgFilePath, 0600);
     }
 
     public function getDefaultHost()