summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-18 11:04:11 +0530
committerLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-18 11:04:11 +0530
commit5ea7cae973e8329ae768c35bda41e656f974815d (patch)
treed7ce04c820c585e3604f91385beb8090f9dffc4c
parent60298a69538ccdda417613a09e5acbd917bfc53a (diff)
downloadlegit-5ea7cae973e8329ae768c35bda41e656f974815d.tar.gz
legit-5ea7cae973e8329ae768c35bda41e656f974815d.tar.bz2
legit-5ea7cae973e8329ae768c35bda41e656f974815d.zip
unveil: init
-rw-r--r--main.go4
-rw-r--r--static/style.css5
-rw-r--r--unveil.go28
3 files changed, 37 insertions, 0 deletions
diff --git a/main.go b/main.go
index 3f8cad8..8a1c87e 100644
--- a/main.go
+++ b/main.go
@@ -20,6 +20,10 @@ func main() {
log.Fatal(err)
}
+ // for path := range []string{c.Dirs.Static, c.Repo.ScanPath, c.Dirs.Templates} {
+ // Unveil(path, "r")
+ // }
+
mux := routes.Handlers(c)
addr := fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port)
log.Println("starting server on", addr)
diff --git a/static/style.css b/static/style.css
index 340635e..1a36ec7 100644
--- a/static/style.css
+++ b/static/style.css
@@ -210,6 +210,11 @@ a:hover {
.line-numbers {
white-space: pre-line;
+ -moz-user-select: -moz-none;
+ -khtml-user-select: none;
+ -webkit-user-select: none;
+ -o-user-select: none;
+ user-select: none;
}
.file-wrapper {
diff --git a/unveil.go b/unveil.go
new file mode 100644
index 0000000..389dfeb
--- /dev/null
+++ b/unveil.go
@@ -0,0 +1,28 @@
+//go:build openbsd
+// +build openbsd
+
+package main
+
+/*
+#include <stdlib.h>
+#include <unistd.h>
+*/
+import "C"
+
+import (
+ "fmt"
+ "unsafe"
+)
+
+func Unveil(path string, perms string) error {
+ cpath := C.CString(path)
+ defer C.free(unsafe.Pointer(cpath))
+ cperms := C.CString(perms)
+ defer C.free(unsafe.Pointer(cperms))
+
+ rv, err := C.unveil(cpath, cperms)
+ if rv != 0 {
+ return fmt.Errorf("unveil(%s, %s) failure (%d)", path, perms, err)
+ }
+ return nil
+}