5

I have got a wine installtion with a couple of games, most of which work fabulously. However, wine creates directories in my home for the player data, saves, etc.

Is there a way to have those in ~/.winesaves or something similar? I would prefer wine not littering my home directory.

(wine: 1.5.27, game in question was SCII and DE:IW)


edit to clarify:

Everything in ~/.wine is fine and good, but I don't want applications to create ~/GameSaves or the likes.

1
  • You could try using sudo to put the wine folders in annother user's home directory.
    – user255998
    Mar 8, 2014 at 3:45

4 Answers 4

8

You may need to experiment with the sandbox option present in winetricks, which may help you as all the Wine symlinks to $HOME are removed when that setting is applied to the default WINEPREFIX with winetricks sandbox.

However, wine still has your user's permissions in the home folder, and often when installing a new program, an action in the installation can trigger the sandbox to be removed. So it is not really a true 'sandbox' at all, but it may be helpful for your use case.

At the official wine FAQ it is noted that:

Winetricks does have a sandbox verb that does at least a partial job of isolating Wine programs from the rest of your system. It protects against errors rather than malice. It's useful for, e.g., keeping games from saving their settings in random subdirectories of your home directory.

On the official winetricks page, it is explained that

If you want to isolate an app so that it doesn't save anything to your home directory, you can try 'winetricks sandbox'. That will remove the symlinks to your home directory. Do this before saving any data, or you'll have to copy old saved data from your home directory into $WINEPREFIX/drive_c/users/$USERNAME.

Important notes

  • The wine sandbox option will likely need to be used repeatedly, i.e. include it in a launcher script that runs winetricks sandbox and then launches your game, as a number of things in wine can trigger the rebuilding of the symlinks.

  • The folder of saves you have already generated will need to be moved to your WINEPREFIX, e.g /home/$USER/.wine/drive_c/users/$USER/"My Documents" in order for you to resume your game. If wine has just created a folder called ~/gamesaves, simply move that folder to the location mentioned above. Otherwise, observe the directory structure; if a game save folder is ~/Documents/Syberia/save make sure you create an equivalent in /home/$USER/.wine/drive_c/users/$USER/"My Documents".

  • When you install a game in the future, make sure you run winetricks sandbox at the start, so that the game will automatically start using your WINEPREFIX as the save location, and not a folder in your $HOME.

2
  • Very nice, thank you! Just a minor correction: Move ~/* to /home/$USER/.wine/drive_c/users/$USER/*My Documents* Apr 8, 2013 at 20:13
  • @user538603 Thanks, quick edit done.
    – user76204
    Apr 8, 2013 at 20:16
1

Not a complete solution to fully block wine from modifying the home directory, but I find this works to prevent most programs from polluting my home directory, and is quite a clean solution.

Most of the time (in my experience) when a program running through wine is accessing outside the "~/.wine" folder, it's doing so through symbolic links in the "~/.wine" directory. For example, I had an installer install a folder in my home directory, when really it was trying to install in "C:/users/user name/My Documents" which wine redirects to "~/.wine/drive_c/users/user name/My Documents". It turns out "My Documents" here is actually a symbolic link to my home directory, "~".

So simply removing the symbolic link "My Documents" and creating a folder "My Documents" in "~/.wine/drive_c/users/user name/My Documents" did the trick for me.

PS. I'm surprised I couldn't seem to find this answer around given this question is 6 years old but maybe I just didn't look around enough, so please let me know if this post is redundant.

0

What worked for me was to create a wrapper around wine that launched wine with a different HOME. E.g. you can create your own ~/bin/wine (assuming ~/bin is in your PATH), which sets:

#!/bin/sh
export "HOME=$HOME/.wine/home"
exec /usr/bin/wine "$@"

With an empty WINEPREFIX (~/.wine/), Wine will create the symbolic links to its own private home directory in ~/.wine/home/.

You can expand this further to multiple wrappers for different Wine prefixes (e.g. for 32-bit vs. 64-bit).

0

If you have bubblewrap installed, you can use its mechanisms to limit filesystem access.

Example1. You want wine to have access to ~/.wine , ~/Downloads, but nothing else. You may use this command then:

bwrap --dev-bind / / --tmpfs ~ --bind ~/.wine ~/.wine --bind ~/Downloads ~/Downloads --new-session wine ~/.wine/path-to-your-program

In the command above, we create a new namespace, bind the root /, bind an in-memory filesystem to ~, and bind two directories above the ~. Any changes done outside of those 2 directories will go into tmpfs and will be lost once bubblewrap (and your program) exits.

Example2. You don't want complex hierarchies, you just want all wine-related stuff to live in ~/.bubblewrap-wine-container. And nowhere else. In this case, you can use:

bwrap --dev-bind / / --bind ~/.bubblewrap-wine-container ~ --new-session wine path-to-your-program-relative-to-this-directory

If you want to forbid internet access for any of those examples, add --unshare-net argument. Or maybe even --unshare-all to see if it'll launch. Refer to bubblewrap documentation for further details.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .