Saturday, March 24, 2007

Suid bit

Abstract: chmod +s directory

I'm sure you know the suid bit for executable files. It allows a software to run as the user who owns the file instead of the user who runs it. This works exactly the same way for the group (sgid bit).

But directories also have an executable bit. It allows someone to get into the directory (cd command). And suid bit is also useful for them. It makes new files created in this directory owned by the directory's owner and not by the file's creator.

This is really useful for permitting people to work together in the same directory. You create a group where all the concerned users are. Then you set this group as the owner of your working directory and at last set the sgid bit on it. Then every time a file is created in this directory, it is available for other people in the group since they are in the file's group. Beware of your umask to allow read/write or read only.

No comments: