Skip to content

Commit

Permalink
Add the CAP_CHOWN capability to support running rootless
Browse files Browse the repository at this point in the history
  • Loading branch information
EC2 Default User authored and mythri-garaga committed Oct 18, 2022
1 parent a4dc74b commit 0f00378
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ecs-init/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ const (
// For more information on setns, please read this manpage:
// http://man7.org/linux/man-pages/man2/setns.2.html
CapSysAdmin = "SYS_ADMIN"
// CapChown to start agent with CAP_CHOWN capability
// This is needed for the ECS Agent to invoke the chown call when
// configuring the files for configuration or administration.
// http://man7.org/linux/man-pages/man2/chown.2.html
CapChown = "CAP_CHOWN"
// DefaultCgroupMountpoint is the default mount point for the cgroup subsystem
DefaultCgroupMountpoint = "/sys/fs/cgroup"
// pluginSocketFilesDir specifies the location of UNIX domain socket files of
Expand Down
2 changes: 1 addition & 1 deletion ecs-init/docker/docker_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func createHostConfig(binds []string) *godocker.HostConfig {
// CapNetAdmin and CapSysAdmin are needed for running task in awsvpc network mode.
// This network mode is (at least currently) not supported in external environment,
// hence not adding them in that case.
caps = []string{CapNetAdmin, CapSysAdmin}
caps = []string{CapNetAdmin, CapSysAdmin, CapChown}
}

hostConfig := &godocker.HostConfig{
Expand Down
2 changes: 1 addition & 1 deletion ecs-init/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func validateCommonCreateContainerOptions(opts godocker.CreateContainerOptions,
t.Errorf("Expected network mode to be %s, got %s", networkMode, hostCfg.NetworkMode)
}

if len(hostCfg.CapAdd) != 2 {
if len(hostCfg.CapAdd) != 3 {
t.Error("Mismatch detected in added host config capabilities")
}

Expand Down

0 comments on commit 0f00378

Please sign in to comment.