Skip to content

Commit

Permalink
chore: abort if root
Browse files Browse the repository at this point in the history
Add an uid check to identify if is running with root privileges.
  • Loading branch information
pedrobmarin committed Sep 1, 2021
1 parent a53b0dc commit 15b5756
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ const locales = require('./locales');

const { api, bot, url, misc } = conf.config;

const root = () => {
if (typeof process.getuid === 'function') {
const uid = process.getuid();

if (uid === 0) {
logger.error(`BigBlueBot cannot be runned as root`);

return true;
}
} else {
logger.warn(`Could not get process' uid`);
}

return false;
};

const dependencies = (options) => {
if (!url.host && !options.host) {
logger.error(`BigBlueButton's host is not defined`);
Expand All @@ -26,6 +42,9 @@ const dependencies = (options) => {
};

const run = async (actions, options = {}) => {
// Check for user's permissions
if (root()) return null;

// Check for dependencies
if (!dependencies(options)) return null;

Expand Down

0 comments on commit 15b5756

Please sign in to comment.