From 5eaf79596fd4538b35d4bea1ee9d2faffa2b5178 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 22 Aug 2017 10:40:16 -0400 Subject: [PATCH] fix(linux): use $XDG_RUNTIME_DIR on GNU/Linux Some systems mount `/tmp` with `noexec`, causing `spawn EACCES` errors. See: https://github.com/resin-io/etcher/issues/1699 See: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html Change-Type: patch Changelog-Entry: Store GNU/Linux temporary scripts in `$XDG_RUNTIME_DIR`. Signed-off-by: Juan Cruz Viotti --- lib/execute.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/execute.js b/lib/execute.js index 9fd78107..8f58d615 100644 --- a/lib/execute.js +++ b/lib/execute.js @@ -24,6 +24,13 @@ const path = require('path'); const os = require('os'); const crypto = require('crypto'); +/** + * @summary A temporary directory to store scripts + * @type {String} + * @constant + */ +const TMP_DIRECTORY = process.env.XDG_RUNTIME_DIR || os.tmpdir(); + /** * @summary Generate a tmp filename with full path of OS' tmp dir * @function @@ -38,7 +45,7 @@ const crypto = require('crypto'); const tmpFilename = (extension) => { const random = crypto.randomBytes(6).toString('hex'); const filename = `${packageInfo.name}-${random}${extension}`; - return path.join(os.tmpdir(), filename); + return path.join(TMP_DIRECTORY, filename); }; /**