Steam for Linux > Limited Beta > Topic Details
vodik Nov 29, 2012 @ 9:18pm
Becoming a better citizen on linux
So this past update, steam tried to copy ~/Steam/bin_steam.sh to /usr/bin/steam. (I'm on archlinux btw)

This is definately not the right way to go about doing updates. For one, first because need root privlages, and second because its a file placed there by the package manager. If you want to have some sort of self-updating a binary, here may be a better way going about it, and should play nicer in a multi-user environment.

Ideally you guys should just push out a new .deb file instead and let the package manager update things. However, another approach along how youre doing it could be like this:

I don't claim to have a definative answer, but I hope I can start the discuession to get a better client

1) Create a steam user.
2) Have a simple script in /usr/bin/steam that defers to /var/steam or /opt/steam (whichever)
3) All files here are owned by steam:users.
4) Set umask to 002 (optional) to game files.

Now you're in your own private environment you're free to do whatever you want. You can update the client yourself if its stored in /var/steam/steam. Game files can be shared system wide, so you can share on multi-user system (and TF2 is very _big_ to download twice). If you set the group of game content files to 'users' and set the umask to 002, normal users will still be able to modify these files, even though they're not in their home folders.

**BONUS**: Idealy, for user files, you guys shouldn't be stuffing stuff in ~/Steam or ~/.steam but use xdg user dirs. ~/.config, ~/.locale/share, and ~/.cache are the local versions of etc/, /usr/share, and /var
Showing 1-15 of 83 comments
< >
Dguitarbite Nov 29, 2012 @ 9:25pm 
i believe multiple users need to maintain a different copy of steam with respect to their logins , but there should be a way to universalize things may be your approach is a good way to start with it ...
vodik Nov 29, 2012 @ 9:28pm 
Well its shared on windows. You have steamapps/common and steamapps/<username>. I guess my model for permissions needs to be tweaked a bit, i can see some other flaws already.
Last edited by vodik; Nov 29, 2012 @ 9:29pm
escondida Nov 29, 2012 @ 9:35pm 
The /opt/steam (or /var/steam) could also contain a directory for storing shared libs needed by games; for instance, if a game needed an old version of libpng, there's no way to guarantee distros will keep it around forever.

However, on systems lacking the lib it should be possible to install a copy of it with Steam's other files, and then any game that needed it could have access to it by, say, using a launch script that called the game prepending your libs dir to $LD_LIBRARY_PATH:

LD_LIBRARY_PATH=$steam_libs_dir:$LD_LIBRARY_PATH someGame
vodik Nov 29, 2012 @ 9:38pm 
Yeah, so the steam binary would need to be suid to the steam user so it could overwrite itself. (assuming the steam binary is owned by the steam user).

The uid would still be the user, but the euid would be 'steam' (allowing the update). Afterwards its safe to set the effective user id (steam) to the user id, and steam will be running as if the user sans suid. (pivilage dropping of sorts).
Last edited by vodik; Nov 29, 2012 @ 9:40pm
scott_test123 Nov 29, 2012 @ 10:05pm 
Thanks for your feedback. The latest steam.deb installs to the xdg dir ~/.local/share (if you have an existing install you can move it there manually). We're discussing what to do with the /usr/bin/steam script. We hear your feedback.
ThOR27 Nov 30, 2012 @ 2:55am 
My Idea, to make steam agnostic to platform, is to do a very simple script, I've already posted this in another topic but I will register it here, something like that:

#!/bin/bash

if [ -f ~/.steam/bin/steam ]
then
~/.steam/bin/steam
else
TMPFILE=`tempfile`
wget http://www.steamurltodownloadthis.com/bootstrap.sh -o $TMPFILE
chmod +x $TMPFILE
$TMPFILE
fi

and on the package it should include dependencies for wget.

aka Nov 30, 2012 @ 10:17am 
Putting Steam, and the games Common Files into /opt is a great idea! For a multi user system at least. But running Steam with root privileges are a bit risky; or annoying, if it asks always for root passwd, if a game updates...
DaVince Nov 30, 2012 @ 10:39am 
Originally posted by aka:
Putting Steam, and the games Common Files into /opt is a great idea! For a multi user system at least. But running Steam with root privileges are a bit risky; or annoying, if it asks always for root passwd, if a game updates...
If I'm not mistaken, this is what adding an user to the steam group and setting umask to 002 does: allow all Steam users to update the software without needing a password and without needing root permission more than just on first run.
vodik Nov 30, 2012 @ 12:57pm 
You don't need root and the umask has nothing about self updating, its all about giving the users read/write access to their game files.

You have a steam user and have the steam binary setuid[1] (the one in var/opt). So the steam binary runs as the steam user, not the user who starts it.

This lets steam replace its own binary (you can always replace files you've created in folders you have w permissions in). This means steam can safely update itself without needing to elevate permissions to root.

You can then drop the suid (suid sets euid, not uid. setuid(getuid()) would discard the euid) and now steam is running as the user which started the binary, giving up its permissions. Its privilage dropping of sorts, though not the typical sorts. More horizontal then vertical. (And yes you can do this trick)

If steamapps folder is owned by steam:users and was created with the umask of 002, then everyone in the users group would the same rwx permissions that the steam user would have. Effectively, that means any user can manipulate content in there like it belongs to them.

[1]: https://en.wikipedia.org/wiki/Setuid
Last edited by vodik; Nov 30, 2012 @ 1:09pm
DaVince Nov 30, 2012 @ 1:05pm 
I got that, but you'll need root access to create the steam user group and set the right permissions for it, right? Because the /opt directory is originally owned by root. That's why I mentioned "root permission on first run".
vodik Nov 30, 2012 @ 1:06pm 
That should be, and typically is, the package manager's job.
Last edited by vodik; Nov 30, 2012 @ 1:11pm
mikeym Nov 30, 2012 @ 1:21pm 
+1 for more sane file management
blackout24 Nov 30, 2012 @ 2:31pm 
I second vodiks approach.

I'd also rather have steam /opt because this is where all prop. software goes like dropbox, google earth and such.
mikeym Nov 30, 2012 @ 2:48pm 
I've got it at the back of my mind that /opt is not a standard Linux folder but specific to Ubuntu (although having gained more use because of Ubuntu). Does anyone know if that's right?
blackout24 Nov 30, 2012 @ 2:55pm 
/opt is part of the UNIX Filesystem Hirarchy Standards 2.3 since 2004.
http://www.pathname.com/fhs/
http://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES
Last edited by blackout24; Nov 30, 2012 @ 2:57pm
Showing 1-15 of 83 comments
< >
Per page: 15 30 50
Date Posted: Nov 29, 2012 @ 9:18pm
Posts: 83