gunk-dev/the-valley

nodump_linux.go

source535d69c9a69emain's published tip history
411 bytes
1package main
2
3import "syscall"
4
5// noCoreDump makes this process non-dumpable, prctl(PR_SET_DUMPABLE, 0):
6// it leaves no core dump, and no process of the same user may read its
7// memory through ptrace or /proc, so a link's secret stays in it alone.
8func noCoreDump() error {
9 if _, _, errno := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_DUMPABLE, 0, 0); errno != 0 {
10 return errno
11 }
12 return nil
13}