aboutsummaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2019-12-10 19:26:21 -0800
committerAndrew G. Morgan <morgan@kernel.org>2019-12-10 19:51:00 -0800
commit2bd8e293982acc034554b7f66d6b969f24199876 (patch)
tree62cf12c9e72d69f407c1ffb10a14183cd4a314b6 /go
parent37b646801aba5779abfb0171865acd35b7a21d98 (diff)
downloadlibcap-2bd8e293982acc034554b7f66d6b969f24199876.tar.gz
Realign around the evolving Go support for POSIX semantics syscalls.
I've moved my go.patch to address: https://github.com/golang/go/issues/1435 into a development patch against the upstream Go sources: https://go-review.googlesource.com/c/go/+/210639/ and the review process will likely evolve it somewhat. I plan to ensure that working libcap/cap Go package is in sync with the working state of the above development change. As such, there is no need to keep the patch here any more. I'll keep the tests for now, as it isn't clear to me how the Go source tree supports tests that require privilege yet. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
Diffstat (limited to 'go')
-rwxr-xr-xgo/cgo-required.sh10
-rwxr-xr-xgo/syscalls.sh19
2 files changed, 12 insertions, 17 deletions
diff --git a/go/cgo-required.sh b/go/cgo-required.sh
index 8f22d43..5e7e98f 100755
--- a/go/cgo-required.sh
+++ b/go/cgo-required.sh
@@ -1,11 +1,11 @@
#!/bin/bash
#
-# Runtime check for whether or not syscall.PosixSyscall is available to
-# the working go runtime or not. If it isn't we always have to use
-# libcap/psx to get POSIX semantics for syscalls that change security
-# state.
+# Runtime check for whether or not syscall.PerOSThreadSyscall is
+# available to the working go runtime or not. If it isn't we always
+# have to use libcap/psx to get POSIX semantics for syscalls that
+# change security state.
-if [ -z "$(go doc syscall 2>/dev/null|grep PosixSyscall)" ]; then
+if [ -z "$(go doc syscall 2>/dev/null|grep PerOSThreadSyscall)" ]; then
echo "1"
else
echo "0"
diff --git a/go/syscalls.sh b/go/syscalls.sh
index eeba450..b91424d 100755
--- a/go/syscalls.sh
+++ b/go/syscalls.sh
@@ -6,14 +6,9 @@ if [[ -z "$dir" ]]; then
exit 1
fi
-# This is something that we should revisit if golang adopts my
-# syscall.PosixSyscall patch. At that stage, we won't need cgo to
-# support a pure Go program. However, we will need a to use the cgo
-# version if the program being compiled actually needs cgo. That is,
-# we should have two permenant files that use +build lines to control
-# which one is built based on cgo or not.
-
-if [ -z "$(go doc syscall 2>/dev/null|grep PosixSyscall)" ]; then
+# We use one or the other syscalls.go file based on whether or not the
+# Go runtime include syscall.PerOSThreadSyscall or not.
+if [ -z "$(go doc syscall 2>/dev/null|grep PerOSThreadSyscall)" ]; then
rm -f "${dir}/syscalls_cgo.go"
cat > "${dir}/syscalls.go" <<EOF
// +build linux
@@ -26,7 +21,7 @@ import (
)
// callKernel variables overridable for testing purposes.
-// (Go build tree has no syscall.PosixSyscall support.)
+// (Go build tree has no syscall.PerOSThreadSyscall support.)
var callWKernel = psx.Syscall3
var callWKernel6 = psx.Syscall6
var callRKernel = syscall.RawSyscall
@@ -45,9 +40,9 @@ package cap
import "syscall"
// callKernel variables overridable for testing purposes.
-// (Go build tree contains syscall.PosixSyscall support.)
-var callWKernel = syscall.PosixSyscall
-var callWKernel6 = syscall.PosixSyscall6
+// (Go build tree contains syscall.PerOSThreadSyscall support.)
+var callWKernel = syscall.PerOSThreadSyscall
+var callWKernel6 = syscall.PerOSThreadSyscall6
var callRKernel = syscall.RawSyscall
var callRKernel6 = syscall.RawSyscall6
EOF