diff options
author | Andinus <andinus@nand.sh> | 2020-04-06 14:59:25 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-04-06 14:59:25 +0530 |
commit | 202c8a13803b76b838f99cbd887616c67c9aedde (patch) | |
tree | 5bd265a0b0a11d5e329f750059471217cceb32c3 /cmd | |
parent | 0883e2777d35eea4e38a20b16ebac6b1c8d2ac5b (diff) | |
download | cetus-202c8a13803b76b838f99cbd887616c67c9aedde.tar.gz |
Switch to lynx & remove custom unveil wrappers
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/cetus/main_openbsd.go | 66 |
1 files changed, 17 insertions, 49 deletions
diff --git a/cmd/cetus/main_openbsd.go b/cmd/cetus/main_openbsd.go index b978e7c..7e19f5b 100644 --- a/cmd/cetus/main_openbsd.go +++ b/cmd/cetus/main_openbsd.go @@ -3,12 +3,11 @@ package main import ( - "fmt" "log" - "strings" "golang.org/x/sys/unix" "tildegit.org/andinus/cetus/cache" + "tildegit.org/andinus/lynx" ) func main() { @@ -17,41 +16,28 @@ func main() { } func unveil() { - unveilL := make(map[string]string) + paths := make(map[string]string) - // We unveil the whole cache directory. - err = unix.Unveil(cache.Dir(), "rwc") + paths[cache.Dir()] = "rwc" + paths["/dev/null"] = "rw" // required by feh + paths["/etc/resolv.conf"] = "r" + + // ktrace output + paths["/usr/libexec/ld.so"] = "r" + paths["/var/run/ld.so.hints"] = "r" + paths["/usr/lib"] = "r" + paths["/dev/urandom"] = "r" + paths["/etc/hosts"] = "r" + paths["/etc/ssl"] = "r" + + err := lynx.UnveilPaths(paths) if err != nil { log.Fatal(err) } - unveilL["/dev/null"] = "rw" // required by feh - unveilL["/etc/resolv.conf"] = "r" - - // ktrace output - unveilL["/usr/libexec/ld.so"] = "r" - unveilL["/var/run/ld.so.hints"] = "r" - unveilL["/usr/lib"] = "r" - unveilL["/dev/urandom"] = "r" - unveilL["/etc/hosts"] = "r" - unveilL["/etc/ssl"] = "r" - - for k, v := range unveilL { - err = unix.Unveil(k, v) - if err != nil && err.Error() == "no such file or directory" { - log.Printf("WARN: Unveil failed on %s", k) - } else if err != nil { - log.Fatal(fmt.Sprintf("%s :: %s\n%s", k, v, - err.Error())) - } - } + commands := []string{"feh", "gsettings", "pcmanfm", "notify-send"} - err = unveilCmds([]string{ - "feh", - "gsettings", - "pcmanfm", - "notify-send", - }) + err = lynx.UnveilCommands(commands) if err != nil { log.Fatal(err) } @@ -62,21 +48,3 @@ func unveil() { log.Fatal(err) } } - -// unveilCmds will unveil commands. -func unveilCmds(cmds []string) error { - pathList := strings.Split(getEnv("PATH", ""), ":") - // Unveil each command. - for _, cmd := range cmds { - for _, path := range pathList { - err = unix.Unveil(fmt.Sprintf("%s/%s", path, cmd), "rx") - - if err != nil && err.Error() != "no such file or directory" { - return fmt.Errorf("%s\n%s", - cmd, - err.Error()) - } - } - } - return nil -} |