ethical-haquer / Galaxy-Flasher

A GUI for Samsung Flash Tools
GNU General Public License v3.0
56 stars 4 forks source link

[Bug]: Nothing showing in the log when run thor with sudo. #15

Closed Kreuger closed 3 months ago

Kreuger commented 4 months ago

What happened?

I loaded the program fine at first. When I tried clicking connect it gave me an error "fail to find valid endpoints". I had toggled run thor with sudo on so I thought maybe I needed to restart the app for it to work properly. Now when it opens, I don't see anything on the log screen and can't click connect or anything else. The only buttons that work are the tabs and the file selection buttons. If I try to run the flatpak command with sudo infront, it says that I don't have GF installed. If I turn off "run with sudo" then it will load fine but I'm back to the error about valid endpoints. Can we maybe have it prompt for a SU password (for example as an Lubuntu user, it would use lxqt-sudo)?

Galaxy Flasher version

Alpha v0.5.0

Galaxy Flasher's log output

n/a

Flash tool's log output

n/a
ethical-haquer commented 4 months ago

Thanks for reporting this! So yes, currently the "Run Thor with sudo" setting only applies upon restart. As for the "Failed to find valid endpoints!" error, that is this issue: https://github.com/Samsung-Loki/Thor/issues/9. So far no one knows how to fix it (or even what causes it). In short, there's not much I can do about that. Now about that issue you're having with using sudo, that's because Galaxy Flasher disables buttons until it detects "[sudo] password for" in the output. Perhaps your sudo prompt uses a different format? If so, please let me know what's displayed in the Log Tab after the app starts up (with "Run Thor with sudo" enabled). Thanks!

Kreuger commented 4 months ago

Absolutely nothing shows in the log tab at all when I launch it with sudo enabled. Where is it supposed to prompt for my password?

ethical-haquer commented 4 months ago

It's supposed to look like this: Galaxy-Flasher-Thor-sudo-prompt However, after testing it on my system, I actually got the same result! 🤣 Apparently, the issue only effects the flatpaks. I will look into what needs to be done to fix this, and hopefully have it fixed in the next release. In the meantime, have you tried using Odin4? Thanks for alerting me to this!

justaCasualCoder commented 4 months ago

@ethical-haquer The issue is simple, sudo is not included in the org.gnome.Platform flatpak:

flatpak run --command=sudo com.ethicalhaquer.galaxyflasher
bwrap: execvp sudo: No such file or directory

The option should probably be disabled in flatpak anyway, because it won't do anything (the host needs to give permissions, not the flatpak).

ethical-haquer commented 4 months ago

@justaCasualCoder Sorry, I meant fixing the "Run Thor with sudo" setting not working with the flatpak. So, as I'm sure you know, you can't run a sudo command in the sandbox. This is what I've come up with so far:

# Add this line to the finish-args in com.ethicalhaquer.galaxyflasher.yml for this to work:
# "- --talk-name=org.freedesktop.Flatpak"
if self.settings.get("sudo", False) and self.flashtool == "thor":
                # This would still be used if the app isn't a flatpak, I think.
                # flashtool_exec = ["sudo", flashtool_path]
                # For a flatpak.
                flashtool_exec = [
                    "flatpak-spawn",
                    "--host",
                    "--env=TERM=xterm-256color",
                    "--directory=/home/ethical_haquer",
                    "sudo",
                    "-S",
                    "./TheAirBlow.Thor.Shell",
                ]

Obviously without the hard-coded values though. I also don't really like bundling the flash-tools with the app, because it makes the release almost 80Mbs. If you're on x64 you don't need the arm64 version of Thor. We could have multiple different release files for different platforms, but I was thinking the app would let you choose a file to use (like in prev releases) and maybe also allow downloading them.

What are your thoughts on this?

Kreuger commented 4 months ago

I think if youre going to do separate releases, you might as well do deb/rpm/etc. The idea of a flatpak is one single package for all, to make releases easier right? I dont think 80mb is a lot.

ethical-haquer commented 4 months ago

@Kreuger, @justaCasualCoder

I think if youre going to do separate releases, you might as well do deb/rpm/etc. The idea of a flatpak is one single package for all, to make releases easier right? I dont think 80mb is a lot.

Yeah, doing separate releases might be something for in the future, but for now Galaxy Flasher just needs to get on FlatHub. And yes, 80Mb isn't a ton, but if it can be made smaller, that's better. Especially with people with slow internet speeds.

This is what the improved flash-tool setting I'm working on looks like right now: new-flash-tool-setting

justaCasualCoder commented 4 months ago

@ethical-haquer It looks good! About the "Run Thor with Sudo" in Flatpak, that looks good too, but running Thor with sudo is not really the proper way to do it. Adding a udev rule would be better (or telling the user how to).

ethical-haquer commented 4 months ago

@justaCasualCoder You're right, the "Run Thor with sudo" setting should be removed. I'll look into making adding the udev rule easier.

ethical-haquer commented 3 months ago

@Kreuger This issue was fixed in Alpha v0.5.1. If you get a chance to try it let me know what you think!

Kreuger commented 3 months ago

I am unable to build the new release. I have posted a log here showing the output.

ethical-haquer commented 3 months ago

I am unable to build the new release. I have posted a log here showing the output.

Thanks for the info. I uploaded a new release file, it should be fixed now. I really need to automate testing. 😊

Kreuger commented 3 months ago

Ill try it again later today.

Kreuger commented 3 months ago

I was able to install it no problem but it doesn't seem to detect my phone. I tried doing it with my phone mounted and unmounted, nothing. The connect button just stays greyed out. Also, it doesn't seem to remember which tool you set upon restart.

ethical-haquer commented 3 months ago

I was able to install it no problem but it doesn't seem to detect my phone. I tried doing it with my phone mounted and unmounted, nothing. The connect button just stays greyed out. Also, it doesn't seem to remember which tool you set upon restart.

The settings file, which is called "settings.json" is located at ~/.var/app/com.ethicalhaquer.galaxyflasher/config/galaxy-flasher, for the flatpak. The contents of that are human-readable, here's what mine looks like: {"odin4_file": "/home/ethical_haquer/odin4", "flash_tool": "odin4", "auto_partitions": false, "theme": "system", "thor_file": "/home/ethical_haquer/TheAirBlow.Thor.Shell", "keep_log_dark": true, "pythor_file": "/home/ethical_haquer/pythor_cli"}

The README doesn't have this info, but the first time you run Galaxy Flasher, you have to select a flash-tool to use in settings. For example, in this screenshot an Odin4 executable hasn't been selected, so you will be prompted to select one if you choose it: odin4-not-set

It sounds like you are already trying to do that though. Is there ever any output in the Log Tab? If so, could you copy/paste it here? (right click in the Log Tab to copy). Could you copy/paste the contents of your settings file, once before changing the flash-tool setting, and once after changing it by doing this:

  1. Copy/paste contents of settings file
  2. Run Galaxy Flasher
  3. Change the flash-tool setting (change Thor to Odin4, etc)
  4. Change the executable file of one of the flash-tools (e.g. click the "file" icon and pick a different file, if possible)
  5. Close Galaxy Flasher
  6. Copy/paste contents of settings file

Sorry that it's causing so many problems for you, hopefully I can figure out why it's doing that. TIA.

Kreuger commented 3 months ago

Yes I was trying to set the flash tool. Nothing shows in the log tab except that it tells me to set a flash tool. I tried setting both thor and odin4 and nothing else appears. When I run it from the terminal it says "flash_tool set to: thor/odin4" but nothing else after. Is the problem that my phone needs to be in recovery phone to work? Also it's not a big deal, I can't actually flash anything to my phone. I just wanted to try it out and seeing as I found some issues, I thought I'd help out by reporting them for you.

Also: I don't have a /var/app folder at all.

ethical-haquer commented 3 months ago

Yeah, once you set the flash-tool, close GF, and then restart it, the flash-tool should be set to what you chose. This is the output you should expect to see after setting the flash-tool:

Selected Thor executable: /home/ethical_haquer/TheAirBlow.Thor.Shell
thor_file set to: '/home/ethical_haquer/TheAirBlow.Thor.Shell'
flash_tool set to: 'thor'

It is prompting you to select a flash-tool executable (with a file-picker), right?

Your phone doesn't even need to be connected to your computer, unless your actually connecting/flashing it. That's not the issue.

Also, the var folder is hidden (".var"). Maybe that's why you couldn't find it? There's also a chance that the config folder is somewhere else on your system, let me know if that's the case.

Once again, I'm really sorry it's causing this many issues for you. I understand that you aren't actually using it, and it's not a big deal for you, but as long as I'm not irritating you with all these questions, I would like to figure out what the problem is. If you get tired of me, please just let me know! :smile:

Kreuger commented 3 months ago

Ah see I havent been using the file picker because for some silly reason, I didnt think I needed to. I thought both thor and odin were bundled and the file picker was for if you had them installed already and wanted to use your own for whatever reason.

I only plugged my phone in when I had noticed that the connect button was greyed out.

I found the var folder. I didnt realize it was in the user directory. I was looking in the system /var/ folder. Here is what the file shows:

{"theme": "dark", "flash_tool": "odin4", "sudo": false, "keep_log_dark": true}

Are you planning to release an actual flatpak file at some point that doesnt require the user compiling it themself?

Edit: I don't mind the questions, Im happy to help and appreciate your work. It's not often tools are ported to Linux, especially with a GUI.

Edit 2: Okay Im rather confused by this. I grabbed thor from the github linked in the readme. It appears to be a bunch of DLL files. When I selected it and relaunched GF, it told me that I need the .NET framework but that's an exe file. I don't have wine installed and really have no other need for it. Is this really all we have? Im a little bit disappointed. I thought it was native code. At least your app is working fine now.

ethical-haquer commented 3 months ago

If you click the "info" icons for the flash-tools, they will give you some info about the flash-tools, along with a link to download them: info-button For Thor, It's programmed in C#, which needs .NET to run. However, I built an executable that is self-contained, and doesn't require .NET to be installed. The link for it is included in the info dialog.

All of this info should be in the documentation, but it's not yet. I hope to have the documentation on something like Read The Docs in the near future. Also, yes, there will be a flatpak at some point. First GF needs a logo, and some further improvements. But yeah, that's definitely the plan. If possible, there could be packages for Debian/Ubuntu, Arch, etc. as well, at some point.

Kreuger commented 3 months ago

Thanks. I somehow missed the link for the self-contained file. Oddly, it now says I have to run as root or edit the udev rules. But it didn't show that when I used the other version. It also says "failed to download usb.ids" no device will be shown".

ethical-haquer commented 3 months ago

Yeah, it says: "You have to run Thor as root or edit udev rules as follows.." even after you edit the udev rules. And the "Run Thor with sudo" setting was removed since editing the udev rules is the "proper" way of doing it. In future versions I hope to make editing the udev rules something GF does for you. As for the "Failed to download "usb.ids"" message, that is not a big deal, as it always showed you device as an S2, regardless of what is was. I'm realizing now that it probably shows that message because it doesn't have access to the internet, to download it. I may revert the changes I made that removed copying that file, as that will prevent the error from showing, but yeah, it'll just show "unknown device" instead of "Samsung S2". Also feel free to try Odin4, the link to download it is in it's info dialog. I really appreciate you trying out the app again, reporting bugs, and answering my questions!

Kreuger commented 3 months ago

Yeah, it says: "You have to run Thor as root or edit udev rules as follows.." even after you edit the udev rules. And the "Run Thor with sudo" setting was removed since editing the udev rules is the "proper" way of doing it. In future versions I hope to make editing the udev rules something GF does for you. As for the "Failed to download "usb.ids"" message, that is not a big deal, as it always showed you device as an S2, regardless of what is was. I'm realizing now that it probably shows that message because it doesn't have access to the internet, to download it. I may revert the changes I made that removed copying that file, as that will prevent the error from showing, but yeah, it'll just show "unknown device" instead of "Samsung S2". Also feel free to try Odin4, the link to download it is in it's info dialog. I really appreciate you trying out the app again, reporting bugs, and answering my questions!

I couldnt get it to run by sticking lxsudo infront of the command. It seems that it cant detect it being installed. I guess because I didnt install it system wide?

I tried creating the udev file and relaunching GF but it didnt seem to work. Also I believe that folder requires root access so I dont think you could have GF create/edit that file without the user doing it manually and setting the proper permissions.

I also toyed around with odin4 and even tried to use pythor. But none of them seem able to find my phone. And since I cant flash to it anyway, thats not a bit deal. Im just happy to try the program out and certainly dont mind testing - reporting issues.

ethical-haquer commented 3 months ago

@Kreuger First of all, sorry for my delayed response! What were you not able to run? GF? So you have a /etc/udev/rules.d/51-android.rules file? If so, what is its contents? What phone do you have? TIA, and once again, sorry for the wait!

Kreuger commented 3 months ago

No worries. Im actually on vacation so I will get back to you in a day or 2.

Kreuger commented 3 months ago

Yes, I have created the file.

SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="robbie"

It's the Samsung Galaxy A54. What I couldn't run is the command for GF with lxsudo infront. It says it can't find flatpak.

lxsudo /usr/bin/flatpak run --branch=master --arch=x86_64 --command=/app/bin/entry com.ethicalhaquer.galaxyflasher lxqt-sudo: Stripping child environment except for: DISPLAY,LANG,LANGUAGE,LC_ADDRESS,LC_ALL,LC_COLLATE,LC_CTYPE,LC_IDENTIFICATION,LC_MEASUREMENT,LC_MESSAGES,LC_MONETARY,LC_NAME,LC_NUMERIC,LC_PAPER,LC_TELEPHONE,LC_TIME,PATH,QT_PLATFORM_PLUGIN,QT_QPA_PLATFORMTHEME,TERM,WAYLAND_DISPLAY,XAUTHLOCALHOSTNAME,XAUTHORITY [sudo] password for robbie: /bin/sh: 1: exec: /usr/bin/flatpak: not found

I guess I haven't installed flatpak for all users but only myself?

Edit: I somehow don't have flatpak installed anymore. I have no idea what happened.

Edit 2: Okay I reinstalled it and now have the same error I had the last time trying to run it with lxsudo infront.

lxsudo /usr/bin/flatpak run --branch=master --arch=x86_64 --command=/app/bin/entry com.ethicalhaquer.galaxyflasher lxqt-sudo: Stripping child environment except for: DISPLAY,LANG,LANGUAGE,LC_ADDRESS,LC_ALL,LC_COLLATE,LC_CTYPE,LC_IDENTIFICATION,LC_MEASUREMENT,LC_MESSAGES,LC_MONETARY,LC_NAME,LC_NUMERIC,LC_PAPER,LC_TELEPHONE,LC_TIME,PATH,QT_PLATFORM_PLUGIN,QT_QPA_PLATFORMTHEME,TERM,WAYLAND_DISPLAY,XAUTHLOCALHOSTNAME,XAUTHORITY [sudo] password for robbie: error: app/com.ethicalhaquer.galaxyflasher/x86_64/master not installed

ethical-haquer commented 3 months ago

@Kreuger It should just be flatpak run com.ethicalhaquer.galaxyflasher. What is the output of that command?

Kreuger commented 3 months ago

@Kreuger It should just be flatpak run com.ethicalhaquer.galaxyflasher. What is the output of that command?

Yeah Im not sure how I got that command, actually. I have a shortcut on my desktop and thats what is in there. But I cant remember how I made it. Your command works as a normal user but as root it still says that GF isn't installed.

ethical-haquer commented 3 months ago

@Kreuger You should just run it as a normal user, is there a reason why you want to run it as root?

Kreuger commented 3 months ago

Because it says you have to run Thor as root.

ethical-haquer commented 3 months ago

@Kreuger Yes, but since you edited the udev rules you shouldn't need to run it as root:

You have to run Thor as root or edit udev rules as follows:

It still hasn't been able to detect your device, right?

Kreuger commented 3 months ago

Yeah it didnt work so I tried to run the program as root.

ethical-haquer commented 3 months ago

@Kreuger So the flash-tools start-up fine, but you're unable to connect your device still?

Kreuger commented 3 months ago

Yeah it doesnt show up when using the list command.

ethical-haquer commented 2 months ago

@Kreuger You have your device connected in Download Mode when you run list, right?

Kreuger commented 2 months ago

No I didnt realize that was required.

ethical-haquer commented 2 months ago

@Kreuger No worries. :sweat_smile: Yeah, try just putting it in Download Mode and then connecting. I've been working on the external docs for GF, they can be found here. I'm still working on them, of course.

Kreuger commented 2 months ago

That did indeed work!

ethical-haquer commented 2 months ago

@Kreuger Nice! It should show up in Thor as well than, if you want to test that. You said you couldn't flash your device, right? Is that because it's your daily driver, or something else?

Kreuger commented 2 months ago

I can give that a try. But my bootloader isnt unlocked.

ethical-haquer commented 2 months ago

@Kreuger Alright. What model of the Galaxy A54 do you have?

Kreuger commented 2 months ago

A546E/DS.

ethical-haquer commented 2 months ago

@Kreuger Are you able to enable OEM unlocking from developer settings?

Kreuger commented 2 months ago

Yes I have it OEM unlocked.