Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Using blobsaver with sudo on Linux hint in Wiki or Readme #459

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

Closed
Tuerpe opened this issue Jul 19, 2022 · 15 comments
Closed

Using blobsaver with sudo on Linux hint in Wiki or Readme #459

Tuerpe opened this issue Jul 19, 2022 · 15 comments
Labels
question Further information is requested

Comments

@Tuerpe
Copy link

Tuerpe commented Jul 19, 2022

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 Tuerpe added the question Further information is requested label Jul 19, 2022
@xerz-one
Copy link

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

@superrnovae
Copy link

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"

@Tuerpe
Copy link
Author

Tuerpe commented Jul 23, 2022

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.

@superrnovae
Copy link

superrnovae commented Jul 23, 2022

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.

@Tuerpe
Copy link
Author

Tuerpe commented Jul 24, 2022

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

@xerz-one
Copy link

xerz-one commented Sep 10, 2022

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.

@stale stale bot removed the Stale label Sep 10, 2022
@stale stale bot added the Stale label Oct 12, 2022
@xerz-one
Copy link

is this gonna become my job now

@stale stale bot removed the Stale label Oct 12, 2022
Repository owner deleted a comment from stale bot Nov 7, 2022
Repository owner deleted a comment from stale bot Nov 7, 2022
@airsquared
Copy link
Owner

I was not aware of this.

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

@xerz-one
Copy link

xerz-one commented Nov 7, 2022

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.

@airsquared
Copy link
Owner

airsquared commented Nov 7, 2022

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
Copy link
Owner

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.

@Redecorating
Copy link
Contributor

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.

@airsquared
Copy link
Owner

@Redecorating how did you install libirecovery?

@Redecorating
Copy link
Contributor

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.

@stale stale bot added the Stale label Jan 21, 2023
@airsquared
Copy link
Owner

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

Repository owner deleted a comment from stale bot Jan 22, 2023
@stale stale bot removed the Stale label Jan 22, 2023
Repository owner locked and limited conversation to collaborators Jan 22, 2023
@airsquared airsquared converted this issue into discussion #545 Jan 22, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants