Load HTML as HTML, resolve relative endpoint URLs
[shpub.git] / src / shpub / Config.php
index 5da9c4a729b9d8fad77d7c2f239a1e10b354ec00..352ab99da68b8194b865e841fa2486a338762e70 100644 (file)
@@ -15,6 +15,7 @@ class Config
     protected function getConfigFilePath()
     {
         if (!isset($_SERVER['HOME'])) {
+            Log::err('Cannot determine home directory');
             return false;
         }
 
@@ -58,7 +59,7 @@ class Config
             }
             $str .= '[' . $hostName . "]\n";
             foreach ($host as $hostProp => $hostVal) {
-                if ($hostProp == 'cache') {
+                if ($hostProp == 'endpoints') {
                     continue;
                 }
                 if ($hostVal == '') {
@@ -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()