From a129334aefa559e36783347c5243303a6dd8b104 Mon Sep 17 00:00:00 2001 From: Andinus Date: Wed, 15 Apr 2020 00:24:55 +0530 Subject: [PATCH] Compile for non OpenBSD systems Previously the compilation would fail for non OpenBSD systems & the user had to manage it themselves. Now it compiles on non OpenBSD systems but returns nil immediately because unveil isn't supported on those systems. --- block.go | 2 ++ block_other.go | 9 +++++++++ commands.go | 2 ++ commands_other.go | 9 +++++++++ path.go | 2 ++ path_other.go | 15 +++++++++++++++ paths.go | 2 ++ paths_other.go | 15 +++++++++++++++ 8 files changed, 56 insertions(+) create mode 100644 block_other.go create mode 100644 commands_other.go create mode 100644 path_other.go create mode 100644 paths_other.go diff --git a/block.go b/block.go index c16a1eb..5a46693 100644 --- a/block.go +++ b/block.go @@ -1,3 +1,5 @@ +// +build openbsd + package lynx import "golang.org/x/sys/unix" diff --git a/block_other.go b/block_other.go new file mode 100644 index 0000000..65b7131 --- /dev/null +++ b/block_other.go @@ -0,0 +1,9 @@ +// +build !openbsd + +package lynx + +// UnveilBlock is just a wrapper around unix.UnveilBlock, it does +// nothing on non OpenBSD systems. +func UnveilBlock() error { + return nil +} diff --git a/commands.go b/commands.go index 5d57546..0d645ff 100644 --- a/commands.go +++ b/commands.go @@ -1,3 +1,5 @@ +// +build openbsd + package lynx import ( diff --git a/commands_other.go b/commands_other.go new file mode 100644 index 0000000..794d18b --- /dev/null +++ b/commands_other.go @@ -0,0 +1,9 @@ +// +build !openbsd + +package lynx + +// UnveilCommands takes a slice of commands & unveils them one by one, +// it does nothing on non OpenBSD systems. +func UnveilCommands(_ []string) error { + return nil +} diff --git a/path.go b/path.go index 8f3dcc2..a04c723 100644 --- a/path.go +++ b/path.go @@ -1,3 +1,5 @@ +// +build openbsd + package lynx import "golang.org/x/sys/unix" diff --git a/path_other.go b/path_other.go new file mode 100644 index 0000000..a0273c9 --- /dev/null +++ b/path_other.go @@ -0,0 +1,15 @@ +// +build !openbsd + +package lynx + +// UnveilPath takes a path, permission & unveils it, it does nothing +// on non OpenBSD systems. +func UnveilPath(_ string, _ string) error { + return nil +} + +// UnveilPathStrict is just a wrapper around unix.Unveil. It does +// nothing on non OpenBSD systems. +func UnveilPathStrict(_ string, _ string) error { + return nil +} diff --git a/paths.go b/paths.go index 2a3986e..589cca5 100644 --- a/paths.go +++ b/paths.go @@ -1,3 +1,5 @@ +// +build openbsd + // Package lynx is a simple wrapper to unveil. package lynx diff --git a/paths_other.go b/paths_other.go new file mode 100644 index 0000000..de2c2b1 --- /dev/null +++ b/paths_other.go @@ -0,0 +1,15 @@ +// +build !openbsd + +package lynx + +// UnveilPaths takes a map of path, permission & unveils them one by +// one, it does nothing on non OpenBSD systems. +func UnveilPaths(_ map[string]string) error { + return nil +} + +// UnveilPathsStrict takes a map of path, permission & unveils them +// one by one, it does nothing on non OpenBSD systems. +func UnveilPathsStrict(_ map[string]string) error { + return nil +}