Skip to content

Commit

Permalink
Create UDS parent directories if not exists
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos G. Yedro <[email protected]>
  • Loading branch information
marcosy committed Apr 4, 2019
1 parent bcb99be commit cfefaec
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/agent/endpoints/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net"
"os"
"path/filepath"

sds_v2 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v2"
attestor "github.com/spiffe/spire/pkg/agent/attestor/workload"
Expand Down Expand Up @@ -89,6 +90,13 @@ func (e *endpoints) registerSecretDiscoveryService(server *grpc.Server) {
}

func (e *endpoints) createUDSListener() (net.Listener, error) {
// Create uds dir and parents if not exists
dir := filepath.Dir(e.c.BindAddr.String())
if err := os.MkdirAll(dir, 0755); err != nil {
return nil, err
}

// Remove uds if already exists
os.Remove(e.c.BindAddr.String())

l, err := net.Listen(e.c.BindAddr.Network(), e.c.BindAddr.String())
Expand Down

0 comments on commit cfefaec

Please sign in to comment.