Commit 75c94aa1 authored by Éloïs's avatar Éloïs
Browse files

[fix] #1416

parent ec96572a
......@@ -112,8 +112,20 @@ export class CFSCore {
* @param content String content to write.
* @param deep Wether to make a deep write or not.
*/
async write(filePath: string, content: string, deep: boolean): Promise<void> {
return this.qfs.fsWrite(path.join(this.rootPath, filePath), content);
async write(
filePath: string,
content: string,
deep: boolean,
secureMode: boolean = false
): Promise<void> {
if (secureMode) {
return this.qfs.fsWriteSecure(
path.join(this.rootPath, filePath),
content
);
} else {
return this.qfs.fsWrite(path.join(this.rootPath, filePath), content);
}
}
/**
......
......@@ -50,6 +50,7 @@ export interface FileSystem {
fsUnlink(file: string): Promise<boolean>;
fsList(dir: string): Promise<string[]>;
fsWrite(file: string, content: string): Promise<void>;
fsWriteSecure(file: string, content: string): Promise<void>;
fsMakeDirectory(dir: string): Promise<void>;
fsRemoveTree(dir: string): Promise<void>;
fsStreamTo(file: string, iterator: IterableIterator<string>): Promise<void>;
......@@ -69,7 +70,6 @@ class QioFileSystem implements FileSystem {
async fsReadFile(file: string) {
return this.qio.read(file);
}
async fsUnlink(file: string) {
return this.qio.remove(file);
}
......@@ -85,6 +85,10 @@ class QioFileSystem implements FileSystem {
return this.qio.write(file, content);
}
fsWriteSecure(file: string, content: string): Promise<void> {
return this.qio.write(file, content, undefined, undefined, { mode: 0o640 });
}
async fsStreamTo(
file: string,
iterator: IterableIterator<string>
......
......@@ -152,7 +152,7 @@ export const KeypairDependency = {
// We save the key in a separate file
const keyring =
'pub: "' + conf.pair.pub + '"\n' + 'sec: "' + conf.pair.sec + '"';
await confDAL.coreFS.write("keyring.yml", keyring);
await confDAL.coreFS.write("keyring.yml", keyring, false, true);
// We never want to store salt, password or keypair in the conf.json file
delete conf.salt;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment