I need to write to /dev/sdx which is why I put the removable-media plug in my snapcraft.yaml file.
Yet when I try to open /dev/sdb my app crashes:
thread ‘main’ panicked at ‘Could not open output file.: Os { code: 13, kind: PermissionDenied, message: “Permission denied” }’, src/frontend/mod.rs:206:30
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
removable-media allows acces to the typical mount points where removable devices get mounted (/media, /mnt), not to the hardware devices themselves …
to access a raw disk device you would need to use the (highly privileged) block-devices interface …
$ snap interface block-devices
name: block-devices
summary: allows access to disk block devices
slots:
- core
$
being highly privileged, note that you will need to ask for permission for this interface if you want to upload a snap using it into the global store (the snap will be held during upload and you will have to open a forum topic with a store-request to get permission granted) …
In such a case, I need to always launch the app with root privileges. I tried specifying Exec = pkexec nixwriter in the .desktop file but it fails. How does one launch a non-terminal snap app with root privilages?
I think this is a bug. For the .desktop file under my gui folder below:
[Desktop Entry]
Type=Application
Name=Nixwriter (Snap)
Comment=Create bootable Linux images with dd and from a GTK user interface
Terminal=false
Icon=${SNAP}/meta/gui/nixwriter.png
Exec=pkexec nixwriter
Category=Utility;
The generated desktop file is:
[Desktop Entry]
X-SnapInstanceName=nixwriter
Type=Application
Name=Nixwriter (Snap)
Comment=Create bootable Linux images with dd and from a GTK user interface
Terminal=false
Icon=/var/lib/snapd/snap/nixwriter/x5/meta/gui/nixwriter.png
I don’t think it has anything to do with Snapcraft: this looks like snapd ignoring the Exec line because “pkexec” is not a command provided by the snap.