File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,6 +159,23 @@ struct RunCommand: ParsableCommand {
159159 }
160160 }
161161
162+ // Apply sysctls from the OCI spec.
163+ if let sysctls = spec. linux? . sysctl {
164+ for (key, value) in sysctls {
165+ let path = " /proc/sys/ " + key. replacingOccurrences ( of: " . " , with: " / " )
166+ let fd = open ( path, O_WRONLY)
167+ guard fd >= 0 else {
168+ throw App . Errno ( stage: " sysctl open( \( path) ) " )
169+ }
170+ defer { close ( fd) }
171+ let bytes = Array ( value. utf8)
172+ let written = write ( fd, bytes, bytes. count)
173+ guard written == bytes. count else {
174+ throw App . Errno ( stage: " sysctl write( \( key) = \( value) ) " )
175+ }
176+ }
177+ }
178+
162179 // Apply O_CLOEXEC to all file descriptors except stdio.
163180 // This ensures that all unwanted fds we may have accidentally
164181 // inherited are marked close-on-exec so they stay out of the
You can’t perform that action at this time.
0 commit comments