diff options
author | Andinus <andinus@nand.sh> | 2020-04-15 19:20:22 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-04-15 19:20:22 +0530 |
commit | 6e5a88bc7749b3fe4d9419b95a2ba2b596e3f837 (patch) | |
tree | 3cbea158f28ad56729dd88705bc6a4b94083f7b9 /unveil.go | |
parent | f479b82ff8aa13b953590a13d31de93de8e53ec2 (diff) | |
download | lynx-6e5a88bc7749b3fe4d9419b95a2ba2b596e3f837.tar.gz |
Rename func UnveilPath to Unveil
UnveilPath is confusing, it's kept only for backwards compatibility & users should use Unveil & UnveilStrict instead of UnveilPath & UnveilPathStrict.
Diffstat (limited to 'unveil.go')
-rw-r--r-- | unveil.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/unveil.go b/unveil.go new file mode 100644 index 0000000..3069ec6 --- /dev/null +++ b/unveil.go @@ -0,0 +1,39 @@ +// +build openbsd + +package lynx + +import "golang.org/x/sys/unix" + +// Unveil takes a path, permission & unveils it, returning an +// error if unveil fails. "no such file or directory" error is +// ignored. +func Unveil(path string, flags string) (err error) { + err = unix.Unveil(path, flags) + + // "no such file or directory" error is ignored. + if err != nil && err.Error() != "no such file or directory" { + // Better error message could be returned like + // one that includes the path on which unveil + // failed. + return err + } + // Returning nil because err can be "no such file or + // directory" which needs to be ignored. + return nil +} + +// UnveilPath is kept for backwards compatibility, use Unveil instead. +func UnveilPath(path string, flags string) (err error) { + return Unveil(path, flags) +} + +// UnveilStrict is just a wrapper around unix.Unveil. +func UnveilStrict(path string, flags string) error { + return unix.Unveil(path, flags) +} + +// UnveilPathStrict is kept for backwards compatibility, use +// UnveilStrict instead. +func UnveilPathStrict(path string, flags string) error { + return UnveilStrict(path, flags) +} |