~egtann/migrate

ref: f8bba57067c303761315e2916cc06bc61880b2cd migrate/security_openbsd.go -rw-r--r-- 639 bytes
f8bba570 — Evan Tann update module path 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package migrate

import (
	"github.com/pkg/errors"
	"golang.org/x/sys/unix"
)

// Pledge to the kernel the required syscalls on OpenBSD.
func Pledge() error {
	const promises = "stdio rpath inet tty"
	if err := unix.Pledge(promises, ""); err != nil {
		return err
	}
	return nil
}

// Unveil only specific directories containing migrations and/or TLS certs to
// the program.
func Unveil(paths []string) error {
	for _, p := range paths {
		if err := unix.Unveil(p, "r"); err != nil {
			return errors.Wrapf(err, "unveil %s", p)
		}
	}
	if err := unix.UnveilBlock(); err != nil {
		return errors.Wrap(err, "unveil block")
	}
	return nil
}