From 4ab3e7a53a15cf0bc311179994f339760365dd97 Mon Sep 17 00:00:00 2001 From: "fupan.lfp" Date: Fri, 16 Jul 2021 11:48:16 +0800 Subject: [PATCH] runtime: fix the issue of create new socket with abstract address For the abstract socket adress there's no need to chmod the address's file, cause the file didn't exist actually. Signed-off-by: Fupan Li --- runtime/v2/shim/util_unix.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/runtime/v2/shim/util_unix.go b/runtime/v2/shim/util_unix.go index f956b0986..5bd6facfe 100644 --- a/runtime/v2/shim/util_unix.go +++ b/runtime/v2/shim/util_unix.go @@ -90,7 +90,10 @@ func NewSocket(address string) (*net.UnixListener, error) { sock = socket(address) path = sock.path() ) - if !sock.isAbstract() { + + isAbstract := sock.isAbstract() + + if !isAbstract { if err := os.MkdirAll(filepath.Dir(path), 0600); err != nil { return nil, errors.Wrapf(err, "%s", path) } @@ -99,10 +102,13 @@ func NewSocket(address string) (*net.UnixListener, error) { if err != nil { return nil, err } - if err := os.Chmod(path, 0600); err != nil { - os.Remove(sock.path()) - l.Close() - return nil, err + + if !isAbstract { + if err := os.Chmod(path, 0600); err != nil { + os.Remove(sock.path()) + l.Close() + return nil, err + } } return l.(*net.UnixListener), nil }