Rename darwin-kubelet to containerd
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
parent
d1564fec5b
commit
3a9044f240
@ -26,6 +26,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@ -87,15 +88,20 @@ func AnonReconnectDialer(address string, timeout time.Duration) (net.Conn, error
|
|||||||
// NewSocket returns a new socket
|
// NewSocket returns a new socket
|
||||||
func NewSocket(address string) (*net.UnixListener, error) {
|
func NewSocket(address string) (*net.UnixListener, error) {
|
||||||
var (
|
var (
|
||||||
sock = socket(address)
|
sock = socket(address)
|
||||||
path = sock.path()
|
path = sock.path()
|
||||||
|
isAbstract = sock.isAbstract()
|
||||||
|
perm = os.FileMode(0600)
|
||||||
)
|
)
|
||||||
|
|
||||||
isAbstract := sock.isAbstract()
|
// Darwin needs +x to access socket, otherwise it'll fail with "bind: permission denied" when running as non-root.
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
perm = 0700
|
||||||
|
}
|
||||||
|
|
||||||
if !isAbstract {
|
if !isAbstract {
|
||||||
if err := os.MkdirAll(filepath.Dir(path), 0600); err != nil {
|
if err := os.MkdirAll(filepath.Dir(path), perm); err != nil {
|
||||||
return nil, fmt.Errorf("%s: %w", path, err)
|
return nil, fmt.Errorf("mkdir failed for %s: %w", path, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
l, err := net.Listen("unix", path)
|
l, err := net.Listen("unix", path)
|
||||||
@ -104,12 +110,13 @@ func NewSocket(address string) (*net.UnixListener, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !isAbstract {
|
if !isAbstract {
|
||||||
if err := os.Chmod(path, 0600); err != nil {
|
if err := os.Chmod(path, perm); err != nil {
|
||||||
os.Remove(sock.path())
|
os.Remove(sock.path())
|
||||||
l.Close()
|
l.Close()
|
||||||
return nil, err
|
return nil, fmt.Errorf("chmod failed for %s: %w", path, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return l.(*net.UnixListener), nil
|
return l.(*net.UnixListener), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user