eventlog: support ticket and ssh

This commit is contained in:
Girish Ramakrishnan
2019-12-16 14:06:55 -08:00
parent 4c6566f42f
commit 93199c7f5b
5 changed files with 19 additions and 6 deletions

View File

@@ -8,11 +8,12 @@ exports = module.exports = {
let assert = require('assert'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
shell = require('./shell.js'),
eventlog = require('./eventlog.js'),
once = require('once'),
path = require('path'),
paths = require('./paths.js'),
settings = require('./settings.js');
settings = require('./settings.js'),
shell = require('./shell.js');
// the logic here is also used in the cloudron-support tool
const AUTHORIZED_KEYS_CMD = path.join(__dirname, 'scripts/remotesupport.sh');
@@ -48,13 +49,17 @@ function getRemoteSupport(callback) {
cp.stdout.on('data', (data) => result = result + data.toString('utf8'));
}
function enableRemoteSupport(enable, callback) {
function enableRemoteSupport(enable, auditSource, callback) {
assert.strictEqual(typeof enable, 'boolean');
assert.strictEqual(typeof auditSource, 'object');
assert.strictEqual(typeof callback, 'function');
let si = sshInfo();
shell.sudo('support', [ AUTHORIZED_KEYS_CMD, enable ? 'enable' : 'disable', si.filePath, si.user ], {}, function (error) {
if (error) callback(new BoxError(BoxError.FS_ERROR, error));
eventlog.add(eventlog.ACTION_SUPPORT_SSH, auditSource, { enable });
callback();
});
}