From f0fa37739591be8acacf5c9b1a1ce456999f6fbe Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Mon, 3 Aug 2020 11:06:45 -0700 Subject: [PATCH] Added root check for service install/uninstall --- modules/interactive.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/interactive.js b/modules/interactive.js index 78f6799..6dc0355 100644 --- a/modules/interactive.js +++ b/modules/interactive.js @@ -108,11 +108,17 @@ limitations under the License. if ((msh.InstallFlags & 1) == 1) { buttons.unshift('Connect'); } if ((msh.InstallFlags & 2) == 2) { + if (!require('user-sessions').isRoot()) + { + console.log('\n' + "Elevated permissions is required to install/uninstall the agent."); + console.log("Please try again with sudo."); + process.exit(); + } if (s) { if (process.platform == 'darwin' || require('message-box').kdialog) { - buttons.unshift('Setup'); + buttons.unshift("Setup"); } else { @@ -135,6 +141,11 @@ limitations under the License. process.exit(); } } + else + { + if (!require('user-sessions').isRoot()) { console.log('\n' + "This utility requires elevated permissions. Please try again with sudo."); process.exit(); } + } + if (!s) {