From feb35544c8b06391f9b0b2d7f844060897817c66 Mon Sep 17 00:00:00 2001 From: xSmurf Date: Sat, 18 Jul 2015 00:11:08 +0000 Subject: [PATCH] Added permission checking of profiles, added border option for xpra, pulseaudio option removed (automatically detected from audio mode) --- profile.go | 8 ++++++-- xpra/client.go | 21 ++++++++++++++++----- xpra/server.go | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/profile.go b/profile.go index 9fd3bc5..982fba2 100644 --- a/profile.go +++ b/profile.go @@ -62,9 +62,9 @@ type XServerConf struct { WindowIcon string `json:"window_icon"` EnableTray bool `json:"enable_tray"` EnableNotifications bool `json:"enable_notifications"` - UsePulseaudio bool `json:"use_pulseaudio"` DisableClipboard bool `json:"disable_clipboard"` AudioMode AudioMode `json:"audio_mode"` + Border bool `json:"border"` } type SeccompMode string @@ -124,8 +124,8 @@ func NewDefaultProfile() *Profile { Enabled: true, EnableTray: false, EnableNotifications: false, - UsePulseaudio: false, AudioMode: PROFILE_AUDIO_NONE, + Border: false, }, } } @@ -193,6 +193,10 @@ func LoadProfiles(dir string) (Profiles, error) { } func loadProfileFile(file string) (*Profile, error) { + if err := checkConfigPermissions(file); err != nil { + return nil, err + } + bs, err := ioutil.ReadFile(file) if err != nil { return nil, err diff --git a/xpra/client.go b/xpra/client.go index 1a20156..b57e653 100644 --- a/xpra/client.go +++ b/xpra/client.go @@ -1,12 +1,16 @@ package xpra import ( + "crypto/md5" "fmt" - "github.com/op/go-logging" - "github.com/subgraph/oz" + "io" "os" "os/exec" "syscall" + + "github.com/subgraph/oz" + + "github.com/op/go-logging" ) var xpraClientDefaultArgs = []string{ @@ -40,13 +44,20 @@ func prepareClientArgs(config *oz.XServerConf, display uint64, workdir string, l args = append(args, xpraClientDefaultArgs...) if !config.EnableTray { args = append(args, "--no-tray") - } - if exists(config.TrayIcon, "Tray icon", log) { - args = append(args, fmt.Sprintf("--tray-icon=%s", config.TrayIcon)) + } else { + args = append(args, "--tray") + if exists(config.TrayIcon, "Tray icon", log) { + args = append(args, fmt.Sprintf("--tray-icon=%s", config.TrayIcon)) + } } if exists(config.WindowIcon, "Window icon", log) { args = append(args, fmt.Sprintf("--window-icon=%s", config.WindowIcon)) } + if config.Border { + h := md5.New() + io.WriteString(h, workdir) + args = append(args, "--border=#" + fmt.Sprintf("%x", h.Sum(nil)[0:3])) + } args = append(args, fmt.Sprintf("--socket-dir=%s", workdir), "attach", diff --git a/xpra/server.go b/xpra/server.go index 2e79408..26c4b9d 100644 --- a/xpra/server.go +++ b/xpra/server.go @@ -35,7 +35,7 @@ func prepareServerArgs(config *oz.XServerConf, display uint64, workdir string) [ "start", fmt.Sprintf(":%d", display), ) - if config.UsePulseaudio { + if config.AudioMode == oz.PROFILE_AUDIO_FULL || config.AudioMode == oz.PROFILE_AUDIO_SPEAKER { args = append(args, "--pulseaudio") } else { args = append(args, "--no-pulseaudio")