Skip to content

Commit 551ac06

Browse files
committed
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 2ddd3db commit 551ac06

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/containerd/server/server.go

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

92101
if config.TempDir != "" {
93102
if err := sys.MkdirAllWithACL(config.TempDir, 0o711); err != nil {

0 commit comments

Comments
 (0)