Skip to content
Snippets Groups Projects
Commit 330ca261 authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'fix/1416' into dev

parents ec96572a 75c94aa1
No related branches found
No related tags found
No related merge requests found
......@@ -112,9 +112,21 @@ 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> {
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);
}
}
/**
* REMOVE operation of CFS. Set given file as removed. Logical deletion since physical won't work due to the algorithm of CFS.
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment