mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-24 07:17:18 +00:00
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:
parent
835f2cf769
commit
9b42960b2f
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user