summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-04-15 00:24:55 +0530
committerAndinus <andinus@nand.sh>2020-04-15 00:24:55 +0530
commita129334aefa559e36783347c5243303a6dd8b104 (patch)
treedfd3964ccf879037b14a7a917641963b45e123b9
parent0dfcf8cb81daa80aa751a5a40c243e64ee030929 (diff)
downloadlynx-a129334aefa559e36783347c5243303a6dd8b104.tar.gz
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.
-rw-r--r--block.go2
-rw-r--r--block_other.go9
-rw-r--r--commands.go2
-rw-r--r--commands_other.go9
-rw-r--r--path.go2
-rw-r--r--path_other.go15
-rw-r--r--paths.go2
-rw-r--r--paths_other.go15
8 files changed, 56 insertions, 0 deletions
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
+}