aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2020-12-08 22:11:31 -0800
committerAndrew G. Morgan <morgan@kernel.org>2020-12-08 22:26:34 -0800
commit69e33835586d6cf59bf635b7cb287960ed93af1f (patch)
tree5210e655462c50e95e509ec9d2454311852ad22f
parent2b75e6c316d8f1a8b8549bc352858b0232f40a58 (diff)
downloadlibcap-69e33835586d6cf59bf635b7cb287960ed93af1f.tar.gz
Add a go.mod file for building gowns.
Since go 1.15 doesn't require the wrapping linker trick, I'm recommending that version of Go for building it. Also add a test of building the setid and gowns sources in the .../go/ directory. At this stage, I'm imagining a tutorial on how gowns works here: https://sites.google.com/site/fullycapable/getting-started-with-go but I haven't started writing that yet. I first want to confirm the state of all the features I want to use. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--go/Makefile17
-rw-r--r--goapps/gowns/go.mod5
2 files changed, 20 insertions, 2 deletions
diff --git a/go/Makefile b/go/Makefile
index 70a8abf..bfee9f4 100644
--- a/go/Makefile
+++ b/go/Makefile
@@ -18,7 +18,7 @@ CAPGOPACKAGE=$(PKGDIR)/cap.a
DEPS=../libcap/libcap.a ../libcap/libpsx.a
-all: $(PSXGOPACKAGE) $(CAPGOPACKAGE) web compare-cap try-launching psx-signals
+all: $(PSXGOPACKAGE) $(CAPGOPACKAGE) web setid gowns compare-cap try-launching psx-signals
$(DEPS):
make -C ../libcap all
@@ -61,6 +61,12 @@ ifeq ($(RAISE_GO_FILECAP),yes)
@echo "NOTE: RAISED cap_setpcap,cap_net_bind_service ON web binary"
endif
+setid: ../goapps/setid/setid.go $(CAPGOPACKAGE)
+ GO111MODULE=off CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" GOPATH=$(GOPATH) $(GO) build -o $@ $(GOBUILDTAG) $<
+
+gowns: ../goapps/gowns/gowns.go $(CAPGOPACKAGE)
+ GO111MODULE=off CGO_ENABLED="$(CGO_REQUIRED)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" GOPATH=$(GOPATH) $(GO) build -o $@ $(GOBUILDTAG) $<
+
ok: ok.go
GO111MODULE=off CGO_ENABLED=0 GOPATH=$(GOPATH) $(GO) build $<
@@ -79,8 +85,14 @@ test: all
GO111MODULE=off CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" GOPATH="$(GOPATH)" $(GO) test $(IMPORTDIR)/cap
LD_LIBRARY_PATH=../libcap ./compare-cap
./psx-signals
+ ./setid --caps=false
+ ./gowns -- -c "echo gowns runs"
+# Note, the user namespace doesn't require sudo, but I wanted to avoid
+# requiring that the hosting kernel supports user namespaces for the
+# regular test case.
sudotest: test ../progs/tcapsh-static
+ ./gowns --ns -- -c "echo gowns runs with user namespace"
./try-launching
ifeq ($(CGO_REQUIRED),0)
./try-launching-cgo
@@ -100,7 +112,8 @@ install: all
install -m 0644 src/$(IMPORTDIR)/cap/* $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/cap
clean:
- rm -f *.o *.so *~ mknames web ok good-names.go
+ rm -f *.o *.so *~ mknames ok good-names.go
+ rm -f web setid gowns
rm -f compare-cap try-launching try-launching-cgo
rm -f $(topdir)/cap/*~ $(topdir)/psx/*~
rm -f psx-signals
diff --git a/goapps/gowns/go.mod b/goapps/gowns/go.mod
new file mode 100644
index 0000000..8cb3752
--- /dev/null
+++ b/goapps/gowns/go.mod
@@ -0,0 +1,5 @@
+module gowns
+
+go 1.15
+
+require kernel.org/pub/linux/libs/security/libcap/cap v0.2.45