Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No removable drive detected." when /tmp is mounted as noexec #1699

Closed
szotsaki opened this issue Aug 19, 2017 · 9 comments
Closed

"No removable drive detected." when /tmp is mounted as noexec #1699

szotsaki opened this issue Aug 19, 2017 · 9 comments

Comments

@szotsaki
Copy link

  • Etcher version: 1.1.2
  • Operating system and architecture: openSUSE Leap 42.3, x64

Mount /tmp as noexec (many people and some distros do that by default) and click on "Select drive" after you chose an image. It will show "No removable drive detected".

Console log:

Uncaught Error: spawn EACCES
    at exports._errnoException (util.js:1022:11)
    at ChildProcess.spawn (internal/child_process.js:313:11)
    at exports.spawn (child_process.js:399:9)
    at Object.exports.execFile (child_process.js:160:15)
    at Object.module.(anonymous function) [as execFile] (ELECTRON_ASAR.js:200:20)
    at executeScript (/tmp/.mount_npruyq/usr/bin/resources/app.asar/node_modules/drivelist/lib/execute.js:87:16)
    at createTemporaryScriptFile (/tmp/.mount_npruyq/usr/bin/resources/app.asar/node_modules/drivelist/lib/execute.js:153:5)
    at fs.writeFile (/tmp/.mount_npruyq/usr/bin/resources/app.asar/node_modules/drivelist/lib/execute.js:67:5)
    at FSReqWrap.oncomplete (fs.js:112:15)
@lurch
Copy link
Contributor

lurch commented Aug 19, 2017

Yeah, that'll be because we write the drivelist script to /tmp before executing it. See https://github.com/resin-io-modules/drivelist/blob/master/scripts/linux.sh

We've already moved the drivelist functionality into native code for Windows (because it solved a lot of spawning problems) but we've not yet done that for Linux or macOS.

@jviotti
Copy link
Contributor

jviotti commented Aug 21, 2017

@lurch What do you think about spawning the drives somewhere else in the mean-time, like $HOME/.etcher/tmp/ or something like that?

@lurch
Copy link
Contributor

lurch commented Aug 22, 2017

I dunno, that might work. What does @szotsaki think?

I did a bit of googling, and found a bunch of pages telling you how to enable a noexec /tmp directory, and also a bunch of pages telling you how to temporarily disable the noexec option ;-) https://debian-administration.org/article/57/Making_/tmp_non-executable

I did a little bit of digging, and drivelist uses https://nodejs.org/api/os.html#os_os_tmpdir to determine where to write its files, and it seems that function respects the TMPDIR variable:

$ node
> os.tmpdir()
'/tmp'
$ TMPDIR=/foo node
> os.tmpdir()
'/foo'
$ node
> os.tmpdir()
'/tmp'

So @szotsaki could you try running TMPDIR=some/executable/path etcher-electron (or maybe TMPDIR=some/executable/path etcher-1.1.2-linux-x86_64.AppImage) and let us know if that fixes your problem?

@szotsaki
Copy link
Author

Yes, I used the remount option to make /tmp executable but only root can do that, so I think it's not a good solution. Modifying it in a program and knowing that that program can accidentally crash leaving /tmp in exec state may have awful consequences.

Directory selection idea: I recommend to adhere to Freedesktop specification, specifically $XDG_RUNTIME_DIR or maybe $XDG_CACHE_HOME.

Running ethcher with TMPDIR=$XDG_RUNTIME_DIR ./etcher-1.1.2-x86_64.AppImage made it work with noexec, thank you for the tip.

@lurch
Copy link
Contributor

lurch commented Aug 22, 2017

Modifying it in a program

Sorry, that's not what I was suggesting. I was just illustrating that other programs can have problems with a non-executable /tmp directory too ;-)

Thanks for the info about $XDG_RUNTIME_DIR !

@jviotti
Copy link
Contributor

jviotti commented Aug 22, 2017

@szotsaki Thanks a lot for the XDG suggestions. I'll be sending a PR very soon :)

jviotti added a commit to balena-io-modules/drivelist that referenced this issue Aug 22, 2017
Some systems mount `/tmp` with `noexec`, causing `spawn EACCES` errors.

See: balena-io/etcher#1699
See: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti
Copy link
Contributor

jviotti commented Aug 22, 2017

jviotti added a commit to balena-io-modules/drivelist that referenced this issue Aug 22, 2017
Some systems mount `/tmp` with `noexec`, causing `spawn EACCES` errors.

See: balena-io/etcher#1699
See: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
Change-Type: patch
Changelog-Entry: Store GNU/Linux temporary scripts in `$XDG_RUNTIME_DIR`.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit to balena-io-modules/drivelist that referenced this issue Aug 28, 2017
Some systems mount `/tmp` with `noexec`, causing `spawn EACCES` errors.

See: balena-io/etcher#1699
See: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
Change-Type: patch
Changelog-Entry: Store GNU/Linux temporary scripts in `$XDG_RUNTIME_DIR`.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit to balena-io-modules/drivelist that referenced this issue Aug 28, 2017
Some systems mount `/tmp` with `noexec`, causing `spawn EACCES` errors.

See: balena-io/etcher#1699
See: https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html
Change-Type: patch
Changelog-Entry: Store GNU/Linux temporary scripts in `$XDG_RUNTIME_DIR`.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Aug 28, 2017
Fixes: #1699
Change-Type: patch
Changelog-Entry: Try to use `$XDG_RUNTIME_DIR` to extract temporary scripts on GNU/Linux.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
jviotti added a commit that referenced this issue Sep 4, 2017
Fixes: #1699
Change-Type: patch
Changelog-Entry: Try to use `$XDG_RUNTIME_DIR` to extract temporary scripts on GNU/Linux.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@lurch
Copy link
Contributor

lurch commented Oct 5, 2017

Re-opening this issue, as the proposed fix actually breaks things for other Linux distros, see balena-io-modules/drivelist#209 (comment)

(BTW it seems $XDG_CACHE_HOME isn't set on Ubuntu 14.04)

@lurch
Copy link
Contributor

lurch commented Oct 10, 2017

Closing, as drivelist in Etcher has been upgraded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants