tangled
alpha
login
or
join now
anirudh.fi
/
legit
7
fork
atom
web frontend for git (tangled's grandpa)
7
fork
atom
overview
issues
pulls
pipelines
unveil: initial commit
authored by
zak
and committed by
anirudh.fi
3 years ago
4aa8cbff
d0f5d874
+36
-22
4 changed files
expand all
collapse all
unified
split
go.mod
main.go
unveil.go
unveil_stub.go
+1
-1
go.mod
···
8
8
github.com/dustin/go-humanize v1.0.0
9
9
github.com/go-git/go-git/v5 v5.5.1
10
10
github.com/sosedoff/gitkit v0.3.0
11
11
+
golang.org/x/sys v0.3.0
11
12
gopkg.in/yaml.v3 v3.0.0
12
13
)
13
14
···
30
31
golang.org/x/crypto v0.4.0 // indirect
31
32
golang.org/x/mod v0.7.0 // indirect
32
33
golang.org/x/net v0.4.0 // indirect
33
33
-
golang.org/x/sys v0.3.0 // indirect
34
34
golang.org/x/tools v0.4.0 // indirect
35
35
gopkg.in/warnings.v0 v0.1.2 // indirect
36
36
)
+3
-3
main.go
···
20
20
log.Fatal(err)
21
21
}
22
22
23
23
-
// for path := range []string{c.Dirs.Static, c.Repo.ScanPath, c.Dirs.Templates} {
24
24
-
// Unveil(path, "r")
25
25
-
// }
23
23
+
if err = UnveilPaths([]string{c.Dirs.Static, c.Repo.ScanPath, c.Dirs.Templates}, "r"); err != nil {
24
24
+
log.Fatal(err)
25
25
+
}
26
26
27
27
mux := routes.Handlers(c)
28
28
addr := fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port)
+14
-18
unveil.go
···
1
1
//go:build openbsd
2
2
// +build openbsd
3
3
4
4
-
// Doesn't do anything yet.
5
5
-
6
4
package main
7
7
-
8
8
-
/*
9
9
-
#include <stdlib.h>
10
10
-
#include <unistd.h>
11
11
-
*/
12
12
-
import "C"
13
5
14
6
import (
15
15
-
"fmt"
16
16
-
"unsafe"
7
7
+
"golang.org/x/sys/unix"
17
8
)
18
9
19
10
func Unveil(path string, perms string) error {
20
20
-
cpath := C.CString(path)
21
21
-
defer C.free(unsafe.Pointer(cpath))
22
22
-
cperms := C.CString(perms)
23
23
-
defer C.free(unsafe.Pointer(cperms))
11
11
+
return unix.Unveil(path, perms)
12
12
+
}
24
13
25
25
-
rv, err := C.unveil(cpath, cperms)
26
26
-
if rv != 0 {
27
27
-
return fmt.Errorf("unveil(%s, %s) failure (%d)", path, perms, err)
14
14
+
func UnveilBlock() error {
15
15
+
return unix.UnveilBlock()
16
16
+
}
17
17
+
18
18
+
func UnveilPaths(paths []string, perms string) error {
19
19
+
for _, path := range paths {
20
20
+
err := Unveil(path, perms)
21
21
+
if err != nil {
22
22
+
return err
23
23
+
}
28
24
}
29
29
-
return nil
25
25
+
return UnveilBlock()
30
26
}
+18
unveil_stub.go
···
1
1
+
//go:build !openbsd
2
2
+
// +build !openbsd
3
3
+
4
4
+
// Stub functions for GOOS that don't support unix.Unveil()
5
5
+
6
6
+
package main
7
7
+
8
8
+
func Unveil(path string, perms string) error {
9
9
+
return nil
10
10
+
}
11
11
+
12
12
+
func UnveilBlock() error {
13
13
+
return nil
14
14
+
}
15
15
+
16
16
+
func UnveilPaths(paths []string, perms string) error {
17
17
+
return nil
18
18
+
}