mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(ecs): honour privileged EC2 task containers (#6659)
This commit is contained in:
1 parent
95960f80e8
commit
1bf019f89a
7 files changed
+112
-1
No files matched your search
@@ -2414,6 +2414,10 @@ public interface EmulatorConfig {
|
||||
@WithDefault("false")
|
||||
boolean allowUnsafeHostVolumes();
|
||||
|
||||
/** Allow ECS task definitions to launch Docker containers with host-level privilege. */
|
||||
@WithDefault("false")
|
||||
boolean allowPrivilegedContainers();
|
||||
|
||||
/**
|
||||
* When true, Floci removes on startup, in Docker mode, every ECS container a previous run
|
||||
* of <em>this same</em> Floci left on the daemon (matched by the {@code io.floci.owner}
|
||||
|
||||
+10
@@ -248,6 +248,13 @@ public class EcsContainerManager {
|
||||
|
||||
EcsTaskHandle startTask(EcsTask task, TaskDefinition taskDef,
|
||||
List<ContainerOverride> containerOverrides, String region, long firelensBackoffMillis) {
|
||||
if (!config.services().ecs().allowPrivilegedContainers()
|
||||
&& taskDef.getContainerDefinitions().stream()
|
||||
.anyMatch(def -> Boolean.TRUE.equals(def.getPrivileged()))) {
|
||||
throw new AwsException("ClientException",
|
||||
"Privileged containers require floci.services.ecs.allow-privileged-containers"
|
||||
+ " (FLOCI_SERVICES_ECS_ALLOW_PRIVILEGED_CONTAINERS) to be enabled.", 400);
|
||||
}
|
||||
String taskId = extractTaskId(task.getTaskArn());
|
||||
|
||||
Map<String, String> containerIds = new LinkedHashMap<>();
|
||||
@@ -440,6 +447,9 @@ public class EcsContainerManager {
|
||||
if (Boolean.TRUE.equals(def.getReadonlyRootFilesystem())) {
|
||||
specBuilder.withReadonlyRootfs();
|
||||
}
|
||||
if (Boolean.TRUE.equals(def.getPrivileged())) {
|
||||
specBuilder.withPrivileged(true);
|
||||
}
|
||||
// Checked at registration too; again here, as for a host volume, for a definition
|
||||
// persisted before the policy covered devices.
|
||||
checkDeviceHostPaths(def);
|
||||
|
||||
Reference in new issue
Block a user