launch xpra client

networking
brl 10 years ago
parent 409bdb568a
commit deb2751d85

@ -98,7 +98,7 @@ func (d *daemonState) handleLaunch(msg *LaunchMsg, m *ipc.Message) error {
return m.Respond(&ErrorMsg{err.Error()})
}
d.Debug("Would launch %s", p.Name)
_,err = d.launch(p, m.Ucred.Uid)
_,err = d.launch(p, m.Ucred.Uid, m.Ucred.Gid)
if err != nil {
d.Warning("launch of %s failed: %v", p.Name, err)
return m.Respond(&ErrorMsg{err.Error()})

@ -9,6 +9,8 @@ import (
"io"
"bufio"
"os/user"
"github.com/subgraph/oz/xpra"
"os"
)
const initPath = "/usr/local/bin/oz-init"
@ -20,9 +22,11 @@ type Sandbox struct {
display int
profile *oz.Profile
init *exec.Cmd
cred *syscall.Credential
fs *fs.Filesystem
stderr io.ReadCloser
addr string
xpra *xpra.Xpra
}
/*
@ -55,7 +59,7 @@ func createInitCommand(addr, name, chroot string, uid uint32, display int) *exec
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))
if err != nil {
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,
profile: p,
init: cmd,
cred: &syscall.Credential{Uid: uid, Gid: gid},
fs: fs,
addr: addr,
stderr: pp,
@ -119,6 +124,7 @@ func (sbox *Sandbox) logMessages() {
line := scanner.Text()
if line == "XPRA READY" {
sbox.daemon.log.Info("Xpra server is ready for connection")
go sbox.startXpraClient()
} else if len(line) > 1 {
sbox.logLine(line)
}
@ -157,3 +163,18 @@ func (sbox *Sandbox) getLogFunc(c byte) func(string, ...interface{}) {
}
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)
}
}

Loading…
Cancel
Save