From a61d7a40a2e11576173c2f446a76f1ecde8e411e Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 3 Apr 2019 00:23:44 -0700 Subject: [PATCH] binfmt_misc: fix building on windows Signed-off-by: Tonis Tiigi --- util/binfmt_misc/check.go | 5 +---- util/binfmt_misc/check_unix.go | 14 ++++++++++++++ util/binfmt_misc/check_windows.go | 10 ++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 util/binfmt_misc/check_unix.go create mode 100644 util/binfmt_misc/check_windows.go diff --git a/util/binfmt_misc/check.go b/util/binfmt_misc/check.go index 2f2352c8..4caf5944 100644 --- a/util/binfmt_misc/check.go +++ b/util/binfmt_misc/check.go @@ -8,7 +8,6 @@ import ( "os" "os/exec" "path/filepath" - "syscall" ) func check(bin string) error { @@ -37,9 +36,7 @@ func check(bin string) error { f.Close() cmd := exec.Command("/check") - cmd.SysProcAttr = &syscall.SysProcAttr{ - Chroot: tmpdir, - } + withChroot(cmd, tmpdir) err = cmd.Run() return err } diff --git a/util/binfmt_misc/check_unix.go b/util/binfmt_misc/check_unix.go new file mode 100644 index 00000000..22c7ce7c --- /dev/null +++ b/util/binfmt_misc/check_unix.go @@ -0,0 +1,14 @@ +// +build !windows + +package binfmt_misc + +import ( + "os/exec" + "syscall" +) + +func withChroot(cmd *exec.Cmd, dir string) { + cmd.SysProcAttr = &syscall.SysProcAttr{ + Chroot: dir, + } +} diff --git a/util/binfmt_misc/check_windows.go b/util/binfmt_misc/check_windows.go new file mode 100644 index 00000000..3c28c8bd --- /dev/null +++ b/util/binfmt_misc/check_windows.go @@ -0,0 +1,10 @@ +// +build windows + +package binfmt_misc + +import ( + "os/exec" +) + +func withChroot(cmd *exec.Cmd, dir string) { +}