gunk-dev/the-valley

nodump_linux.go

sourceba6dab50f578main's published tip history
611 bytes
1// Package nodump makes a process non-dumpable, so the secrets it holds in
2// memory stay in it alone. The publisher's link command holds a new
3// link's secret, and valley-web with readers holds the links readers
4// post and their sessions' tokens.
5package nodump
6
7import "syscall"
8
9// Set makes this process non-dumpable, prctl(PR_SET_DUMPABLE, 0): it
10// leaves no core dump, and no process of the same user may read its
11// memory through ptrace or /proc.
12func Set() error {
13 if _, _, errno := syscall.RawSyscall(syscall.SYS_PRCTL, syscall.PR_SET_DUMPABLE, 0, 0); errno != 0 {
14 return errno
15 }
16 return nil
17}