fix: rid linux startup elevation (#1831)

We remove the Linux elevation meant for usbboot device access.

Reverts: https://github.com/resin-io/etcher/pull/1708
See: https://github.com/resin-io/etcher/issues/1819
Change-Type: minor
Changelog-Entry: Remove Linux elevation meant for usbboot.
This commit is contained in:
Benedict Aas 2017-11-13 19:34:20 +00:00 committed by Juan Cruz Viotti
parent 8b13a23117
commit 5771c0f56e
6 changed files with 2 additions and 100 deletions

View File

@ -83,12 +83,10 @@ deb:
- libxss1
- libxtst6
- polkit-1-auth-agent | policykit-1-gnome | polkit-kde-1
- gksu | kdesudo
rpm:
icon: assets/icon.png
depends:
- lsb
- libXScrnSaver
- beesu
appImage:
icon: assets/icon.png

View File

@ -35,10 +35,6 @@ module.exports = {
flashComplete: _.template([
'<%= imageBasename %> was successfully written to',
'<%= drive.description %> (<%= drive.displayName %>)'
].join(' ')),
providePassword: _.template([
'<%= displayName %> needs special permissions to interact with raw devices. Please provide your password.'
].join(' '))
},

View File

@ -233,7 +233,7 @@ SDK.Scanner = class Scanner extends EventEmitter {
instance.removeListener('devices', this.onDevices)
instance.removeListener('error', this.onError)
this.adapters.delete(instance.name)
this.adapters.delete(instance.id)
this.emit('unsubscribe', adapter)
return this

View File

@ -29,91 +29,5 @@
if (process.env.ELECTRON_RUN_AS_NODE || process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE) {
require('./cli/etcher')
} else {
const electron = require('electron')
const os = require('os')
const _ = require('lodash')
const Bluebird = require('bluebird')
const commandExists = Bluebird.promisify(require('command-exists'))
const childProcess = require('child_process')
const permissions = require('./shared/permissions')
const errors = require('./shared/errors')
const EXIT_CODES = require('./shared/exit-codes')
const packageJSON = require('../package.json')
const messages = require('./shared/messages')
const MESSAGE = messages.info.providePassword({
displayName: packageJSON.displayName
})
const ELEVATOR_COMMANDS = [
{
name: 'gksudo',
options: [ '--preserve-env', '--message', MESSAGE ]
},
{
name: 'kdesudo',
options: [ '--comment', MESSAGE, '--' ]
},
{
name: 'beesu',
options: [ '--preserve-environment' ]
}
]
if (_.includes([ 'win32', 'darwin' ], os.platform())) {
require('./gui/etcher')
} else {
permissions.isElevated().then((isElevated) => {
if (isElevated) {
require('./gui/etcher')
return Bluebird.resolve()
}
return Bluebird.any(_.map(ELEVATOR_COMMANDS, (command) => {
return commandExists(command.name).then((exists) => {
if (!exists) {
throw new Error(`Command does not exist: ${command.name}`)
}
return command
})
})).then((command) => {
return new Bluebird((resolve, reject) => {
const argv = process.env.APPIMAGE ? [ process.env.APPIMAGE ] : process.argv
const options = command.options.concat([ 'env', 'SKIP=1' ]).concat(argv)
console.log(`Running ${command.name}`)
const child = childProcess.spawn(command.name, options, {
detached: true,
env: process.env
})
child.stdout.on('data', (data) => {
console.log(data.toString())
})
child.stderr.on('data', (data) => {
console.error(data.toString())
})
child.on('exit', () => {
electron.app.quit()
})
child.on('error', reject)
})
}).catch(Bluebird.AggregateError, () => {
const commands = _.map(ELEVATOR_COMMANDS, 'name')
const formattedCommands = `${_.initial(commands).join(', ')}, or ${_.last(commands)}`
throw errors.createUserError({
title: 'Can\'t elevate the application',
description: `Please ensure you have either ${formattedCommands} available in your system`
})
})
}).catch((error) => {
electron.dialog.showErrorBox(errors.getTitle(error), errors.getDescription(error))
electron.app.exit(EXIT_CODES.GENERAL_ERROR)
})
}
require('./gui/etcher')
}

5
npm-shrinkwrap.json generated
View File

@ -855,11 +855,6 @@
"resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz",
"dev": true
},
"command-exists": {
"version": "1.2.2",
"from": "command-exists@latest",
"resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.2.tgz"
},
"command-join": {
"version": "2.0.0",
"from": "command-join@2.0.0",

View File

@ -50,7 +50,6 @@
"bluebird": "3.4.1",
"bootstrap-sass": "3.3.6",
"chalk": "1.1.3",
"command-exists": "1.2.2",
"command-join": "2.0.0",
"debug": "2.6.0",
"drivelist": "5.2.4",