Skip to content

Commit

Permalink
Remove CAP_CHOWN (#3480)
Browse files Browse the repository at this point in the history
* Revert "Add the CAP_CHOWN capability to support running rootless"

This reverts commit 0f00378.

* Add comment to not include  in capacity string
  • Loading branch information
Realmonia authored Nov 10, 2022
1 parent 27149d2 commit d367b12
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
29 changes: 14 additions & 15 deletions ecs-init/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,6 @@ const (
// maxRetries specifies the maximum number of retries for ping to return
// a successful response from the docker socket
maxRetries = 5
// CapNetAdmin to start agent with NET_ADMIN capability
// For more information on capabilities, please read this manpage:
// http://man7.org/linux/man-pages/man7/capabilities.7.html
CapNetAdmin = "NET_ADMIN"
// CapSysAdmin to start agent with SYS_ADMIN capability
// This is needed for the ECS Agent to invoke the setns call when
// configuring the network namespace of the pause container
// 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 Expand Up @@ -127,6 +112,20 @@ const (
execAgentLogRelativePath = "/exec"
)

// Do NOT include "CAP_" in capability string
const (
// CapNetAdmin to start agent with NET_ADMIN capability
// For more information on capabilities, please read this manpage:
// http://man7.org/linux/man-pages/man7/capabilities.7.html
CapNetAdmin = "NET_ADMIN"
// CapSysAdmin to start agent with SYS_ADMIN capability
// This is needed for the ECS Agent to invoke the setns call when
// configuring the network namespace of the pause container
// For more information on setns, please read this manpage:
// http://man7.org/linux/man-pages/man2/setns.2.html
CapSysAdmin = "SYS_ADMIN"
)

var pluginDirs = []string{
pluginSocketFilesDir,
pluginSpecFilesEtcDir,
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, CapChown}
caps = []string{CapNetAdmin, CapSysAdmin}
}

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 @@ -292,7 +292,7 @@ func validateCommonCreateContainerOptions(opts godocker.CreateContainerOptions,
t.Errorf("Expected network mode to be %s, got %s", networkMode, hostCfg.NetworkMode)
}

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

Expand Down

0 comments on commit d367b12

Please sign in to comment.