Skip to content

Commit

Permalink
fix: write keystore cache with 600 permissions (#5622)
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Jun 9, 2023
1 parent 8463445 commit f245849
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/cli/src/cmds/validator/keymanager/keystoreCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Keystore} from "@chainsafe/bls-keystore";
import {SignerLocal, SignerType} from "@lodestar/validator";
import {fromHex, toHex} from "@lodestar/utils";
import {PointFormat} from "@chainsafe/bls/types";
import {writeFile600Perm} from "../../../util/file.js";
import {lockFilepath, unlockFilepath} from "../../../util/lockfile.js";
import {LocalKeystoreDefinition} from "./interface.js";

Expand Down Expand Up @@ -79,7 +80,7 @@ export async function writeKeystoreCache(
const keystore = await Keystore.create(password, secretKeyConcatenatedBytes, publicConcatenatedBytes, cacheFilepath);
if (!fs.existsSync(path.dirname(cacheFilepath))) fs.mkdirSync(path.dirname(cacheFilepath), {recursive: true});
lockFilepath(cacheFilepath);
fs.writeFileSync(cacheFilepath, keystore.stringify());
writeFile600Perm(cacheFilepath, keystore.stringify());
unlockFilepath(cacheFilepath);
}

Expand Down

0 comments on commit f245849

Please sign in to comment.