blobsaver icon indicating copy to clipboard operation
blobsaver copied to clipboard

Using blobsaver with sudo on Linux hint in Wiki or Readme

Open Tuerpe opened this issue 3 years ago • 7 comments

Hey there, sorry, it might seem really dumb but i think it would be nice to have a hint in the Wiki under "blobsaver on Linux" or in the readme that its mandatory to use blobsaver on linux with su privilegs. If i had this Info (not your fault just my total braindeadness) it would have saved me a bad day yesterday because i got stuck in recovery mode. On Linux (Im using Fedora) blobsaver cant detect my Iphone (13 Pro Max) in recovery mode without su privilegs.

Thx for reading and greetings:)

Tuerpe avatar Jul 19 '22 16:07 Tuerpe

Alternatively, I think it would be best to just have the program call polkit or an equivalent tool to request privilege escalation when needed.

xerz-one avatar Jul 20 '22 11:07 xerz-one

Use this udev rule and you won't need su privileges

# Handle iOS devices in DFU and Recovery mode - for use with libirecovery

# Change group and permissions of iOS devices in DFU, legacy WTF, and Recovery mode
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="05ac", ATTR{idProduct}=="122[27]|128[0-3]", MODE="0666"

ACTION=="bind", SUBSYSTEM=="usb", ATTR{idVendor}=="05ac", ATTR{idProduct}=="122[27]|128[0-3]", MODE="0666"

superrnovae avatar Jul 22 '22 17:07 superrnovae

Thx for sharing this method. But i think it would be helpful for some users, if theres a hint in the readme or wiki for either using sudo or your solution. As mentioned, it gave me a very bad day :D and the solution was so obvious.

Tuerpe avatar Jul 23 '22 11:07 Tuerpe

That is because there is a udev rule that comes bundled with libirecovery. In addition to the rule above it sets the owner and group access on the device, but it wasn't working for me. Seems the same happened in your case. I tinkered a bit and made it work by only changing the mode and saving it as 39-libirecovery.rules to override the existing one.

superrnovae avatar Jul 23 '22 14:07 superrnovae

hm okay. I thought I was the problem. :D Maybe this "bug" happened to me too.

Tuerpe avatar Jul 24 '22 18:07 Tuerpe

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you would like this to remain open, please comment, otherwise this issue will be closed in 5 days.'

stale[bot] avatar Sep 09 '22 01:09 stale[bot]

I mean... yeah, this probably needs to be kept open imho. Like at the very least blobsaver should be able to figure out something is wrong and how to work around it.

xerz-one avatar Sep 10 '22 11:09 xerz-one

is this gonna become my job now

xerz-one avatar Oct 12 '22 10:10 xerz-one

I was not aware of this.

Is the udev rule not installed automatically when libirecovery is installed? @superrnovae

airsquared avatar Nov 07 '22 01:11 airsquared

That depends on your distro, and blobsaver shouldn't assume the Udev rules are available and grant access to the specific user running the program. Handling this best would be checking if it has permission, and if it doesn't, then call polkit through e.g. Dbus.

xerz-one avatar Nov 07 '22 11:11 xerz-one

I have no idea how polkit and udev works; but if someone could provide a more in depth explanation of what blobsaver should do (like what CLI programs or C functions to call) I could add a way for blobsaver to automatically detect it and try to fix it. Or if there's a way to elevate permissions while blobsaver is already running that would work too.

airsquared avatar Nov 07 '22 19:11 airsquared

What is the error message given when it fails due to incorrect/missing permissions? I can at least try to add a more detailed error message to explain possible solutions.

airsquared avatar Nov 07 '22 19:11 airsquared

On archlinux, I can't read apnonce normally without sudo.

What happens is:

This message stays for a while: image

Then after quite a while (longer than the time taken for irecovery -q without sudo to fail) I get this:

image

The terminal output is:

> ./gradlew run

> Configure project :
Project : => 'airsquared.blobsaver' Java module

> Task :run
airsquared.blobsaver.app.LibimobiledeviceUtil$LibimobiledeviceException: irecovery error: code=-3

If your device is still in recovery mode, use the "Exit Recovery Mode" option from the help menu.
        at [email protected]/airsquared.blobsaver.app.LibimobiledeviceUtil.throwIfNeeded(LibimobiledeviceUtil.java:344)
        at [email protected]/airsquared.blobsaver.app.LibimobiledeviceUtil.waitForRecovery(LibimobiledeviceUtil.java:210)
        at [email protected]/airsquared.blobsaver.app.LibimobiledeviceUtil$GetApnonceTask.call(LibimobiledeviceUtil.java:100)
        at [email protected]/airsquared.blobsaver.app.LibimobiledeviceUtil$GetApnonceTask.call(LibimobiledeviceUtil.java:71)
        at javafx.graphics@19/javafx.concurrent.Task$TaskCallable.call(Task.java:1426)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

I can get the apnonce value fine if I run blobsaver with sudo.

Redecorating avatar Dec 04 '22 08:12 Redecorating

@Redecorating how did you install libirecovery?

airsquared avatar Dec 14 '22 22:12 airsquared

I have it from the AUR:

> pacman -Q libirecovery-git 
libirecovery-git 2:1.0.0.r47.gab5b4d8-1
> pacman -Ql libirecovery-git
libirecovery-git /usr/
libirecovery-git /usr/bin/
libirecovery-git /usr/bin/irecovery
libirecovery-git /usr/include/
libirecovery-git /usr/include/libirecovery.h
libirecovery-git /usr/lib/
libirecovery-git /usr/lib/libirecovery-1.0.so
libirecovery-git /usr/lib/libirecovery-1.0.so.3
libirecovery-git /usr/lib/libirecovery-1.0.so.3.0.0
libirecovery-git /usr/lib/pkgconfig/
libirecovery-git /usr/lib/pkgconfig/libirecovery-1.0.pc
libirecovery-git /usr/lib/udev/
libirecovery-git /usr/lib/udev/rules.d/
libirecovery-git /usr/lib/udev/rules.d/39-libirecovery.rules
> cat /usr/lib/udev/rules.d/39-libirecovery.rules
# Handle iOS devices in DFU and Recovery mode - for use with libirecovery

# Change group and permissions of iOS devices in DFU, legacy WTF, and Recovery mode
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="05ac", ATTR{idProduct}=="122[27]|128[0-3]", OWNER="root", GROUP="storage", MODE="0660"

# Handle checkra1n DFU mode
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="05ac", ATTR{idProduct}=="1338", OWNER="root", GROUP="storage", MODE="0660"

It includes a udev rule, although I'm not too sure of how to check if this rule is changing the permissions of the usb device or not.

Redecorating avatar Dec 15 '22 04:12 Redecorating

I'll move this to a discussion, since it doesn't seem like something that can be easily fixed.

airsquared avatar Jan 22 '23 23:01 airsquared