fix(scanner): Enable usbboot on Linux if run as root

This re-enables the usbboot scanner dynamically if Etcher
is run as root on Linux.

Change-Type: patch
This commit is contained in:
Jonas Hermsmeier 2018-03-13 15:08:40 +01:00
parent 835f2cf769
commit 9b42960b2f
No known key found for this signature in database
GPG Key ID: 1B870F801A0CEE9F

View File

@ -22,6 +22,7 @@ const fs = Bluebird.promisifyAll(require('fs'))
const path = require('path')
const settings = require('../models/settings')
const SDK = require('../../../sdk')
const permissions = require('../../../shared/permissions')
/**
* @summary The Etcher "blobs" directory path
@ -51,4 +52,15 @@ const scanner = SDK.createScanner({
}
})
// NOTE: Enable USBBoot on Linux if run as root
permissions.isElevated().then((elevated) => {
if (elevated && process.platform === 'linux') {
const UsbbootAdapter = require('../../../sdk/adapters/usbboot')
const adapter = new UsbbootAdapter()
scanner.stop()
scanner.subscribe(adapter)
scanner.start()
}
}).catch(_.noop)
module.exports = scanner