Skip to content

Commit bee2d62

Browse files
committed
multi: add withAllSubServers param to perms.NewManager
In this commit, a new withAllSubServers option is added to the perms.NewManager function. If its value is true, then all LND's subserver permissions will be added to the active permissions set regardless of whether LND was actually compiled with the necessary build tags. This is useful for Lit clients who perhaps can never know which sub-servers LND was compiled with and so want to assume that it was compiled with all.
1 parent 7d26d2d commit bee2d62

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

itest/litd_mode_integrated_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ func bakeSuperMacaroon(cfg *LitNodeConfig, readOnly bool) (string, error) {
974974
lndAdminCtx := macaroonContext(ctxt, lndAdminMacBytes)
975975
lndConn := lnrpc.NewLightningClient(rawConn)
976976

977-
permsMgr, err := perms.NewManager()
977+
permsMgr, err := perms.NewManager(false)
978978
if err != nil {
979979
return "", err
980980
}

perms/permissions.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,12 @@ type Manager struct {
135135
}
136136

137137
// NewManager constructs a new Manager instance and collects any of the fixed
138-
// permissions.
139-
func NewManager() (*Manager, error) {
138+
// permissions. If withAllSubServers is true, then all the LND sub-server
139+
// permissions will be added to the available permissions set regardless of
140+
// whether LND was compiled with those sub-servers. If it is not set, however,
141+
// then OnLNDBuildTags can be used to specify the exact sub-servers that LND
142+
// was compiled with and then only the corresponding permissions will be added.
143+
func NewManager(withAllSubServers bool) (*Manager, error) {
140144
permissions := make(map[subServerName]map[string][]bakery.Op)
141145
permissions[faradayPerms] = faraday.RequiredPermissions
142146
permissions[loopPerms] = loop.RequiredPermissions
@@ -166,8 +170,11 @@ func NewManager() (*Manager, error) {
166170

167171
// If this sub-server is one that we know is
168172
// automatically compiled in LND then we add it to our
169-
// map of active permissions.
170-
if lndAutoCompiledSubServers[name] {
173+
// map of active permissions. We also add the permission
174+
// if withAllSubServers is true.
175+
if withAllSubServers ||
176+
lndAutoCompiledSubServers[name] {
177+
171178
permissions[lndPerms][key] = value
172179
}
173180
}

terminal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func (g *LightningTerminal) Run() error {
212212
defer g.errQueue.Stop()
213213

214214
// Construct a new Manager.
215-
g.permsMgr, err = perms.NewManager()
215+
g.permsMgr, err = perms.NewManager(false)
216216
if err != nil {
217217
return fmt.Errorf("could not create permissions manager")
218218
}

0 commit comments

Comments
 (0)