Use custom XDG runtime dirs for better isolation.

develop
Icedream 2015-11-02 12:45:27 +01:00
parent ee9bd9c0fc
commit ce801fecbb
3 changed files with 9 additions and 0 deletions

View File

@ -8,6 +8,7 @@ request = require "request"
fs = require("fs") fs = require("fs")
path = require("path") path = require("path")
qs = require "querystring" qs = require "querystring"
temp = require("temp").track()
youtubedl = require "youtube-dl" youtubedl = require "youtube-dl"
isValidUrl = (require "valid-url").isWebUri isValidUrl = (require "valid-url").isWebUri
@ -34,6 +35,9 @@ module.exports =
cb?() cb?()
shutdownSync: => Sync @shutdown shutdownSync: => Sync @shutdown
# Separate our own PulseAudio from any system one by using our own custom XDG directories.
process.env.XDG_RUNTIME_DIR = temp.mkdirSync "ts3bot-xdg"
# PulseAudio daemon # PulseAudio daemon
await services.find("pulseaudio").start defer err await services.find("pulseaudio").start defer err
if err if err

View File

@ -38,6 +38,7 @@
"stream-splitter": "^0.3.2", "stream-splitter": "^0.3.2",
"string.prototype.startswith": "^0.2.0", "string.prototype.startswith": "^0.2.0",
"sync": "^0.2.5", "sync": "^0.2.5",
"temp": "^0.8.3",
"valid-url": "^1.0.9", "valid-url": "^1.0.9",
"webchimera.js": "^0.1.38", "webchimera.js": "^0.1.38",
"which": "^1.1.2", "which": "^1.1.2",

View File

@ -22,6 +22,10 @@ module.exports = class TS3ClientService extends services.Service
] ]
constructor: -> super "TS3Client", constructor: -> super "TS3Client",
start: (args, cb) => start: (args, cb) =>
if not process.env.XDG_RUNTIME_DIR? or process.env.XDG_RUNTIME_DIR.trim() == ""
cb? new Error "XDG runtime directory needs to be set."
return
if typeof args == "function" if typeof args == "function"
cb = args cb = args
args = null args = null