cmd/fshim: switch to generic setup func
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
parent
7f29b37a32
commit
7be53a2438
@ -13,6 +13,7 @@ import (
|
|||||||
"git.ophivana.moe/security/fortify/helper"
|
"git.ophivana.moe/security/fortify/helper"
|
||||||
"git.ophivana.moe/security/fortify/internal"
|
"git.ophivana.moe/security/fortify/internal"
|
||||||
"git.ophivana.moe/security/fortify/internal/fmsg"
|
"git.ophivana.moe/security/fortify/internal/fmsg"
|
||||||
|
"git.ophivana.moe/security/fortify/internal/proc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// everything beyond this point runs as unconstrained target user
|
// everything beyond this point runs as unconstrained target user
|
||||||
@ -110,17 +111,14 @@ func main() {
|
|||||||
|
|
||||||
var extraFiles []*os.File
|
var extraFiles []*os.File
|
||||||
|
|
||||||
// share config pipe
|
// serve setup payload
|
||||||
if r, w, err := os.Pipe(); err != nil {
|
if fd, encoder, err := proc.Setup(&extraFiles); err != nil {
|
||||||
fmsg.Fatalf("cannot pipe: %v", err)
|
fmsg.Fatalf("cannot pipe: %v", err)
|
||||||
} else {
|
} else {
|
||||||
conf.SetEnv[init0.Env] = strconv.Itoa(3 + len(extraFiles))
|
conf.SetEnv[init0.Env] = strconv.Itoa(fd)
|
||||||
extraFiles = append(extraFiles, r)
|
|
||||||
|
|
||||||
fmsg.VPrintln("transmitting config to init")
|
|
||||||
go func() {
|
go func() {
|
||||||
// stream config to pipe
|
fmsg.VPrintln("transmitting config to init")
|
||||||
if err = gob.NewEncoder(w).Encode(&ic); err != nil {
|
if err = encoder.Encode(&ic); err != nil {
|
||||||
fmsg.Fatalf("cannot transmit init config: %v", err)
|
fmsg.Fatalf("cannot transmit init config: %v", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user