Update to lynx v0.4.0
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
d5b95cbec7
commit
593a8ef24e
2
go.mod
2
go.mod
|
@ -4,5 +4,5 @@ go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
golang.org/x/sys v0.0.0-20200406113430-c6e801f48ba2
|
golang.org/x/sys v0.0.0-20200406113430-c6e801f48ba2
|
||||||
tildegit.org/andinus/lynx v0.2.0
|
tildegit.org/andinus/lynx v0.4.0
|
||||||
)
|
)
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -5,3 +5,5 @@ tildegit.org/andinus/lynx v0.1.0 h1:7YjyF8h7MBGKRgQZT0j0I3uHRPf3mI2GMiDujXVlLS0=
|
||||||
tildegit.org/andinus/lynx v0.1.0/go.mod h1:/PCNkKwfJ7pb6ziHa76a4gYp1R9S1Ro4ANjQwzSpBIk=
|
tildegit.org/andinus/lynx v0.1.0/go.mod h1:/PCNkKwfJ7pb6ziHa76a4gYp1R9S1Ro4ANjQwzSpBIk=
|
||||||
tildegit.org/andinus/lynx v0.2.0 h1:cBoAWqC/osZJE4VPdB0HhIEpMIC4A4eI9nEbHR/9Qvk=
|
tildegit.org/andinus/lynx v0.2.0 h1:cBoAWqC/osZJE4VPdB0HhIEpMIC4A4eI9nEbHR/9Qvk=
|
||||||
tildegit.org/andinus/lynx v0.2.0/go.mod h1:/PCNkKwfJ7pb6ziHa76a4gYp1R9S1Ro4ANjQwzSpBIk=
|
tildegit.org/andinus/lynx v0.2.0/go.mod h1:/PCNkKwfJ7pb6ziHa76a4gYp1R9S1Ro4ANjQwzSpBIk=
|
||||||
|
tildegit.org/andinus/lynx v0.4.0 h1:bAxZLOdWy66+qJ3bDWjkbmJfCWTIOZ8hMGzYt7T7Bxk=
|
||||||
|
tildegit.org/andinus/lynx v0.4.0/go.mod h1:/PCNkKwfJ7pb6ziHa76a4gYp1R9S1Ro4ANjQwzSpBIk=
|
||||||
|
|
|
@ -6,15 +6,18 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"tildegit.org/andinus/grus/lexical"
|
"tildegit.org/andinus/grus/lexical"
|
||||||
|
"tildegit.org/andinus/lynx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func grus() {
|
func main() {
|
||||||
|
initGrus()
|
||||||
|
|
||||||
if len(os.Args) == 1 {
|
if len(os.Args) == 1 {
|
||||||
fmt.Println("Usage: grus <word> <dictionaries>")
|
fmt.Println("Usage: grus <word> <dictionaries>")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
version := "v0.3.0"
|
version := "v0.3.1"
|
||||||
|
|
||||||
// Print version if first argument is version.
|
// Print version if first argument is version.
|
||||||
if os.Args[1] == "version" {
|
if os.Args[1] == "version" {
|
||||||
|
@ -134,10 +137,49 @@ func grus() {
|
||||||
if !envVar["GRUS_SEARCH_ALL"] {
|
if !envVar["GRUS_SEARCH_ALL"] {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initGrus() {
|
||||||
|
// We need less permissions on these conditions.
|
||||||
|
if len(os.Args) == 1 ||
|
||||||
|
os.Args[1] == "version" ||
|
||||||
|
os.Args[1] == "env" {
|
||||||
|
err := lynx.PledgePromises("stdio")
|
||||||
|
panicOnErr(err)
|
||||||
|
} else {
|
||||||
|
err := lynx.PledgePromises("unveil stdio rpath")
|
||||||
|
panicOnErr(err)
|
||||||
|
|
||||||
|
unveil()
|
||||||
|
|
||||||
|
// Drop unveil from promises.
|
||||||
|
err = lynx.PledgePromises("stdio rpath")
|
||||||
|
panicOnErr(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func unveil() {
|
||||||
|
paths := make(map[string]string)
|
||||||
|
|
||||||
|
paths["/usr/share/dict"] = "r"
|
||||||
|
paths["/usr/local/share/dict"] = "r"
|
||||||
|
|
||||||
|
// Unveil user defined dictionaries.
|
||||||
|
if len(os.Args) >= 3 {
|
||||||
|
for _, dict := range os.Args[2:] {
|
||||||
|
paths[dict] = "r"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// This will not return error if the file doesn't exist.
|
||||||
|
err := lynx.UnveilPaths(paths)
|
||||||
|
panicOnErr(err)
|
||||||
|
|
||||||
|
// Block further unveil calls.
|
||||||
|
err = lynx.UnveilBlock()
|
||||||
|
panicOnErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
func panicOnErr(err error) {
|
func panicOnErr(err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
|
@ -1,51 +0,0 @@
|
||||||
// +build openbsd
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
"tildegit.org/andinus/lynx"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// We need less permissions on these conditions.
|
|
||||||
if len(os.Args) == 1 ||
|
|
||||||
os.Args[1] == "version" ||
|
|
||||||
os.Args[1] == "env" {
|
|
||||||
err := unix.PledgePromises("stdio")
|
|
||||||
panicOnErr(err)
|
|
||||||
} else {
|
|
||||||
err := unix.PledgePromises("unveil stdio rpath")
|
|
||||||
panicOnErr(err)
|
|
||||||
|
|
||||||
unveil()
|
|
||||||
|
|
||||||
// Drop unveil from promises.
|
|
||||||
err = unix.PledgePromises("stdio rpath")
|
|
||||||
panicOnErr(err)
|
|
||||||
}
|
|
||||||
grus()
|
|
||||||
}
|
|
||||||
|
|
||||||
func unveil() {
|
|
||||||
paths := make(map[string]string)
|
|
||||||
|
|
||||||
paths["/usr/share/dict"] = "r"
|
|
||||||
paths["/usr/local/share/dict"] = "r"
|
|
||||||
|
|
||||||
// Unveil user defined dictionaries.
|
|
||||||
if len(os.Args) >= 3 {
|
|
||||||
for _, dict := range os.Args[2:] {
|
|
||||||
paths[dict] = "r"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// This will not return error if the file doesn't exist.
|
|
||||||
err := lynx.UnveilPaths(paths)
|
|
||||||
panicOnErr(err)
|
|
||||||
|
|
||||||
// Block further unveil calls.
|
|
||||||
err = lynx.UnveilBlock()
|
|
||||||
panicOnErr(err)
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
// +build !openbsd
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
grus()
|
|
||||||
}
|
|
Loading…
Reference in New Issue