Skip to content

Commit

Permalink
Ensure directory exists for socket connection and Makefile additions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Lin committed Oct 30, 2019
1 parent 7d787a4 commit 86da73a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions pkg/dmsgpty/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net"
"net/rpc"
"os"
"path/filepath"
"sync"
"sync/atomic"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
}

0 comments on commit 86da73a

Please sign in to comment.