Skip to content

Commit 242d5e5

Browse files
authored
Merge pull request #192 from ellemouton/fixMacaroonPathParsing
config+frcli: fix macaroon & tls cert path parsing
2 parents f9fec2f + 951cc86 commit 242d5e5

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

cmd/frcli/utils.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,23 @@ func extractPathArgs(ctx *cli.Context) (string, string, error) {
159159
if faradayDir != faraday.FaradayDirBase ||
160160
networkStr != faraday.DefaultNetwork {
161161

162-
tlsCertPath = filepath.Join(
163-
faradayDir, networkStr, faraday.DefaultTLSCertFilename,
164-
)
165-
macPath = filepath.Join(
166-
faradayDir, networkStr, faraday.DefaultMacaroonFilename,
167-
)
162+
// Only overwrite the tls cert path if the user has not
163+
// explicitly defined it.
164+
if !ctx.GlobalIsSet(tlsCertFlag.Name) {
165+
tlsCertPath = filepath.Join(
166+
faradayDir, networkStr,
167+
faraday.DefaultTLSCertFilename,
168+
)
169+
}
170+
171+
// Only overwrite the macaroon path if the user has not
172+
// explicitly defined it.
173+
if !ctx.GlobalIsSet(macaroonPathFlag.Name) {
174+
macPath = filepath.Join(
175+
faradayDir, networkStr,
176+
faraday.DefaultMacaroonFilename,
177+
)
178+
}
168179
}
169180

170181
return tlsCertPath, macPath, nil

config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ func ValidateConfig(config *Config) error {
192192
config.TLSKeyPath = lncfg.CleanAndExpandPath(config.TLSKeyPath)
193193
config.MacaroonPath = lncfg.CleanAndExpandPath(config.MacaroonPath)
194194

195+
// Before adding the network namespace below, check if the user has
196+
// overwritten the default faraday directory.
197+
faradayDirSet := config.FaradayDir != FaradayDirBase
198+
195199
// Append the network type to faraday directory so they are "namespaced"
196200
// per network.
197201
config.FaradayDir = filepath.Join(config.FaradayDir, config.Network)
@@ -205,7 +209,6 @@ func ValidateConfig(config *Config) error {
205209
// values, make sure that they are not set when faraday dir is set. We
206210
// fail hard here rather than overwriting and potentially confusing the
207211
// user.
208-
faradayDirSet := config.FaradayDir != FaradayDirBase
209212
if faradayDirSet {
210213
tlsCertPathSet := config.TLSCertPath != DefaultTLSCertPath
211214
tlsKeyPathSet := config.TLSKeyPath != DefaultTLSKeyPath

0 commit comments

Comments
 (0)