diff --git a/cmd/containerd/main_unix.go b/cmd/containerd/main_unix.go index 6aa5626d2..74274f211 100644 --- a/cmd/containerd/main_unix.go +++ b/cmd/containerd/main_unix.go @@ -35,6 +35,12 @@ func platformInit(context *cli.Context) error { return err } } + if err := os.MkdirAll(conf.State, 0750); err != nil { + return err + } + if err := os.Chown(conf.State, conf.GRPC.Uid, conf.GRPC.Gid); err != nil { + return err + } return nil } diff --git a/sys/socket_unix.go b/sys/socket_unix.go index e5f2ba6c1..cd361c25e 100644 --- a/sys/socket_unix.go +++ b/sys/socket_unix.go @@ -28,6 +28,11 @@ func GetLocalListener(path string, uid, gid int) (net.Listener, error) { return l, err } + if err := os.Chmod(path, 0660); err != nil { + l.Close() + return nil, err + } + if err := os.Chown(path, uid, gid); err != nil { l.Close() return nil, err