full diff: https://github.com/opencontainers/runc/compare/v1.0.0-rc8...3e425f80a8c931f88e6d94a8c831b9d5aa481657
- opencontainers/runc#2010 criu image path permission error when checkpoint rootless container
- opencontainers/runc#2028 Update to Go 1.12 and drop obsolete versions
- opencontainers/runc#2029 Update dependencies
- opencontainers/runc#2034 Support for logging from children processes
- opencontainers/runc#2035 specconv: always set "type: bind" in case of MS_BIND
- opencontainers/runc#2038 `r.destroy` can defer exec in `runner.run` method
- opencontainers/runc#2041 Change the permissions of the notify listener socket to rwx for everyone
- opencontainers/runc#2042 libcontainer: intelrdt: add missing destroy handler in defer func
- opencontainers/runc#2047 Move systemd.Manager initialization into a function in that module
- opencontainers/runc#2057 main: not reopen /dev/stderr
- closes opencontainers/runc#2056 Runc + podman|cri-o + systemd issue with stderr
- closes kubernetes/kubernetes#77615 kubelet fails starting CRI-O containers (Ubuntu 18.04 + systemd cgroups driver)
- closes cri-o/cri-o#2368 Joining worker node not starting flannel or kube-proxy / CRI-O error "open /dev/stderr: no such device or address"
- opencontainers/runc#2061 libcontainer: fix TestGetContainerState to check configs.NEWCGROUP
- opencontainers/runc#2065 Fix cgroup hugetlb size prefix for kB
- opencontainers/runc#2067 libcontainer: change seccomp test for clone syscall
- opencontainers/runc#2074 Update dependency libseccomp-golang
- opencontainers/runc#2081 Bump CRIU to 3.12
- opencontainers/runc#2089 doc: First process in container needs `Init: true`
- opencontainers/runc#2094 Skip searching /dev/.udev for device nodes
- closes opencontainers/runc#2093 HostDevices() race with older udevd versions
- opencontainers/runc#2098 man: fix man-pages
- opencontainers/runc#2103 cgroups/fs: check nil pointers in cgroup manager
- opencontainers/runc#2107 Make get devices function public
- opencontainers/runc#2113 libcontainer: initial support for cgroups v2
- opencontainers/runc#2116 Avoid the dependency on cgo through go-systemd/util package
- removes github.com/coreos/pkg as dependency
- opencontainers/runc#2117 Remove libcontainer detection for systemd features
- fixes opencontainers/runc#2117 Cache the systemd detection results
- opencontainers/runc#2119 libcontainer: update masked paths of /proc
- relates to moby/moby#36368 Add /proc/keys to masked paths
- relates to moby/moby#38299 Masked /proc/asound
- relates to moby/moby#37404 Add /proc/acpi to masked paths (CVE-2018-10892)
- opencontainers/runc#2122 nsenter: minor fixes
- opencontainers/runc#2123 Bump x/sys and update syscall for initial Risc-V support
- opencontainers/runc#2125 cgroup: support mount of cgroup2
- opencontainers/runc#2126 libcontainer/nsenter: Don't import C in non-cgo file
- opencontainers/runc#2129 Only allow proc mount if it is procfs
- addresses opencontainers/runc#2129 AppArmor can be bypassed by a malicious image that specifies a volume at /proc (CVE-2019-16884)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit ac0ab114a2ad14eab4a4da6a855831d90d777139)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -81,7 +81,7 @@ google.golang.org/grpc 6eaf6f47437a6b4e2153a190160e |
| 81 | 81 |
# the containerd project first, and update both after that is merged. |
| 82 | 82 |
# This commit does not need to match RUNC_COMMIT as it is used for helper |
| 83 | 83 |
# packages but should be newer or equal. |
| 84 |
-github.com/opencontainers/runc 425e105d5a03fabd737a126ad93d62a9eeede87f # v1.0.0-rc8 |
|
| 84 |
+github.com/opencontainers/runc 3e425f80a8c931f88e6d94a8c831b9d5aa481657 # v1.0.0-rc8-92-g84373aaa |
|
| 85 | 85 |
github.com/opencontainers/runtime-spec 29686dbc5559d93fb1ef402eeda3e35c38d75af4 # v1.0.1-59-g29686db |
| 86 | 86 |
github.com/opencontainers/image-spec d60099175f88c47cd379c4738d158884749ed235 # v1.0.1 |
| 87 | 87 |
github.com/seccomp/libseccomp-golang 32f571b70023028bd57d9288c20efbcb237f3ce0 |
| ... | ... |
@@ -11,6 +11,8 @@ import ( |
| 11 | 11 |
"path/filepath" |
| 12 | 12 |
"strconv" |
| 13 | 13 |
"strings" |
| 14 |
+ "sync" |
|
| 15 |
+ "syscall" |
|
| 14 | 16 |
"time" |
| 15 | 17 |
|
| 16 | 18 |
units "github.com/docker/go-units" |
| ... | ... |
@@ -22,6 +24,30 @@ const ( |
| 22 | 22 |
CgroupProcesses = "cgroup.procs" |
| 23 | 23 |
) |
| 24 | 24 |
|
| 25 |
+var ( |
|
| 26 |
+ isUnifiedOnce sync.Once |
|
| 27 |
+ isUnified bool |
|
| 28 |
+) |
|
| 29 |
+ |
|
| 30 |
+// HugePageSizeUnitList is a list of the units used by the linux kernel when |
|
| 31 |
+// naming the HugePage control files. |
|
| 32 |
+// https://www.kernel.org/doc/Documentation/cgroup-v1/hugetlb.txt |
|
| 33 |
+// TODO Since the kernel only use KB, MB and GB; TB and PB should be removed, |
|
| 34 |
+// depends on https://github.com/docker/go-units/commit/a09cd47f892041a4fac473133d181f5aea6fa393 |
|
| 35 |
+var HugePageSizeUnitList = []string{"B", "KB", "MB", "GB", "TB", "PB"}
|
|
| 36 |
+ |
|
| 37 |
+// IsCgroup2UnifiedMode returns whether we are running in cgroup v2 unified mode. |
|
| 38 |
+func IsCgroup2UnifiedMode() bool {
|
|
| 39 |
+ isUnifiedOnce.Do(func() {
|
|
| 40 |
+ var st syscall.Statfs_t |
|
| 41 |
+ if err := syscall.Statfs("/sys/fs/cgroup", &st); err != nil {
|
|
| 42 |
+ panic("cannot statfs cgroup root")
|
|
| 43 |
+ } |
|
| 44 |
+ isUnified = st.Type == unix.CGROUP2_SUPER_MAGIC |
|
| 45 |
+ }) |
|
| 46 |
+ return isUnified |
|
| 47 |
+} |
|
| 48 |
+ |
|
| 25 | 49 |
// https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt |
| 26 | 50 |
func FindCgroupMountpoint(cgroupPath, subsystem string) (string, error) {
|
| 27 | 51 |
mnt, _, err := FindCgroupMountpointAndRoot(cgroupPath, subsystem) |
| ... | ... |
@@ -42,6 +68,10 @@ func FindCgroupMountpointAndRoot(cgroupPath, subsystem string) (string, string, |
| 42 | 42 |
} |
| 43 | 43 |
defer f.Close() |
| 44 | 44 |
|
| 45 |
+ if IsCgroup2UnifiedMode() {
|
|
| 46 |
+ subsystem = "" |
|
| 47 |
+ } |
|
| 48 |
+ |
|
| 45 | 49 |
return findCgroupMountpointAndRootFromReader(f, cgroupPath, subsystem) |
| 46 | 50 |
} |
| 47 | 51 |
|
| ... | ... |
@@ -50,12 +80,12 @@ func findCgroupMountpointAndRootFromReader(reader io.Reader, cgroupPath, subsyst |
| 50 | 50 |
for scanner.Scan() {
|
| 51 | 51 |
txt := scanner.Text() |
| 52 | 52 |
fields := strings.Fields(txt) |
| 53 |
- if len(fields) < 5 {
|
|
| 53 |
+ if len(fields) < 9 {
|
|
| 54 | 54 |
continue |
| 55 | 55 |
} |
| 56 | 56 |
if strings.HasPrefix(fields[4], cgroupPath) {
|
| 57 | 57 |
for _, opt := range strings.Split(fields[len(fields)-1], ",") {
|
| 58 |
- if opt == subsystem {
|
|
| 58 |
+ if (subsystem == "" && fields[9] == "cgroup2") || opt == subsystem {
|
|
| 59 | 59 |
return fields[4], fields[3], nil |
| 60 | 60 |
} |
| 61 | 61 |
} |
| ... | ... |
@@ -69,6 +99,19 @@ func findCgroupMountpointAndRootFromReader(reader io.Reader, cgroupPath, subsyst |
| 69 | 69 |
} |
| 70 | 70 |
|
| 71 | 71 |
func isSubsystemAvailable(subsystem string) bool {
|
| 72 |
+ if IsCgroup2UnifiedMode() {
|
|
| 73 |
+ controllers, err := GetAllSubsystems() |
|
| 74 |
+ if err != nil {
|
|
| 75 |
+ return false |
|
| 76 |
+ } |
|
| 77 |
+ for _, c := range controllers {
|
|
| 78 |
+ if c == subsystem {
|
|
| 79 |
+ return true |
|
| 80 |
+ } |
|
| 81 |
+ } |
|
| 82 |
+ return false |
|
| 83 |
+ } |
|
| 84 |
+ |
|
| 72 | 85 |
cgroups, err := ParseCgroupFile("/proc/self/cgroup")
|
| 73 | 86 |
if err != nil {
|
| 74 | 87 |
return false |
| ... | ... |
@@ -113,7 +156,7 @@ func FindCgroupMountpointDir() (string, error) {
|
| 113 | 113 |
return "", fmt.Errorf("Found no fields post '-' in %q", text)
|
| 114 | 114 |
} |
| 115 | 115 |
|
| 116 |
- if postSeparatorFields[0] == "cgroup" {
|
|
| 116 |
+ if postSeparatorFields[0] == "cgroup" || postSeparatorFields[0] == "cgroup2" {
|
|
| 117 | 117 |
// Check that the mount is properly formatted. |
| 118 | 118 |
if numPostFields < 3 {
|
| 119 | 119 |
return "", fmt.Errorf("Error found less than 3 fields post '-' in %q", text)
|
| ... | ... |
@@ -186,6 +229,19 @@ func getCgroupMountsHelper(ss map[string]bool, mi io.Reader, all bool) ([]Mount, |
| 186 | 186 |
// GetCgroupMounts returns the mounts for the cgroup subsystems. |
| 187 | 187 |
// all indicates whether to return just the first instance or all the mounts. |
| 188 | 188 |
func GetCgroupMounts(all bool) ([]Mount, error) {
|
| 189 |
+ if IsCgroup2UnifiedMode() {
|
|
| 190 |
+ availableControllers, err := GetAllSubsystems() |
|
| 191 |
+ if err != nil {
|
|
| 192 |
+ return nil, err |
|
| 193 |
+ } |
|
| 194 |
+ m := Mount{
|
|
| 195 |
+ Mountpoint: "/sys/fs/cgroup", |
|
| 196 |
+ Root: "/sys/fs/cgroup", |
|
| 197 |
+ Subsystems: availableControllers, |
|
| 198 |
+ } |
|
| 199 |
+ return []Mount{m}, nil
|
|
| 200 |
+ } |
|
| 201 |
+ |
|
| 189 | 202 |
f, err := os.Open("/proc/self/mountinfo")
|
| 190 | 203 |
if err != nil {
|
| 191 | 204 |
return nil, err |
| ... | ... |
@@ -349,6 +405,9 @@ func parseCgroupFromReader(r io.Reader) (map[string]string, error) {
|
| 349 | 349 |
} |
| 350 | 350 |
|
| 351 | 351 |
func getControllerPath(subsystem string, cgroups map[string]string) (string, error) {
|
| 352 |
+ if IsCgroup2UnifiedMode() {
|
|
| 353 |
+ return "/", nil |
|
| 354 |
+ } |
|
| 352 | 355 |
|
| 353 | 356 |
if p, ok := cgroups[subsystem]; ok {
|
| 354 | 357 |
return p, nil |
| ... | ... |
@@ -409,19 +468,26 @@ func RemovePaths(paths map[string]string) (err error) {
|
| 409 | 409 |
} |
| 410 | 410 |
|
| 411 | 411 |
func GetHugePageSize() ([]string, error) {
|
| 412 |
- var pageSizes []string |
|
| 413 |
- sizeList := []string{"B", "kB", "MB", "GB", "TB", "PB"}
|
|
| 414 | 412 |
files, err := ioutil.ReadDir("/sys/kernel/mm/hugepages")
|
| 415 | 413 |
if err != nil {
|
| 416 |
- return pageSizes, err |
|
| 414 |
+ return []string{}, err
|
|
| 417 | 415 |
} |
| 416 |
+ var fileNames []string |
|
| 418 | 417 |
for _, st := range files {
|
| 419 |
- nameArray := strings.Split(st.Name(), "-") |
|
| 418 |
+ fileNames = append(fileNames, st.Name()) |
|
| 419 |
+ } |
|
| 420 |
+ return getHugePageSizeFromFilenames(fileNames) |
|
| 421 |
+} |
|
| 422 |
+ |
|
| 423 |
+func getHugePageSizeFromFilenames(fileNames []string) ([]string, error) {
|
|
| 424 |
+ var pageSizes []string |
|
| 425 |
+ for _, fileName := range fileNames {
|
|
| 426 |
+ nameArray := strings.Split(fileName, "-") |
|
| 420 | 427 |
pageSize, err := units.RAMInBytes(nameArray[1]) |
| 421 | 428 |
if err != nil {
|
| 422 | 429 |
return []string{}, err
|
| 423 | 430 |
} |
| 424 |
- sizeString := units.CustomSize("%g%s", float64(pageSize), 1024.0, sizeList)
|
|
| 431 |
+ sizeString := units.CustomSize("%g%s", float64(pageSize), 1024.0, HugePageSizeUnitList)
|
|
| 425 | 432 |
pageSizes = append(pageSizes, sizeString) |
| 426 | 433 |
} |
| 427 | 434 |
|
| ... | ... |
@@ -59,3 +59,8 @@ func NewThrottleDevice(major, minor int64, rate uint64) *ThrottleDevice {
|
| 59 | 59 |
func (td *ThrottleDevice) String() string {
|
| 60 | 60 |
return fmt.Sprintf("%d:%d %d", td.Major, td.Minor, td.Rate)
|
| 61 | 61 |
} |
| 62 |
+ |
|
| 63 |
+// StringName formats the struct to be writable to the cgroup specific file |
|
| 64 |
+func (td *ThrottleDevice) StringName(name string) string {
|
|
| 65 |
+ return fmt.Sprintf("%d:%d %s=%d", td.Major, td.Minor, name, td.Rate)
|
|
| 66 |
+} |
| ... | ... |
@@ -119,4 +119,12 @@ type Resources struct {
|
| 119 | 119 |
|
| 120 | 120 |
// Set class identifier for container's network packets |
| 121 | 121 |
NetClsClassid uint32 `json:"net_cls_classid_u"` |
| 122 |
+ |
|
| 123 |
+ // Used on cgroups v2: |
|
| 124 |
+ |
|
| 125 |
+ // CpuWeight sets a proportional bandwidth limit. |
|
| 126 |
+ CpuWeight uint64 `json:"cpu_weight"` |
|
| 127 |
+ |
|
| 128 |
+ // CpuMax sets she maximum bandwidth limit (format: max period). |
|
| 129 |
+ CpuMax string `json:"cpu_max"` |
|
| 122 | 130 |
} |
| ... | ... |
@@ -7,11 +7,11 @@ import ( |
| 7 | 7 |
"path/filepath" |
| 8 | 8 |
|
| 9 | 9 |
"github.com/opencontainers/runc/libcontainer/configs" |
| 10 |
- |
|
| 11 | 10 |
"golang.org/x/sys/unix" |
| 12 | 11 |
) |
| 13 | 12 |
|
| 14 | 13 |
var ( |
| 14 |
+ // ErrNotADevice denotes that a file is not a valid linux device. |
|
| 15 | 15 |
ErrNotADevice = errors.New("not a device node")
|
| 16 | 16 |
) |
| 17 | 17 |
|
| ... | ... |
@@ -21,7 +21,8 @@ var ( |
| 21 | 21 |
ioutilReadDir = ioutil.ReadDir |
| 22 | 22 |
) |
| 23 | 23 |
|
| 24 |
-// Given the path to a device and its cgroup_permissions(which cannot be easily queried) look up the information about a linux device and return that information as a Device struct. |
|
| 24 |
+// Given the path to a device and its cgroup_permissions(which cannot be easily queried) look up the |
|
| 25 |
+// information about a linux device and return that information as a Device struct. |
|
| 25 | 26 |
func DeviceFromPath(path, permissions string) (*configs.Device, error) {
|
| 26 | 27 |
var stat unix.Stat_t |
| 27 | 28 |
err := unixLstat(path, &stat) |
| ... | ... |
@@ -60,25 +61,29 @@ func DeviceFromPath(path, permissions string) (*configs.Device, error) {
|
| 60 | 60 |
}, nil |
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 |
+// HostDevices returns all devices that can be found under /dev directory. |
|
| 63 | 64 |
func HostDevices() ([]*configs.Device, error) {
|
| 64 |
- return getDevices("/dev")
|
|
| 65 |
+ return GetDevices("/dev")
|
|
| 65 | 66 |
} |
| 66 | 67 |
|
| 67 |
-func getDevices(path string) ([]*configs.Device, error) {
|
|
| 68 |
+// GetDevices recursively traverses a directory specified by path |
|
| 69 |
+// and returns all devices found there. |
|
| 70 |
+func GetDevices(path string) ([]*configs.Device, error) {
|
|
| 68 | 71 |
files, err := ioutilReadDir(path) |
| 69 | 72 |
if err != nil {
|
| 70 | 73 |
return nil, err |
| 71 | 74 |
} |
| 72 |
- out := []*configs.Device{}
|
|
| 75 |
+ var out []*configs.Device |
|
| 73 | 76 |
for _, f := range files {
|
| 74 | 77 |
switch {
|
| 75 | 78 |
case f.IsDir(): |
| 76 | 79 |
switch f.Name() {
|
| 77 | 80 |
// ".lxc" & ".lxd-mounts" added to address https://github.com/lxc/lxd/issues/2825 |
| 78 |
- case "pts", "shm", "fd", "mqueue", ".lxc", ".lxd-mounts": |
|
| 81 |
+ // ".udev" added to address https://github.com/opencontainers/runc/issues/2093 |
|
| 82 |
+ case "pts", "shm", "fd", "mqueue", ".lxc", ".lxd-mounts", ".udev": |
|
| 79 | 83 |
continue |
| 80 | 84 |
default: |
| 81 |
- sub, err := getDevices(filepath.Join(path, f.Name())) |
|
| 85 |
+ sub, err := GetDevices(filepath.Join(path, f.Name())) |
|
| 82 | 86 |
if err != nil {
|
| 83 | 87 |
return nil, err |
| 84 | 88 |
} |
| ... | ... |
@@ -37,9 +37,6 @@ enum sync_t {
|
| 37 | 37 |
SYNC_RECVPID_ACK = 0x43, /* PID was correctly received by parent. */ |
| 38 | 38 |
SYNC_GRANDCHILD = 0x44, /* The grandchild is ready to run. */ |
| 39 | 39 |
SYNC_CHILD_READY = 0x45, /* The child or grandchild is ready to return. */ |
| 40 |
- |
|
| 41 |
- /* XXX: This doesn't help with segfaults and other such issues. */ |
|
| 42 |
- SYNC_ERR = 0xFF, /* Fatal error, no turning back. The error code follows. */ |
|
| 43 | 40 |
}; |
| 44 | 41 |
|
| 45 | 42 |
/* |
| ... | ... |
@@ -53,9 +50,6 @@ enum sync_t {
|
| 53 | 53 |
#define JUMP_CHILD 0xA0 |
| 54 | 54 |
#define JUMP_INIT 0xA1 |
| 55 | 55 |
|
| 56 |
-/* JSON buffer. */ |
|
| 57 |
-#define JSON_MAX 4096 |
|
| 58 |
- |
|
| 59 | 56 |
/* Assume the stack grows down, so arguments should be above it. */ |
| 60 | 57 |
struct clone_t {
|
| 61 | 58 |
/* |
| ... | ... |
@@ -95,6 +89,15 @@ struct nlconfig_t {
|
| 95 | 95 |
size_t gidmappath_len; |
| 96 | 96 |
}; |
| 97 | 97 |
|
| 98 |
+#define PANIC "panic" |
|
| 99 |
+#define FATAL "fatal" |
|
| 100 |
+#define ERROR "error" |
|
| 101 |
+#define WARNING "warning" |
|
| 102 |
+#define INFO "info" |
|
| 103 |
+#define DEBUG "debug" |
|
| 104 |
+ |
|
| 105 |
+static int logfd = -1; |
|
| 106 |
+ |
|
| 98 | 107 |
/* |
| 99 | 108 |
* List of netlink message types sent to us as part of bootstrapping the init. |
| 100 | 109 |
* These constants are defined in libcontainer/message_linux.go. |
| ... | ... |
@@ -131,22 +134,34 @@ int setns(int fd, int nstype) |
| 131 | 131 |
} |
| 132 | 132 |
#endif |
| 133 | 133 |
|
| 134 |
+static void write_log_with_info(const char *level, const char *function, int line, const char *format, ...) |
|
| 135 |
+{
|
|
| 136 |
+ char message[1024] = {};
|
|
| 137 |
+ |
|
| 138 |
+ va_list args; |
|
| 139 |
+ |
|
| 140 |
+ if (logfd < 0 || level == NULL) |
|
| 141 |
+ return; |
|
| 142 |
+ |
|
| 143 |
+ va_start(args, format); |
|
| 144 |
+ if (vsnprintf(message, sizeof(message), format, args) < 0) |
|
| 145 |
+ goto done; |
|
| 146 |
+ |
|
| 147 |
+ dprintf(logfd, "{\"level\":\"%s\", \"msg\": \"%s:%d %s\"}\n", level, function, line, message);
|
|
| 148 |
+done: |
|
| 149 |
+ va_end(args); |
|
| 150 |
+} |
|
| 151 |
+ |
|
| 152 |
+#define write_log(level, fmt, ...) \ |
|
| 153 |
+ write_log_with_info((level), __FUNCTION__, __LINE__, (fmt), ##__VA_ARGS__) |
|
| 154 |
+ |
|
| 134 | 155 |
/* XXX: This is ugly. */ |
| 135 | 156 |
static int syncfd = -1; |
| 136 | 157 |
|
| 137 |
-/* TODO(cyphar): Fix this so it correctly deals with syncT. */ |
|
| 138 |
-#define bail(fmt, ...) \ |
|
| 139 |
- do { \
|
|
| 140 |
- int ret = __COUNTER__ + 1; \ |
|
| 141 |
- fprintf(stderr, "nsenter: " fmt ": %m\n", ##__VA_ARGS__); \ |
|
| 142 |
- if (syncfd >= 0) { \
|
|
| 143 |
- enum sync_t s = SYNC_ERR; \ |
|
| 144 |
- if (write(syncfd, &s, sizeof(s)) != sizeof(s)) \ |
|
| 145 |
- fprintf(stderr, "nsenter: failed: write(s)"); \ |
|
| 146 |
- if (write(syncfd, &ret, sizeof(ret)) != sizeof(ret)) \ |
|
| 147 |
- fprintf(stderr, "nsenter: failed: write(ret)"); \ |
|
| 148 |
- } \ |
|
| 149 |
- exit(ret); \ |
|
| 158 |
+#define bail(fmt, ...) \ |
|
| 159 |
+ do { \
|
|
| 160 |
+ write_log(FATAL, "nsenter: " fmt ": %m", ##__VA_ARGS__); \ |
|
| 161 |
+ exit(1); \ |
|
| 150 | 162 |
} while(0) |
| 151 | 163 |
|
| 152 | 164 |
static int write_file(char *data, size_t data_len, char *pathfmt, ...) |
| ... | ... |
@@ -352,6 +367,23 @@ static int initpipe(void) |
| 352 | 352 |
return pipenum; |
| 353 | 353 |
} |
| 354 | 354 |
|
| 355 |
+static void setup_logpipe(void) |
|
| 356 |
+{
|
|
| 357 |
+ char *logpipe, *endptr; |
|
| 358 |
+ |
|
| 359 |
+ logpipe = getenv("_LIBCONTAINER_LOGPIPE");
|
|
| 360 |
+ if (logpipe == NULL || *logpipe == '\0') {
|
|
| 361 |
+ return; |
|
| 362 |
+ } |
|
| 363 |
+ |
|
| 364 |
+ logfd = strtol(logpipe, &endptr, 10); |
|
| 365 |
+ if (logpipe == endptr || *endptr != '\0') {
|
|
| 366 |
+ fprintf(stderr, "unable to parse _LIBCONTAINER_LOGPIPE, value: %s\n", logpipe); |
|
| 367 |
+ /* It is too early to use bail */ |
|
| 368 |
+ exit(1); |
|
| 369 |
+ } |
|
| 370 |
+} |
|
| 371 |
+ |
|
| 355 | 372 |
/* Returns the clone(2) flag for a namespace, given the name of a namespace. */ |
| 356 | 373 |
static int nsflag(char *name) |
| 357 | 374 |
{
|
| ... | ... |
@@ -545,6 +577,12 @@ void nsexec(void) |
| 545 | 545 |
struct nlconfig_t config = { 0 };
|
| 546 | 546 |
|
| 547 | 547 |
/* |
| 548 |
+ * Setup a pipe to send logs to the parent. This should happen |
|
| 549 |
+ * first, because bail will use that pipe. |
|
| 550 |
+ */ |
|
| 551 |
+ setup_logpipe(); |
|
| 552 |
+ |
|
| 553 |
+ /* |
|
| 548 | 554 |
* If we don't have an init pipe, just return to the go routine. |
| 549 | 555 |
* We'll only get an init pipe for start or exec. |
| 550 | 556 |
*/ |
| ... | ... |
@@ -560,6 +598,8 @@ void nsexec(void) |
| 560 | 560 |
if (ensure_cloned_binary() < 0) |
| 561 | 561 |
bail("could not ensure we are a cloned binary");
|
| 562 | 562 |
|
| 563 |
+ write_log(DEBUG, "nsexec started"); |
|
| 564 |
+ |
|
| 563 | 565 |
/* Parse all of the netlink configuration. */ |
| 564 | 566 |
nl_parse(pipenum, &config); |
| 565 | 567 |
|
| ... | ... |
@@ -676,7 +716,6 @@ void nsexec(void) |
| 676 | 676 |
*/ |
| 677 | 677 |
while (!ready) {
|
| 678 | 678 |
enum sync_t s; |
| 679 |
- int ret; |
|
| 680 | 679 |
|
| 681 | 680 |
syncfd = sync_child_pipe[1]; |
| 682 | 681 |
close(sync_child_pipe[0]); |
| ... | ... |
@@ -685,12 +724,6 @@ void nsexec(void) |
| 685 | 685 |
bail("failed to sync with child: next state");
|
| 686 | 686 |
|
| 687 | 687 |
switch (s) {
|
| 688 |
- case SYNC_ERR: |
|
| 689 |
- /* We have to mirror the error code of the child. */ |
|
| 690 |
- if (read(syncfd, &ret, sizeof(ret)) != sizeof(ret)) |
|
| 691 |
- bail("failed to sync with child: read(error code)");
|
|
| 692 |
- |
|
| 693 |
- exit(ret); |
|
| 694 | 688 |
case SYNC_USERMAP_PLS: |
| 695 | 689 |
/* |
| 696 | 690 |
* Enable setgroups(2) if we've been asked to. But we also |
| ... | ... |
@@ -759,7 +792,6 @@ void nsexec(void) |
| 759 | 759 |
ready = false; |
| 760 | 760 |
while (!ready) {
|
| 761 | 761 |
enum sync_t s; |
| 762 |
- int ret; |
|
| 763 | 762 |
|
| 764 | 763 |
syncfd = sync_grandchild_pipe[1]; |
| 765 | 764 |
close(sync_grandchild_pipe[0]); |
| ... | ... |
@@ -774,12 +806,6 @@ void nsexec(void) |
| 774 | 774 |
bail("failed to sync with child: next state");
|
| 775 | 775 |
|
| 776 | 776 |
switch (s) {
|
| 777 |
- case SYNC_ERR: |
|
| 778 |
- /* We have to mirror the error code of the child. */ |
|
| 779 |
- if (read(syncfd, &ret, sizeof(ret)) != sizeof(ret)) |
|
| 780 |
- bail("failed to sync with child: read(error code)");
|
|
| 781 |
- |
|
| 782 |
- exit(ret); |
|
| 783 | 777 |
case SYNC_CHILD_READY: |
| 784 | 778 |
ready = true; |
| 785 | 779 |
break; |
| ... | ... |
@@ -1,26 +1,28 @@ |
| 1 | 1 |
# OCI runtime-spec. When updating this, make sure you use a version tag rather |
| 2 | 2 |
# than a commit ID so it's much more obvious what version of the spec we are |
| 3 | 3 |
# using. |
| 4 |
-github.com/opencontainers/runtime-spec 29686dbc5559d93fb1ef402eeda3e35c38d75af4 |
|
| 4 |
+github.com/opencontainers/runtime-spec 29686dbc5559d93fb1ef402eeda3e35c38d75af4 # v1.0.1-59-g29686db |
|
| 5 |
+ |
|
| 5 | 6 |
# Core libcontainer functionality. |
| 6 |
-github.com/checkpoint-restore/go-criu v3.11 |
|
| 7 |
-github.com/mrunalp/fileutils ed869b029674c0e9ce4c0dfa781405c2d9946d08 |
|
| 8 |
-github.com/opencontainers/selinux v1.2.2 |
|
| 9 |
-github.com/seccomp/libseccomp-golang 84e90a91acea0f4e51e62bc1a75de18b1fc0790f |
|
| 10 |
-github.com/sirupsen/logrus a3f95b5c423586578a4e099b11a46c2479628cac |
|
| 11 |
-github.com/syndtr/gocapability db04d3cc01c8b54962a58ec7e491717d06cfcc16 |
|
| 12 |
-github.com/vishvananda/netlink 1e2e08e8a2dcdacaae3f14ac44c5cfa31361f270 |
|
| 7 |
+github.com/checkpoint-restore/go-criu 17b0214f6c48980c45dc47ecb0cfd6d9e02df723 # v3.11 |
|
| 8 |
+github.com/mrunalp/fileutils 7d4729fb36185a7c1719923406c9d40e54fb93c7 |
|
| 9 |
+github.com/opencontainers/selinux 3a1f366feb7aecbf7a0e71ac4cea88b31597de9e # v1.2.2 |
|
| 10 |
+github.com/seccomp/libseccomp-golang 689e3c1541a84461afc49c1c87352a6cedf72e9c # v0.9.1 |
|
| 11 |
+github.com/sirupsen/logrus 8bdbc7bcc01dcbb8ec23dc8a28e332258d25251f # v1.4.1 |
|
| 12 |
+github.com/syndtr/gocapability d98352740cb2c55f81556b63d4a1ec64c5a319c2 |
|
| 13 |
+github.com/vishvananda/netlink 1e2e08e8a2dcdacaae3f14ac44c5cfa31361f270 |
|
| 14 |
+ |
|
| 13 | 15 |
# systemd integration. |
| 14 |
-github.com/coreos/go-systemd v14 |
|
| 15 |
-github.com/coreos/pkg v3 |
|
| 16 |
-github.com/godbus/dbus v3 |
|
| 17 |
-github.com/golang/protobuf 18c9bb3261723cd5401db4d0c9fbc5c3b6c70fe8 |
|
| 16 |
+github.com/coreos/go-systemd 95778dfbb74eb7e4dbaf43bf7d71809650ef8076 # v19 |
|
| 17 |
+github.com/godbus/dbus 2ff6f7ffd60f0f2410b3105864bdd12c7894f844 # v5.0.1 |
|
| 18 |
+github.com/golang/protobuf 925541529c1fa6821df4e44ce2723319eb2be768 # v1.0.0 |
|
| 19 |
+ |
|
| 18 | 20 |
# Command-line interface. |
| 19 |
-github.com/cyphar/filepath-securejoin v0.2.1 |
|
| 20 |
-github.com/docker/go-units v0.2.0 |
|
| 21 |
-github.com/urfave/cli d53eb991652b1d438abdd34ce4bfa3ef1539108e |
|
| 22 |
-golang.org/x/sys 41f3e6584952bb034a481797859f6ab34b6803bd https://github.com/golang/sys |
|
| 21 |
+github.com/cyphar/filepath-securejoin a261ee33d7a517f054effbf451841abaafe3e0fd # v0.2.2 |
|
| 22 |
+github.com/docker/go-units 47565b4f722fb6ceae66b95f853feed578a4a51c # v0.3.3 |
|
| 23 |
+github.com/urfave/cli cfb38830724cc34fedffe9a2a29fb54fa9169cd1 # v1.20.0 |
|
| 24 |
+golang.org/x/sys 9eafafc0a87e0fd0aeeba439a4573537970c44c7 https://github.com/golang/sys |
|
| 23 | 25 |
|
| 24 | 26 |
# console dependencies |
| 25 |
-github.com/containerd/console 2748ece16665b45a47f884001d5831ec79703880 |
|
| 26 |
-github.com/pkg/errors v0.8.0 |
|
| 27 |
+github.com/containerd/console 0650fd9eeb50bab4fc99dceb9f2e14cf58f36e7f |
|
| 28 |
+github.com/pkg/errors ba968bfe8b2f7e042a574c888954fccecfa385b4 # v0.8.1 |