@@ -62,6 +62,9 @@ public final class LinuxContainer: Container, Sendable {
6262 public var virtualization : Bool = false
6363 /// Optional destination for serial boot logs.
6464 public var bootLog : BootLog ?
65+ /// EXPERIMENTAL: Path in the root filesystem for the virtual
66+ /// machine where the OCI runtime used to spawn the container lives.
67+ public var ociRuntimePath : String ?
6568
6669 public init ( ) { }
6770
@@ -77,7 +80,8 @@ public final class LinuxContainer: Container, Sendable {
7780 dns: DNS ? = nil ,
7881 hosts: Hosts ? = nil ,
7982 virtualization: Bool = false ,
80- bootLog: BootLog ? = nil
83+ bootLog: BootLog ? = nil ,
84+ ociRuntimePath: String ? = nil
8185 ) {
8286 self . process = process
8387 self . cpus = cpus
@@ -91,6 +95,7 @@ public final class LinuxContainer: Container, Sendable {
9195 self . hosts = hosts
9296 self . virtualization = virtualization
9397 self . bootLog = bootLog
98+ self . ociRuntimePath = ociRuntimePath
9499 }
95100 }
96101
@@ -317,19 +322,42 @@ public final class LinuxContainer: Container, Sendable {
317322 )
318323 )
319324
325+ spec. linux? . namespaces = [
326+ LinuxNamespace ( type: . cgroup) ,
327+ LinuxNamespace ( type: . ipc) ,
328+ LinuxNamespace ( type: . mount) ,
329+ LinuxNamespace ( type: . pid) ,
330+ LinuxNamespace ( type: . uts) ,
331+ ]
332+
320333 return spec
321334 }
322335
336+ /// The default set of mounts for a LinuxContainer.
323337 public static func defaultMounts( ) -> [ Mount ] {
324338 let defaultOptions = [ " nosuid " , " noexec " , " nodev " ]
325339 return [
326- . any( type: " proc " , source: " proc " , destination: " /proc " , options : defaultOptions ) ,
340+ . any( type: " proc " , source: " proc " , destination: " /proc " ) ,
327341 . any( type: " sysfs " , source: " sysfs " , destination: " /sys " , options: defaultOptions) ,
328342 . any( type: " devtmpfs " , source: " none " , destination: " /dev " , options: [ " nosuid " , " mode=755 " ] ) ,
329343 . any( type: " mqueue " , source: " mqueue " , destination: " /dev/mqueue " , options: defaultOptions) ,
330344 . any( type: " tmpfs " , source: " tmpfs " , destination: " /dev/shm " , options: defaultOptions + [ " mode=1777 " , " size=65536k " ] ) ,
331345 . any( type: " cgroup2 " , source: " none " , destination: " /sys/fs/cgroup " , options: defaultOptions) ,
332- . any( type: " devpts " , source: " devpts " , destination: " /dev/pts " , options: [ " nosuid " , " noexec " , " gid=5 " , " mode=620 " , " ptmxmode=666 " ] ) ,
346+ . any( type: " devpts " , source: " devpts " , destination: " /dev/pts " , options: [ " nosuid " , " noexec " , " newinstance " , " gid=5 " , " mode=0620 " , " ptmxmode=0666 " ] ) ,
347+ ]
348+ }
349+
350+ /// A more traditional default set of mounts that OCI runtimes typically employ.
351+ public static func defaultOCIMounts( ) -> [ Mount ] {
352+ let defaultOptions = [ " nosuid " , " noexec " , " nodev " ]
353+ return [
354+ . any( type: " proc " , source: " proc " , destination: " /proc " ) ,
355+ . any( type: " tmpfs " , source: " tmpfs " , destination: " /dev " , options: [ " nosuid " , " mode=755 " , " size=65536k " ] ) ,
356+ . any( type: " devpts " , source: " devpts " , destination: " /dev/pts " , options: [ " nosuid " , " noexec " , " newinstance " , " gid=5 " , " mode=0620 " , " ptmxmode=0666 " ] ) ,
357+ . any( type: " sysfs " , source: " sysfs " , destination: " /sys " , options: defaultOptions) ,
358+ . any( type: " mqueue " , source: " mqueue " , destination: " /dev/mqueue " , options: defaultOptions) ,
359+ . any( type: " tmpfs " , source: " tmpfs " , destination: " /dev/shm " , options: defaultOptions + [ " mode=1777 " , " size=65536k " ] ) ,
360+ . any( type: " cgroup2 " , source: " none " , destination: " /sys/fs/cgroup " , options: defaultOptions) ,
333361 ]
334362 }
335363
@@ -456,6 +484,7 @@ extension LinuxContainer {
456484 containerID: self . id,
457485 spec: spec,
458486 io: stdio,
487+ ociRuntimePath: self . config. ociRuntimePath,
459488 agent: agent,
460489 vm: createdState. vm,
461490 logger: self . logger
@@ -657,6 +686,7 @@ extension LinuxContainer {
657686 containerID: self . id,
658687 spec: spec,
659688 io: stdio,
689+ ociRuntimePath: self . config. ociRuntimePath,
660690 agent: agent,
661691 vm: startedState. vm,
662692 logger: self . logger,
@@ -693,6 +723,7 @@ extension LinuxContainer {
693723 containerID: self . id,
694724 spec: spec,
695725 io: stdio,
726+ ociRuntimePath: self . config. ociRuntimePath,
696727 agent: agent,
697728 vm: state. vm,
698729 logger: self . logger,
0 commit comments