glasgow icon indicating copy to clipboard operation
glasgow copied to clipboard

CLI handles USB device permission errors badly

Open emilazy opened this issue 5 years ago • 4 comments

If you run Glasgow as a user that can't access the USB device under Linux, you get a usb1.USBErrorAccess: LIBUSB_ERROR_ACCESS [-3] backtrace; it should print something more useful about running it with sudo or installing the udev rules. (Relatedly, Glasgow should probably drop permissions after opening the USB device when run as root.)

emilazy avatar Sep 28 '19 19:09 emilazy

Relatedly, Glasgow should probably drop permissions after opening the USB device when run as root.

I'm not sure if this works. Suppose you run it in a Docker container--you have to be root then, I think, or you can't write anywhere in it.

whitequark avatar Sep 28 '19 19:09 whitequark

Well, it should at least drop its privileges after opening everything it needs to. This is good practice even for daemons that need to have access to root-permissioned files. However, it's hard to implement, and given that the CLI just plain crashes and dies if you try to run it in anything that isn't a proper pty with width and height it can determine, I'm not sure glasgow.cli-in-Docker-with-pid-namespaces is the most convincing use-case.

emilazy avatar Sep 28 '19 19:09 emilazy

Well, it should at least drop its privileges after opening everything it needs to.

You can't do that. An applet can decide to write a file right before termination, and it might not even know the name of this file beforehand (e.g. you're reading a floppy into track-1.raw, track-2.raw etc).

whitequark avatar Sep 28 '19 19:09 whitequark

Also, it works just fine for me in Docker? I actually test the installation instructions that way.

whitequark avatar Sep 28 '19 19:09 whitequark

The error that you get now (since commit 26ba5e70d12b508ebf6f95d4e8544964d28a9d05) is this:

$ glasgow list
E: g.device.hardware: missing permissions to open device 001/113

The documentation includes instructions for installing the udev rules file that should work, as far as I know, for any remotely modern Linux distribution (including eudev-based ones), so I consider this finished.

whitequark avatar Oct 21 '23 11:10 whitequark