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 <fupan.lfp@antgroup.com>
This commit is contained in:
parent
e830c5364c
commit
4ab3e7a53a
@ -90,7 +90,10 @@ func NewSocket(address string) (*net.UnixListener, error) {
|
|||||||
sock = socket(address)
|
sock = socket(address)
|
||||||
path = sock.path()
|
path = sock.path()
|
||||||
)
|
)
|
||||||
if !sock.isAbstract() {
|
|
||||||
|
isAbstract := sock.isAbstract()
|
||||||
|
|
||||||
|
if !isAbstract {
|
||||||
if err := os.MkdirAll(filepath.Dir(path), 0600); err != nil {
|
if err := os.MkdirAll(filepath.Dir(path), 0600); err != nil {
|
||||||
return nil, errors.Wrapf(err, "%s", path)
|
return nil, errors.Wrapf(err, "%s", path)
|
||||||
}
|
}
|
||||||
@ -99,10 +102,13 @@ func NewSocket(address string) (*net.UnixListener, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := os.Chmod(path, 0600); err != nil {
|
|
||||||
os.Remove(sock.path())
|
if !isAbstract {
|
||||||
l.Close()
|
if err := os.Chmod(path, 0600); err != nil {
|
||||||
return nil, err
|
os.Remove(sock.path())
|
||||||
|
l.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return l.(*net.UnixListener), nil
|
return l.(*net.UnixListener), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user