From 95398d3b658e9bb51dce4367486302d9d9c9646e Mon Sep 17 00:00:00 2001 From: Louis Ruch Date: Tue, 23 May 2023 14:27:04 -0700 Subject: [PATCH] fix(dev): Fix panic in controller-only dev mode panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0xb8 pc=0x16626b0] goroutine 1 [running]: github.com/hashicorp/boundary/internal/cmd/commands/dev.(*Command).Run(0xc000b90000, {0xc00003e110, 0x1, 0x1}) github.com/hashicorp/boundary/internal/cmd/commands/dev/dev.go:484 +0x490 github.com/mitchellh/cli.(*CLI).Run(0xc0003323c0) github.com/mitchellh/cli@v1.1.5/cli.go:262 +0x5f8 github.com/hashicorp/boundary/internal/cmd.RunCustom({0xc00003e100?, 0x60?, 0x0?}, 0x0?) github.com/hashicorp/boundary/internal/cmd/main.go:189 +0xa16 github.com/hashicorp/boundary/internal/cmd.Run(...) github.com/hashicorp/boundary/internal/cmd/main.go:95 main.main() github.com/hashicorp/boundary/cmd/boundary/main.go:16 +0xc7 --- internal/cmd/commands/dev/dev.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/internal/cmd/commands/dev/dev.go b/internal/cmd/commands/dev/dev.go index 35148ffc30..a4241a0600 100644 --- a/internal/cmd/commands/dev/dev.go +++ b/internal/cmd/commands/dev/dev.go @@ -479,18 +479,21 @@ func (c *Command) Run(args []string) int { c.DevUnprivilegedPassword = c.flagUnprivilegedPassword c.DevTargetDefaultPort = c.flagTargetDefaultPort c.Config.Plugins.ExecutionDir = c.flagPluginExecutionDir - c.Config.Worker.AuthStoragePath = c.flagWorkerAuthStorageDir - c.Config.Worker.RecordingStoragePath = c.flagWorkerRecordingStorageDir - if c.Config.Worker.RecordingStoragePath == "" { - // Create a temp dir for recording storage - const pattern = "recordingstorage" - c.Config.Worker.RecordingStoragePath, err = os.MkdirTemp("", pattern) - if err != nil { - c.UI.Error(fmt.Errorf("Error creating storage temp dir: %w", err).Error()) - return base.CommandCliError + if !c.flagControllerOnly { + c.Config.Worker.AuthStoragePath = c.flagWorkerAuthStorageDir + c.Config.Worker.RecordingStoragePath = c.flagWorkerRecordingStorageDir + + if c.Config.Worker.RecordingStoragePath == "" { + // Create a temp dir for recording storage + const pattern = "recordingstorage" + c.Config.Worker.RecordingStoragePath, err = os.MkdirTemp("", pattern) + if err != nil { + c.UI.Error(fmt.Errorf("Error creating storage temp dir: %w", err).Error()) + return base.CommandCliError + } + c.ShutdownFuncs = append(c.ShutdownFuncs, func() error { return os.RemoveAll(c.Config.Worker.RecordingStoragePath) }) } - c.ShutdownFuncs = append(c.ShutdownFuncs, func() error { return os.RemoveAll(c.Config.Worker.RecordingStoragePath) }) } if c.flagIdSuffix != "" {