Default to 0600 when creating the custom settings file

The custom settings file will likely contain encryption keys and other 
sensitive data, so it's probably a good idea to tighten up the default 
permissions on it.
This commit is contained in:
Starbeamrainbowlabs 2019-07-16 18:08:39 +01:00
parent 952312fbd3
commit 1252d60af0
1 changed files with 9 additions and 3 deletions

View File

@ -12,9 +12,15 @@ const root_dir = path.dirname(process.argv[1]);
let filename_default = path.resolve(root_dir, "./settings.default.toml"),
filename_custom = path.resolve(root_dir, "../settings.toml");
if(!fs.existsSync(filename_custom))
fs.writeFileSync(filename_custom, `# Custom settings file. This file overrides server/settings.default.toml - refer there for examples of settings you can override.\n\n`);
if(!fs.existsSync(filename_custom)) {
fs.writeFileSync(
filename_custom,
`# Custom settings file. This file overrides server/settings.default.toml - refer there for examples of settings you can override.\n\n`, {
mode: 0o600
}
);
}
let settings = toml.parse(fs.readFileSync(filename_default, "utf-8")),
settings_override = toml.parse(fs.readFileSync(filename_custom, "utf-8"));