Skip to content

Commit 16c5fc7

Browse files
etungstenk8s-infra-cherrypick-robot
authored andcommitted
Ensure /run/containerd is created with correct perms
There are a couple directories that get created under the default state directory ("/run/containerd") even when containerd is configured to use a different location for its state directory. Create the default state directory even if containerd is configured to use a different state directory location. This ensure pkg/shim and pkg/fifo won't create the default state directory with incorrect permissions when calling os.MkdirAll for their respective subdirectories. Signed-off-by: Erikson Tung <[email protected]>
1 parent 97a5245 commit 16c5fc7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

services/server/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ func CreateTopLevelDirectories(config *srvconfig.Config) error {
8484
if err := sys.MkdirAllWithACL(config.State, 0711); err != nil {
8585
return err
8686
}
87+
if config.State != defaults.DefaultStateDir {
88+
// XXX: socketRoot in pkg/shim is hard-coded to the default state directory.
89+
// See https://github.com/containerd/containerd/issues/10502#issuecomment-2249268582 for why it's set up that way.
90+
// The default fifo directory in pkg/cio is also configured separately and defaults to the default state directory instead of the configured state directory.
91+
// Make sure the default state directory is created with the correct permissions.
92+
if err := sys.MkdirAllWithACL(defaults.DefaultStateDir, 0o711); err != nil {
93+
return err
94+
}
95+
}
8796

8897
if config.TempDir != "" {
8998
if err := sys.MkdirAllWithACL(config.TempDir, 0711); err != nil {

0 commit comments

Comments
 (0)