Matoking / protontricks

A wrapper that does winetricks things for Proton enabled games, requires Winetricks.
GNU General Public License v3.0
1.66k stars 36 forks source link

protontricks fails if user has insufficient permissions to access file/directory #111

Closed wright-p closed 3 years ago

wright-p commented 3 years ago

Describe the bug I use a custom version of proton, however Steam tries to install Proton 3.7 along with some games that are flagged to use that specific version. To prevent Steam from downloading that version of proton, I emptied its directory and changed its owner to root with my own user not having permission.

To Reproduce Steps to reproduce the behavior: I went into my .local/share/Steam/steamapps folder, and did: sudo chown root:root appmanifest_858280.acf sudo chmod 600 appmanifest_858280.acf sudo chown -R root:root common/Proton\ 3.7 sudo chmod 700 common/Proton\ 3.7 and then if I ran any protontricks command I would get a PermissionError and protontricks would fail.

Expected behavior protontricks should skip over files and directories without permission

System (please complete the following information):

If the error happens when trying to run a Protontricks command, run the command again using the -v flag and copy the output!

protontricks -v --gui
protontricks (INFO): Found Steam directory at /home/((USERNAME)/.steam/steam. You can also define Steam directory manually using $STEAM_DIR
protontricks (INFO): Using default Steam Runtime at /home/((USERNAME))/.steam/root/ubuntu12_32/steam-runtime
protontricks (INFO): WINETRICKS environment variable is not available. Searching from $PATH.
protontricks (INFO): Found 1 Steam library folders
Traceback (most recent call last):
  File "/usr/bin/protontricks", line 33, in <module>
    sys.exit(load_entry_point('protontricks==1.5.2', 'console_scripts', 'protontricks')())
  File "/usr/lib/python3.9/site-packages/protontricks/cli.py", line 180, in main
    steam_apps = get_steam_apps(
  File "/usr/lib/python3.9/site-packages/protontricks/steam.py", line 916, in get_steam_apps
    steam_app = SteamApp.from_appmanifest(
  File "/usr/lib/python3.9/site-packages/protontricks/steam.py", line 160, in from_appmanifest
    content = path.read_text(encoding="utf-8")
  File "/usr/lib/python3.9/pathlib.py", line 1256, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.9/pathlib.py", line 1242, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.9/pathlib.py", line 1110, in _opener
    return self._accessor.open(self, flags, mode)
PermissionError: [Errno 13] Permission denied: '/home/((USERNAME))/.steam/steam/steamapps/appmanifest_858280.acf'

I was able to get past this error by modifying steam.py as follows:

diff /usr/lib/python3.9/site-packages/protontricks/steam.py steam.py
160a161,165
>         except PermissionError:
>             logger.warning(
>                 "Skipping file without permissions %s", path
>             )
>             return None
Matoking commented 3 years ago

I've pushed a fix to master. Since the Steam client ignores inaccessible appmanifest files, it makes sense for Protontricks to do the same.

Thanks for the report.

CaptainMorgan12 commented 8 months ago

Ubuntu 23.10, Steam Flatpak Install

The

`diff /usr/lib/python3/distribution-packages/protontricks/steam.py steam.py

    except PermissionError:
        logger.warning(
            "Skipping file without permissions %s", path
        )
        return None`

Is already contained in my steam.py and it still generates an error:

$protontricks --gui

protontricks (WARNING): Current Steam Runtime not recognized by Protontricks. /home/user/.cache/protontricks/proton/Proton Experimental/bin/bwrap-launcher: line 83: /home/user/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/SteamLinuxRuntime_sniper/run: Permission denied winetricks GUI enabled, using zenity 3.44.2

Is that related?