Skip to content

Instantly share code, notes, and snippets.

@swalberg
Created June 23, 2020 15:55
Show Gist options
  • Save swalberg/c4b50e395c239920863f898551a12c24 to your computer and use it in GitHub Desktop.
Save swalberg/c4b50e395c239920863f898551a12c24 to your computer and use it in GitHub Desktop.
(gdb) b main.capset
Breakpoint 1 at 0x498380: file /root/go/src/github.com/swalberg/test/capset_linux.go, line 9.
(gdb) r
Starting program: /root/go/src/github.com/swalberg/test/test
2020/06/23 08:55:10 Starting Envoy with CAP_NET_BIND_SERVICE capability
Breakpoint 1, main.capset (~r0=...) at /root/go/src/github.com/swalberg/test/capset_linux.go:9
9 func capset() error {
(gdb) n
10 header := unix.CapUserHeader{unix.LINUX_CAPABILITY_VERSION_3, int32(os.Getpid())}
(gdb) bt
#0 main.capset (~r0=...) at /root/go/src/github.com/swalberg/test/capset_linux.go:10
#1 0x00000000004984f6 in main.main () at /root/go/src/github.com/swalberg/test/wrapper.go:12
(gdb) n
11 data := unix.CapUserData{}
(gdb) n
12 if err := unix.Capget(&header, &data); err != nil {
(gdb) n
16 data.Inheritable = (1 << unix.CAP_NET_BIND_SERVICE)
(gdb) n
18 if err := unix.Capset(&header, &data); err != nil {
(gdb) bt
#0 main.capset (~r0=...) at /root/go/src/github.com/swalberg/test/capset_linux.go:18
#1 0x0000000000000000 in ?? ()
(gdb) b main.capset
Breakpoint 1 at 0x498480: file /root/go/src/github.com/swalberg/test/capset_linux.go, line 10.
(gdb) s
The program is not being run.
(gdb) r
Starting program: /root/go/src/github.com/swalberg/test/test
2020/06/23 08:53:25 Starting Envoy with CAP_NET_BIND_SERVICE capability
Breakpoint 1, main.capset (~r0=...) at /root/go/src/github.com/swalberg/test/capset_linux.go:10
10 func capset() error {
(gdb) bt
#0 main.capset (~r0=...) at /root/go/src/github.com/swalberg/test/capset_linux.go:10
#1 0x0000000000498656 in main.main () at /root/go/src/github.com/swalberg/test/wrapper.go:12
(gdb) n
11 fmt.Println("Why?")
(gdb) n
Why?
12 header := unix.CapUserHeader{unix.LINUX_CAPABILITY_VERSION_3, int32(os.Getpid())}
(gdb) n
13 data := unix.CapUserData{}
(gdb) n
14 if err := unix.Capget(&header, &data); err != nil {
(gdb) n
18 data.Inheritable = (1 << unix.CAP_NET_BIND_SERVICE)
(gdb) n
20 if err := unix.Capset(&header, &data); err != nil {
(gdb) bt
#0 main.capset (~r0=...) at /root/go/src/github.com/swalberg/test/capset_linux.go:20
#1 0x0000000000498656 in main.main () at /root/go/src/github.com/swalberg/test/wrapper.go:12
(gdb)
@swalberg
Copy link
Author

Happening on go version go1.13.3 linux/amd64 and whatever https://github.com/datawire/ambassador is built with, which also may be 1.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment