lnrpc+macaroon: skip subserver macaroons on stateless_init

This will prevent the subservers from writing macaroons to disk
when the stateless_init flag is set to true. It accomplishes
this by storing the StatelessInit value in the Macaroon Service.
This commit is contained in:
Graham Krizek
2020-10-06 17:23:42 +02:00
committed by Oliver Gugger
parent 0b9b7def15
commit 5aa0d26251
5 changed files with 32 additions and 39 deletions

View File

@@ -103,9 +103,12 @@ func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error) {
}
// Now that we know the full path of the signer macaroon, we can check
// to see if we need to create it or not.
// to see if we need to create it or not. If stateless_init is set
// then we don't write the macaroons.
macFilePath := cfg.SignerMacPath
if cfg.MacService != nil && !lnrpc.FileExists(macFilePath) {
if cfg.MacService != nil && !cfg.MacService.StatelessInit &&
!lnrpc.FileExists(macFilePath) {
log.Infof("Making macaroons for Signer RPC Server at: %v",
macFilePath)
@@ -125,7 +128,7 @@ func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error) {
}
err = ioutil.WriteFile(macFilePath, signerMacBytes, 0644)
if err != nil {
os.Remove(macFilePath)
_ = os.Remove(macFilePath)
return nil, nil, err
}
}