From ce801fecbb3490ceafa9f833495fa8b8ddcafc05 Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Mon, 2 Nov 2015 12:45:27 +0100 Subject: [PATCH] Use custom XDG runtime dirs for better isolation. --- app.iced | 4 ++++ package.json | 1 + services/ts3client.iced | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/app.iced b/app.iced index d4e6c52..fc4fe4d 100644 --- a/app.iced +++ b/app.iced @@ -8,6 +8,7 @@ request = require "request" fs = require("fs") path = require("path") qs = require "querystring" +temp = require("temp").track() youtubedl = require "youtube-dl" isValidUrl = (require "valid-url").isWebUri @@ -34,6 +35,9 @@ module.exports = cb?() 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 await services.find("pulseaudio").start defer err if err diff --git a/package.json b/package.json index 78ac299..9f31387 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "stream-splitter": "^0.3.2", "string.prototype.startswith": "^0.2.0", "sync": "^0.2.5", + "temp": "^0.8.3", "valid-url": "^1.0.9", "webchimera.js": "^0.1.38", "which": "^1.1.2", diff --git a/services/ts3client.iced b/services/ts3client.iced index ca662c4..093ba57 100644 --- a/services/ts3client.iced +++ b/services/ts3client.iced @@ -22,6 +22,10 @@ module.exports = class TS3ClientService extends services.Service ] constructor: -> super "TS3Client", 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" cb = args args = null