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

[fix] #1416

parent ec96572a
No related branches found
No related tags found
No related merge requests found
...@@ -112,9 +112,21 @@ export class CFSCore { ...@@ -112,9 +112,21 @@ export class CFSCore {
* @param content String content to write. * @param content String content to write.
* @param deep Wether to make a deep write or not. * @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); 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. * 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 { ...@@ -50,6 +50,7 @@ export interface FileSystem {
fsUnlink(file: string): Promise<boolean>; fsUnlink(file: string): Promise<boolean>;
fsList(dir: string): Promise<string[]>; fsList(dir: string): Promise<string[]>;
fsWrite(file: string, content: string): Promise<void>; fsWrite(file: string, content: string): Promise<void>;
fsWriteSecure(file: string, content: string): Promise<void>;
fsMakeDirectory(dir: string): Promise<void>; fsMakeDirectory(dir: string): Promise<void>;
fsRemoveTree(dir: string): Promise<void>; fsRemoveTree(dir: string): Promise<void>;
fsStreamTo(file: string, iterator: IterableIterator<string>): Promise<void>; fsStreamTo(file: string, iterator: IterableIterator<string>): Promise<void>;
...@@ -69,7 +70,6 @@ class QioFileSystem implements FileSystem { ...@@ -69,7 +70,6 @@ class QioFileSystem implements FileSystem {
async fsReadFile(file: string) { async fsReadFile(file: string) {
return this.qio.read(file); return this.qio.read(file);
} }
async fsUnlink(file: string) { async fsUnlink(file: string) {
return this.qio.remove(file); return this.qio.remove(file);
} }
...@@ -85,6 +85,10 @@ class QioFileSystem implements FileSystem { ...@@ -85,6 +85,10 @@ class QioFileSystem implements FileSystem {
return this.qio.write(file, content); 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( async fsStreamTo(
file: string, file: string,
iterator: IterableIterator<string> iterator: IterableIterator<string>
......
...@@ -152,7 +152,7 @@ export const KeypairDependency = { ...@@ -152,7 +152,7 @@ export const KeypairDependency = {
// We save the key in a separate file // We save the key in a separate file
const keyring = const keyring =
'pub: "' + conf.pair.pub + '"\n' + 'sec: "' + conf.pair.sec + '"'; '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 // We never want to store salt, password or keypair in the conf.json file
delete conf.salt; delete conf.salt;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment