aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2021-08-26 22:26:56 -0700
committerAndrew G. Morgan <morgan@kernel.org>2021-08-26 22:26:56 -0700
commit386af0edbc9eec3b382451da782a08ba4632db06 (patch)
tree2c22b546005de9a14515a0b6478d9699ad8d49cc
parenta56162c6900d203c5ac63a2b41b46cb0c45c645f (diff)
downloadlibcap-386af0edbc9eec3b382451da782a08ba4632db06.tar.gz
Stop installing the cap and psx packages, but do install captree.
We also add the cap.ProcRoot() API to let the user redirect to their local /proc/ directory - in case anyone runs with an unusual setup like that. I've been studying the downstream package definitions and no one it doesn't seem popular to build the Go packages. Indeed, Go folk themselves prefer to install via modules anyway, so we're getting with the program. However, if folk want to build test the Go stuff as part of a package build and run an install as well, we reward them with the 'captree' binary. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--cap/iab.go17
-rw-r--r--go/Makefile19
-rw-r--r--goapps/captree/captree.go4
3 files changed, 33 insertions, 7 deletions
diff --git a/cap/iab.go b/cap/iab.go
index 816118f..1be921c 100644
--- a/cap/iab.go
+++ b/cap/iab.go
@@ -366,11 +366,26 @@ func parseHex(hex string, invert bool) []uint32 {
return result
}
+var procRoot = "/proc"
+
+// ProcRoot sets the local mount point for the Linux /proc filesystem.
+// It defaults to "/proc", but might be mounted elsewhere on any given
+// system. The function returns the previous value of the local mount
+// point. If the user attempts to set it to "", the value is left
+// unchanged.
+func ProcRoot(path string) string {
+ was := procRoot
+ if path != "" {
+ procRoot = path
+ }
+ return was
+}
+
// IABGetPID returns the IAB tuple of a specified process. The kernel
// ABI does not support this query via system calls, so the function
// works by parsing the /proc/<pid>/status file content.
func IABGetPID(pid int) (*IAB, error) {
- tf := fmt.Sprintf("/proc/%d/status", pid)
+ tf := fmt.Sprintf("%s/%d/status", procRoot, pid)
d, err := ioutil.ReadFile(tf)
if err != nil {
return nil, err
diff --git a/go/Makefile b/go/Makefile
index 2100eed..ce464d1 100644
--- a/go/Makefile
+++ b/go/Makefile
@@ -121,13 +121,20 @@ ifeq ($(CGO_REQUIRED),0)
endif
$(SUDO) ../progs/tcapsh-static --cap-uid=$$(id -u) --caps="cap_setpcap=ep" --iab="^cap_setpcap" -- -c ./b210613
+# As of libcap-2.55 We stopped installing the cap and psx packages as
+# part of the install. Most distribution's packagers skip the Go
+# builds, so it was not well used any way. The new hotness is to just
+# use Go modules and download the packages from a tagged release in
+# the git repository. For an example of how to do this from scratch:
+#
+# https://sites.google.com/site/fullycapable/getting-started-with-go/building-go-programs-that-manipulate-capabilities
+#
+# For those brave souls that do include the Go build (testing) as part
+# of their packaging, we reward them with a copy of the captree
+# utility!
install: all
- rm -rf $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/psx
- mkdir -p $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/psx
- install -m 0644 vendor/$(IMPORTDIR)/psx/* $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/psx
- mkdir -p $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/cap
- rm -rf $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/cap/*
- install -m 0644 vendor/$(IMPORTDIR)/cap/* $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/cap
+ mkdir -p -m 0755 $(FAKEROOT)$(SBINDIR)
+ install -m 0755 captree $(FAKEROOT)$(SBINDIR)
clean:
rm -f *.o *.so *~ mknames ok good-names.go
diff --git a/goapps/captree/captree.go b/goapps/captree/captree.go
index 527150c..aa94cd3 100644
--- a/goapps/captree/captree.go
+++ b/goapps/captree/captree.go
@@ -267,6 +267,10 @@ func rDump(pids map[string]*task, pid, stub, lstub, estub string) {
func main() {
flag.Parse()
+ // Just in case the user wants to override this, we set the
+ // cap package up to find it.
+ cap.ProcRoot(*proc)
+
pids := make(map[string]*task)
pids["0"] = &task{
cmd: "<kernel>",