use separate backend hooks with tighter pledge

This commit is contained in:
Ted Unangst 2019-11-27 15:58:41 -05:00
parent c77ef4636c
commit 5435dd1b3f
2 changed files with 6 additions and 1 deletions

View File

@ -73,6 +73,8 @@ func shrinkit(data []byte) (*image.Image, error) {
return res.Image, nil return res.Image, nil
} }
var backendhooks []func()
func backendServer() { func backendServer() {
log.Printf("backend server running") log.Printf("backend server running")
shrinker := new(Shrinker) shrinker := new(Shrinker)
@ -92,7 +94,7 @@ func backendServer() {
if err != nil { if err != nil {
log.Panicf("unable to register shrinker: %s", err) log.Panicf("unable to register shrinker: %s", err)
} }
for _, h := range preservehooks { for _, h := range backendhooks {
h() h()
} }
srv.Accept(lis) srv.Accept(lis)

View File

@ -62,4 +62,7 @@ func init() {
C.unveil(nil, nil) C.unveil(nil, nil)
Pledge("stdio rpath wpath cpath flock dns inet unix") Pledge("stdio rpath wpath cpath flock dns inet unix")
}) })
backendhooks = append(backendhooks, func() {
Pledge("stdio unix")
})
} }