diff --git a/.gitignore b/.gitignore index 88fceb43b8..00797ac1df 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ pkg/visor/foo/ /*.json /*.sh /*.log +dmsgpty # Ignore backup go.mod after running '/ci_scripts/go_mod_replace.sh'. go.mod-e diff --git a/Makefile b/Makefile index 3b04be2254..81a6c82e94 100644 --- a/Makefile +++ b/Makefile @@ -104,7 +104,6 @@ bin: ## Build `skywire-visor`, `skywire-cli`, `hypervisor`, `SSH-cli` ${OPTS} go build ${BUILD_OPTS} -o ./SSH-cli ./cmd/therealssh-cli ${OPTS} go build ${BUILD_OPTS} -o ./dmsgpty ./cmd/dmsgpty - release: ## Build `skywire-visor`, `skywire-cli`, `hypervisor`, `SSH-cli` and apps without -race flag ${OPTS} go build -o ./skywire-visor ./cmd/skywire-visor ${OPTS} go build -o ./skywire-cli ./cmd/skywire-cli diff --git a/pkg/dmsgpty/host.go b/pkg/dmsgpty/host.go index f6f4f45690..b2401fbefb 100644 --- a/pkg/dmsgpty/host.go +++ b/pkg/dmsgpty/host.go @@ -7,6 +7,7 @@ import ( "net" "net/rpc" "os" + "path/filepath" "sync" "sync/atomic" @@ -126,6 +127,12 @@ func NewHostFromDmsgClient( if err != nil { return nil, err } + // Ensure directory exists for socket file (if unix connection). + if cliNet == "unix" { + if err := ensureDir(cliAddr); err != nil { + return nil, err + } + } cliL, err := net.Listen(cliNet, cliAddr) if err != nil { return nil, err @@ -293,3 +300,7 @@ func (h *Host) cleanup() { Debug("deleted unix file") } } + +func ensureDir(path string) error { + return os.MkdirAll(filepath.Dir(path), os.FileMode(0700)) +}