You are not logged in.

#1 2009-02-01 21:07:07

ahcaliskan
Member
From: Sweden
Registered: 2008-10-29
Posts: 174

How to "chown -R" global directory for the non-root user?

How do I create a code in PKBUILD that changes global directory recursively on /opt/ for non-root user without knowning the user X's name? I am in a situation where normal user cannot update a game that I maintain, despite the fact that I have done "chown -R root:games" and chmod -R g+w. Adding user into games group doesn't help. So I did setuid on the directory binaries to let the user update the game.

Offline

#2 2009-02-02 00:28:09

kludge
Member
Registered: 2008-08-03
Posts: 294

Re: How to "chown -R" global directory for the non-root user?

ahcaliskan wrote:

How do I create a code in PKBUILD that changes global directory recursively on /opt/ for non-root user without knowning the user X's name? I am in a situation where normal user cannot update a game that I maintain, despite the fact that I have done "chown -R root:games" and chmod -R g+w. Adding user into games group doesn't help. So I did setuid on the directory binaries to let the user update the game.

i'm not entirely sure what you mean by "changes global directory recursively," but what i think you're asking is how to give ownership of an entire directory tree to a given user without knowing that user's name.  i'm pretty sure that's why there are groups.  if you can know the uid, you could use that.  otherwise, afaik, that's unpossible.


[23:00:16]    dr_kludge | i want to invent an olfactory human-computer interface, integrate it into the web standards, then produce my own forked browser.
[23:00:32]    dr_kludge | can you guess what i'd call it?
[23:01:16]    dr_kludge | nosilla.
[23:01:32]    dr_kludge | i really should be going to bed.  i'm giggling madly about that.

Offline

#3 2009-02-02 12:32:37

ahcaliskan
Member
From: Sweden
Registered: 2008-10-29
Posts: 174

Re: How to "chown -R" global directory for the non-root user?

I know it's impossible, but there could be work around through a well thought script. However, I could install in the home directory of the user, and there be no usage of setuid then. Is it possible to install that way then?

Offline

#4 2009-02-02 14:57:25

jordz
Member
Registered: 2006-02-01
Posts: 248

Re: How to "chown -R" global directory for the non-root user?

The best way is to use your games group, that's the only proper way.

Last edited by jordz (2009-02-02 14:58:02)

Offline

#5 2009-02-02 14:58:38

pointone
Wiki Admin
From: Waterloo, ON
Registered: 2008-02-21
Posts: 379

Re: How to "chown -R" global directory for the non-root user?

The "correct" solution to this problem is indeed to use the setuid bit.

Another "correct" way to overcome this problem is to save updated game files in the user's home directory.

Having the user own a directory in /opt is "incorrect".


M*cr*s*ft: Who needs quality when you have marketing?

Offline

#6 2009-02-02 16:05:48

ahcaliskan
Member
From: Sweden
Registered: 2008-10-29
Posts: 174

Re: How to "chown -R" global directory for the non-root user?

I maintain savage  2, and s2games have their own integrated update script within the game. I've requested for a linux update script, but they wan't do know how that script should be like. Here is the tread:
http://forums.savage2.com/showthread.php?t=15648

Anyway, I tried with "$startdir/pkg/$HOME/" in my PKGBUILD and it works, however root claims the ownership. Is there a workaround? If there is I want to use this code:

    export user=$(whoami)
    chown -R $user:games $HOME/.S2GamesSav2

So far I'm trying to write a bash script, ie "if [[ $UID = 0 ]]; then", to switch to uid 1000 or exit root, but haven't managed to do that.

Last edited by ahcaliskan (2009-02-02 16:09:10)

Offline

#7 2009-02-02 16:19:09

jordz
Member
Registered: 2006-02-01
Posts: 248

Re: How to "chown -R" global directory for the non-root user?

export user=$(whoami), you will always get root there, because you are installing this package as root.
You only should change the group to games and give it write permissions, for example chmod it with 775.

Offline

#8 2009-02-02 16:23:29

ahcaliskan
Member
From: Sweden
Registered: 2008-10-29
Posts: 174

Re: How to "chown -R" global directory for the non-root user?

well, with this game that doesn't work, at least not in /opt or /usr directory. Haven't tested in /home directory tough. This is why either setuid or non-root user(if you install it in /home) is required to update savage, despite including user to the games group. Well I'll try it anyway.

Udate: failed to update!

Last edited by ahcaliskan (2009-02-02 16:38:15)

Offline

#9 2009-02-02 16:27:15

jordz
Member
Registered: 2006-02-01
Posts: 248

Re: How to "chown -R" global directory for the non-root user?

It doesn't depend on the game, i suggest you should read some basic permissions info.
Did you try to Install the package and logoff and login again?

Offline

#10 2009-02-02 16:31:25

ahcaliskan
Member
From: Sweden
Registered: 2008-10-29
Posts: 174

Re: How to "chown -R" global directory for the non-root user?

Yes I have, and I've done quite a lot experimenting as well smile Here is what the developer says concerning the permissions:

Regarding setuid, the way the game handles a multi-user environment is to install it as games:games, with the setuid bit set on the bins (and write only for users). Upon launching the game, it immediately returns to the uid of the user that launched the game and only elevates when it needs to write to the game directory, ie, when it is updating.

What if I create a games user during install, am I allowed to do that as a maintainer?

pointone is right, I'll stick with setuid bit and install the game in users home directory, at least considering the fact that updates are made by the user. [update: installing to home directory works only with sudo not su]

Last edited by ahcaliskan (2009-02-03 18:35:12)

Offline

Board footer

Powered by FluxBB