Spagett1 / pineflash

A tool to flash ironos to the pinecil soldering iron and possibly other pine64 devices in the future
Other
223 stars 12 forks source link

need root privileges for some installations #2

Closed An-GG closed 1 year ago

An-GG commented 1 year ago

So everything seems to work great on mac, but I couldn't get it to work on linux (ubuntu 20.04 amd64).

Did some debugging, I double checked I can use dfu-utils to update, and I noticed I can only do that as root. This is what I get without sudo:

Match vendor ID from file: 28e9
Match product ID from file: 0189
dfu-util: Cannot open DFU device 28e9:0189 found on devnum 55 (LIBUSB_ERROR_ACCESS)

Similar error shows up in pineflash gui logs

Versions successfully fetched.
Download Complete.
File extracted successfully
dfu-util 0.11-dev

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Match vendor ID from file: 28e9
Match product ID from file: 0189
dfu-util: Cannot open DFU device 28e9:0189 found on devnum 95 (LIBUSB_ERROR_ACCESS)
dfu-util: No DFU capable USB device available

pineflash has errors when running as root, as soon as i click update

an@fast:~/External/PineFlash$ sudo target/release/pineflash 
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', src/main.rs:127:55
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'The Promise Sender was dropped', /home/an/.cargo/registry/src/github.com-1ecc6299db9ec823/poll-promise-0.1.0/src/promise.rs:290:25

Some QoL improvements would be appreciated:

Spagett1 commented 1 year ago

Hmm, thanks, Just to clarify dfu-util is required to have root to work on ubuntu but not macos? Yeah i plan on vendoring dfu-util soon, just gotta figure out a few things on how to do that, Thanks i didnt realise the window couldn't be moved, i use a window manager which overrides certain application settings, ill figure that out.

An-GG commented 1 year ago

Just to clarify dfu-util is required to have root to work on ubuntu but not macos?

Yep, this has also generally been my experience in the past. Linux usually just requires adding a dialout group to sudoers.

Spagett1 commented 1 year ago

Interesting, i think this can be solved with a udev rule which ill have to ship with the flasher (may need to make debs, rpms, etc)

so i can write the udev rules could you run udevadm monitor then plug in the pinecil in dfu mode you should see a file path appear, then in a seperate command could you run udevadm info -ap <file path from udevadm monitor> and send me the pinecils ATTRS{idProduct} and ATTRS{idVendor} (they should appear near the top of the output). Thanks

An-GG commented 1 year ago

ATTRS{idVendor}=="28e9" and ATTRS{idProduct}=="0189"

fyi pretty sure these params are already included in the .dfu file though, unlikely but i guess in theory these could change. maybe have some way to run dfu-util as root as a fallback case. wouldn't adding the udev rule require install script to run as root anyway?

Spagett1 commented 1 year ago

cheers, Yeah a root mode is probably a good idea, ill have to figure out how to do that. If i package it up as a .deb .rpm, PKGBUILD or anything like that i can include the rule though, speaking of that i should probably also make a .desktop file so it appears in app launchers, thanks again for the help.

Spagett1 commented 1 year ago

Hey, i think ive fixed it by making some options in a .desktop file. would you mind git cloneing the repo and then running the generic_linux_install.sh script (it will also build the project so you'll need rust installed, if you dont let me know and i can make a release) and launching it from your app launcher? Thanks for the help in figuring out this bug.

hierog commented 1 year ago

i have an odd debian testing(bookworm) without much of the graphical/system tools... so i followed the errors and installed these...

apt install cmake apt install pkg-config apt install libglib2.0-dev apt install libgdk-pixbuf-2.0-dev apt install libcairo2-dev apt install libpango1.0-dev apt install libgtk-3-dev

i was then able to successfuly run...

cargo build --release su -c 'cp ./Pineflash.desktop /usr/share/applications/Pineflash.desktop' su -c 'cp ./assets/pine64logo.png /usr/share/pixmaps/pine64logo.png' su -c 'cp ./target/release/pineflash /usr/bin/pineflash'

i then realized i had no launcher... apt install lxpanel

of course i needed a graphical polkit... apt install policykit-1-gnome

and launch it... /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1

PineFlash shows up in 'System Tools' and launches successfuly.

Spagett1 commented 1 year ago

I reckon this is all solved now, thanks hierog for testing. Im going to close this now.