|
| 1 | +/* |
| 2 | + Copyright The containerd Authors. |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package oci |
| 18 | + |
| 19 | +import ( |
| 20 | + specs "github.com/opencontainers/runtime-spec/specs-go" |
| 21 | +) |
| 22 | + |
| 23 | +// appendOSMounts modifies the mount spec to mount emulated Linux filesystems on FreeBSD, |
| 24 | +// as per: https://wiki.freebsd.org/LinuxJails |
| 25 | +func appendOSMounts(s *Spec, os string) error { |
| 26 | + // No-op for FreeBSD containers |
| 27 | + if os != "linux" { |
| 28 | + return nil |
| 29 | + } |
| 30 | + /* The nosuid noexec options are for consistency with Linux mounts: on FreeBSD it is |
| 31 | + by default impossible to execute anything from these filesystems. |
| 32 | + */ |
| 33 | + var mounts = []specs.Mount{ |
| 34 | + { |
| 35 | + Destination: "/proc", |
| 36 | + Type: "linprocfs", |
| 37 | + Source: "linprocfs", |
| 38 | + Options: []string{"nosuid", "noexec"}, |
| 39 | + }, |
| 40 | + { |
| 41 | + Destination: "/sys", |
| 42 | + Type: "linsysfs", |
| 43 | + Source: "linsysfs", |
| 44 | + Options: []string{"nosuid", "noexec", "nodev"}, |
| 45 | + }, |
| 46 | + } |
| 47 | + |
| 48 | + s.Mounts = append(mounts, s.Mounts...) |
| 49 | + return nil |
| 50 | +} |
0 commit comments