|
|
@ -9,6 +9,8 @@ import (
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"bufio"
|
|
|
|
"bufio"
|
|
|
|
"os/user"
|
|
|
|
"os/user"
|
|
|
|
|
|
|
|
"github.com/subgraph/oz/xpra"
|
|
|
|
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const initPath = "/usr/local/bin/oz-init"
|
|
|
|
const initPath = "/usr/local/bin/oz-init"
|
|
|
@ -20,9 +22,11 @@ type Sandbox struct {
|
|
|
|
display int
|
|
|
|
display int
|
|
|
|
profile *oz.Profile
|
|
|
|
profile *oz.Profile
|
|
|
|
init *exec.Cmd
|
|
|
|
init *exec.Cmd
|
|
|
|
|
|
|
|
cred *syscall.Credential
|
|
|
|
fs *fs.Filesystem
|
|
|
|
fs *fs.Filesystem
|
|
|
|
stderr io.ReadCloser
|
|
|
|
stderr io.ReadCloser
|
|
|
|
addr string
|
|
|
|
addr string
|
|
|
|
|
|
|
|
xpra *xpra.Xpra
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -55,7 +59,7 @@ func createInitCommand(addr, name, chroot string, uid uint32, display int) *exec
|
|
|
|
return cmd
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *daemonState) launch(p *oz.Profile, uid uint32) (*Sandbox, error) {
|
|
|
|
func (d *daemonState) launch(p *oz.Profile, uid,gid uint32) (*Sandbox, error) {
|
|
|
|
u,err := user.LookupId(fmt.Sprintf("%d", uid))
|
|
|
|
u,err := user.LookupId(fmt.Sprintf("%d", uid))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to lookup user for uid=%d: %v", uid, err)
|
|
|
|
return nil, fmt.Errorf("failed to lookup user for uid=%d: %v", uid, err)
|
|
|
@ -91,6 +95,7 @@ func (d *daemonState) launch(p *oz.Profile, uid uint32) (*Sandbox, error) {
|
|
|
|
display: display,
|
|
|
|
display: display,
|
|
|
|
profile: p,
|
|
|
|
profile: p,
|
|
|
|
init: cmd,
|
|
|
|
init: cmd,
|
|
|
|
|
|
|
|
cred: &syscall.Credential{Uid: uid, Gid: gid},
|
|
|
|
fs: fs,
|
|
|
|
fs: fs,
|
|
|
|
addr: addr,
|
|
|
|
addr: addr,
|
|
|
|
stderr: pp,
|
|
|
|
stderr: pp,
|
|
|
@ -119,6 +124,7 @@ func (sbox *Sandbox) logMessages() {
|
|
|
|
line := scanner.Text()
|
|
|
|
line := scanner.Text()
|
|
|
|
if line == "XPRA READY" {
|
|
|
|
if line == "XPRA READY" {
|
|
|
|
sbox.daemon.log.Info("Xpra server is ready for connection")
|
|
|
|
sbox.daemon.log.Info("Xpra server is ready for connection")
|
|
|
|
|
|
|
|
go sbox.startXpraClient()
|
|
|
|
} else if len(line) > 1 {
|
|
|
|
} else if len(line) > 1 {
|
|
|
|
sbox.logLine(line)
|
|
|
|
sbox.logLine(line)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -157,3 +163,18 @@ func (sbox *Sandbox) getLogFunc(c byte) func(string, ...interface{}) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (sbox *Sandbox) startXpraClient() {
|
|
|
|
|
|
|
|
sbox.xpra = xpra.NewClient(
|
|
|
|
|
|
|
|
&sbox.profile.XServer,
|
|
|
|
|
|
|
|
uint64(sbox.display),
|
|
|
|
|
|
|
|
sbox.cred,
|
|
|
|
|
|
|
|
sbox.fs.Xpra(),
|
|
|
|
|
|
|
|
sbox.profile.Name,
|
|
|
|
|
|
|
|
sbox.daemon.log)
|
|
|
|
|
|
|
|
sbox.xpra.Process.Stdout = os.Stdout
|
|
|
|
|
|
|
|
sbox.xpra.Process.Stderr = os.Stdout
|
|
|
|
|
|
|
|
if err := sbox.xpra.Process.Start(); err != nil {
|
|
|
|
|
|
|
|
sbox.daemon.Warning("Failed to start xpra client: %v", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|