Repository: lutris/lutris

Issue:
wine sandboxing error in 0.5.3
Hello,
it seems you resolved issue #2114 but now, when I launch any of my wine games, I obtain this error message:
`[Errno 21] est un dossier: '/home/legluondunet/Games/test/drive_c/users/legluondunet/Downloads'`

* "est un dossier" = "is a folder"

then an other error message:
`en error prevented the game to launch`

I can reproduce this issue with all my installed wine game, **even with new installed game**.
Workaround: disable sandboxing...


Discussion:
@G4E 
Could you run ls -l in your folder /home/legluondunet/Games/diablo-tchernoblog/drive_c/users/ please ?
I think the issue might be related to old wine prefix with non working sandbox, which might be in conflict with the new "correct" way to sandbox.
I can't reproduce on my end.
There is another issue actually with the fix : with the upgraded lutris, you seems to "lose" your savegames and such, as they where previously saved in your ~/Documents/SaveGame or whatever, and now the folder is empty in the sandbox.
I don't see any good solution to this problem atm, except unticking the sandbox option for prefix created with lutris < 0.5.3 
I have the same problem with new install...I have to unticking the sandbox option
@legluondunet peux tu faire ls -l dans /home/legluondunet/Games/diablo-tchernoblog/drive_c/users/legluondunet stp ?
I'm on lutris' discord if you want to talk about the issue quicker.
Lutris log from @legluondunet
```
2019-09-04 17:55:29,291: Creating a win64 prefix in /home/legluondunet/Games/test
2019-09-04 17:55:52,397: win64 Prefix created in /home/legluondunet/Games/test
2019-09-04 17:55:52,476: Failed to setup desktop integration, the prefix may not be valid.
2019-09-04 17:55:52,476: [Errno 21] est un dossier: '/home/legluondunet/Games/test/drive_c/users/legluondunet/Downloads'
Traceback (most recent call last):
  File "/home/legluondunet/Autres_applications/Jeux/Lutris/lutris/lutris/util/wine/prefix.py", line 26, in setup_defaults
    self.desktop_integration()
  File "/home/legluondunet/Autres_applications/Jeux/Lutris/lutris/lutris/util/wine/prefix.py", line 121, in desktop_integration
    os.unlink(path)
IsADirectoryError: [Errno 21] est un dossier: '/home/legluondunet/Games/test/drive_c/users/legluondunet/Downloads'
2019-09-04 17:55:52,477: python3-evdev not installed, controller support not available
2019-09-04 17:55:52,537: Error while completing task <bound method wine.prelaunch of <lutris.runners.wine.wine object at 0x7f91744e6860>>: [Errno 21] est un dossier: '/home/legluondunet/Games/test/drive_c/users/legluondunet/Downloads'
<class 'IsADirectoryError'> [Errno 21] est un dossier: '/home/legluondunet/Games/test/drive_c/users/legluondunet/Downloads'
  File "/home/legluondunet/Autres_applications/Jeux/Lutris/lutris/lutris/util/jobs.py", line 30, in target
    result = self.function(*args, **kwargs)
  File "/home/legluondunet/Autres_applications/Jeux/Lutris/lutris/lutris/runners/wine.py", line 762, in prelaunch
    self.sandbox(prefix_manager)
  File "/home/legluondunet/Autres_applications/Jeux/Lutris/lutris/lutris/runners/wine.py", line 895, in sandbox
    desktop_dir=self.runner_config.get("sandbox_dir")
  File "/home/legluondunet/Autres_applications/Jeux/Lutris/lutris/lutris/util/wine/prefix.py", line 121, in desktop_integration
    os.unlink(path)
2019-09-04 17:55:52,538: [Errno 21] est un dossier: '/home/legluondunet/Games/test/drive_c/users/legluondunet/Downloads'
2019-09-04 17:57:35,720: Game prelaunch unsuccessful
```
Ok we've worked it out.
The bug has been introduced by commit 7856a2abefcc503a0cd327b0cfbe263ff30f45c5, which miscorrected the mistake.
Basically, we check the user's folder for symlinks instead of the wine's prefix, and @legluondunet has a symlink there.
```python
            # Security: Remove other symlinks.
            for item in os.listdir(user_dir):
                if item not in DESKTOP_FOLDERS and os.path.islink(item):
                    path = os.path.join(user_dir, item)
```
should be
```python
            # Security: Remove other symlinks.
            for item in os.listdir(user_dir):
                path = os.path.join(user_dir, item)
                if item not in DESKTOP_FOLDERS and os.path.islink(path):
```

Resolving patch:
diff --git a/lutris/util/wine/prefix.py b/lutris/util/wine/prefix.py
--- a/lutris/util/wine/prefix.py
+++ b/lutris/util/wine/prefix.py
@@ -116,8 +116,8 @@ def desktop_integration(self, desktop_dir=None):
 
             # Security: Remove other symlinks.
             for item in os.listdir(user_dir):
-                if item not in DESKTOP_FOLDERS and os.path.islink(item):
-                    path = os.path.join(user_dir, item)
+                path = os.path.join(user_dir, item)
+                if item not in DESKTOP_FOLDERS and os.path.islink(path):
                     os.unlink(path)
                     os.makedirs(path)
 


Test patch: