|
|
@ -13,7 +13,9 @@ import (
|
|
|
|
"github.com/subgraph/oz/xpra"
|
|
|
|
"github.com/subgraph/oz/xpra"
|
|
|
|
"os/user"
|
|
|
|
"os/user"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"path"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"bufio"
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const profileDirectory = "/var/lib/oz/cells.d"
|
|
|
|
const profileDirectory = "/var/lib/oz/cells.d"
|
|
|
@ -42,6 +44,7 @@ func createLogger() *logging.Logger {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var allowRootShell = false
|
|
|
|
var allowRootShell = false
|
|
|
|
|
|
|
|
var logXpra = true
|
|
|
|
|
|
|
|
|
|
|
|
func Main() {
|
|
|
|
func Main() {
|
|
|
|
st := parseArgs()
|
|
|
|
st := parseArgs()
|
|
|
@ -138,16 +141,13 @@ func (st *initState) startXpraServer() {
|
|
|
|
st.log.Warning("Xpra work directory not set")
|
|
|
|
st.log.Warning("Xpra work directory not set")
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
logpath := path.Join(workdir, "xpra-server.out")
|
|
|
|
xpra := xpra.NewServer(&st.profile.XServer, uint64(st.display), workdir)
|
|
|
|
f,err := os.Create(logpath)
|
|
|
|
p,err := xpra.Process.StderrPipe()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
st.log.Warning("Failed to open xpra logfile (%s): %v", logpath, err)
|
|
|
|
st.log.Warning("Error creating stderr pipe for xpra output: %v", err)
|
|
|
|
return
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
go st.readXpraOutput(p)
|
|
|
|
xpra := xpra.NewServer(&st.profile.XServer, uint64(st.display), workdir)
|
|
|
|
|
|
|
|
xpra.Process.Stdout = f
|
|
|
|
|
|
|
|
xpra.Process.Stderr = f
|
|
|
|
|
|
|
|
xpra.Process.Env = []string{
|
|
|
|
xpra.Process.Env = []string{
|
|
|
|
"HOME="+ st.user.HomeDir,
|
|
|
|
"HOME="+ st.user.HomeDir,
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -162,6 +162,25 @@ func (st *initState) startXpraServer() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (st *initState) readXpraOutput(r io.ReadCloser) {
|
|
|
|
|
|
|
|
sc := bufio.NewScanner(r)
|
|
|
|
|
|
|
|
for sc.Scan() {
|
|
|
|
|
|
|
|
line := sc.Text()
|
|
|
|
|
|
|
|
if len(line) > 0 {
|
|
|
|
|
|
|
|
if strings.Contains(line, "xpra is ready.") {
|
|
|
|
|
|
|
|
os.Stderr.WriteString("XPRA READY\n")
|
|
|
|
|
|
|
|
if !logXpra {
|
|
|
|
|
|
|
|
r.Close()
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if logXpra {
|
|
|
|
|
|
|
|
st.log.Debug("(xpra) %s", line)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func loadProfile(name string) (*oz.Profile, error) {
|
|
|
|
func loadProfile(name string) (*oz.Profile, error) {
|
|
|
|
ps,err := oz.LoadProfiles(profileDirectory)
|
|
|
|
ps,err := oz.LoadProfiles(profileDirectory)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|