LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   suid & sgid on directories (https://www.linuxquestions.org/questions/linux-newbie-8/suid-and-sgid-on-directories-883436/)

Soji Antony 05-30-2011 12:22 AM

suid & sgid on directories
 
Hi

I'm having a bit of a problem with the suid and sgid feature in a directory. I read somewhere that

Quote:

When [the suid bit is] set on a directory, all the files and directories created within this directory will have the same owner as the SUID-directory itself, no matter who created the file.
But it does not seem to be working
Code:

arun~]$mkdir /tmp/abc
chmod u+s /tmp/abc
ls -ld /tmp/abc
drwsrwxrwx 2 arun arun  4096 May 29 20:14 /tmp/abc

But when a user 'tom' go to the directory /tmp/abc, and create a file.
Code:

cd /tmp/abc
touch 1.txt
ls -l 1.txt
-rw_rw_r__ 1 tom tom 0 May 29 20.24 1.txt

As you can see, the new file is owned by tom instead of arun. Please help ...

EricTRA 05-30-2011 01:02 AM

Hello,

The SUID bit is set on files, mainly scripts, to make them run as the user who is the owner of the script rather than the one who started the script.

The same applies for the SGID bit. If the SGID on a file is set then it will run with the privileges of the files group owner, instead of the privileges of the user executing it. You can also set SGID to directories so that any files created by any users in this directory will inherit the group permissions.

So basically setting a SUID on a directory has no effect for as far as file creation is concerned whereas SGID does what you need.

If you want to use SGID, then create a special group and make the necessary users member of that group.

Kind regards,

Eric

Soji Antony 05-30-2011 01:12 AM

Hi Eric

Thank you so much for your reply.....

EricTRA 05-30-2011 01:24 AM

Hi,

You're welcome! Have fun with Linux.

Kind regards,

Eric


All times are GMT -5. The time now is 07:00 AM.