1
0
Fork 0

Make sure the global config file is only readable by the owner

pull/1238/merge
Jordi Boggiano 2012-10-21 18:01:53 +02:00
parent 7aab7c6297
commit c53729793b
2 changed files with 7 additions and 0 deletions

View File

@ -110,6 +110,7 @@ EOT
if ($input->getOption('global') && !$this->configFile->exists()) { if ($input->getOption('global') && !$this->configFile->exists()) {
touch($this->configFile->getPath()); touch($this->configFile->getPath());
$this->configFile->write(array('config' => new \ArrayObject)); $this->configFile->write(array('config' => new \ArrayObject));
chmod($this->configFile->getPath(), 0600);
} }
if (!$this->configFile->exists()) { if (!$this->configFile->exists()) {

View File

@ -70,6 +70,8 @@ class JsonConfigSource implements ConfigSourceInterface
} }
$manipulator = new JsonManipulator($contents); $manipulator = new JsonManipulator($contents);
$newFile = !$this->file->exists();
// try to update cleanly // try to update cleanly
if (call_user_func_array(array($manipulator, $method), $args)) { if (call_user_func_array(array($manipulator, $method), $args)) {
file_put_contents($this->file->getPath(), $manipulator->getContents()); file_put_contents($this->file->getPath(), $manipulator->getContents());
@ -80,5 +82,9 @@ class JsonConfigSource implements ConfigSourceInterface
call_user_func_array($fallback, $args); call_user_func_array($fallback, $args);
$this->file->write($config); $this->file->write($config);
} }
if ($newFile) {
chmod($this->file->getPath(), 0600);
}
} }
} }