config perms
authorChristian Weiske <cweiske@cweiske.de>
Tue, 6 Sep 2016 14:22:38 +0000 (16:22 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 6 Sep 2016 14:22:38 +0000 (16:22 +0200)
src/shpub/Config.php

index 9a23705..044b150 100644 (file)
@@ -67,7 +67,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);
+        }
+        file_put_contents($cfgFilePath, $str);
+        //contains sensitive data; nobody else may read that
+        chmod($cfgFilePath, 0600);
     }
 
     public function getDefaultHost()