DelphiFAQ Home Search:

How to set the setuid and setgid bit for files in Unix

 

comments2 comments. Current rating: 4 stars (1 votes). Leave comments and/ or rate it.

Question:

I need to set setuid and setgid bit for files.
Please show me how to. And what is the exact purpose of the uid bit?

Answer:

In the shell just type the commands shown in the box below to set the uid or gid bits.

The purpose of the uid bit:
If you change an executable file to have the setuid bit set then when any other user runs this executable the effective user ID of the process will be switched to the user that owns the file. The same way, if you set the gid bit, then the process will be executed under the group of the file. You have to be very careful with this feature as one can easily create a hard-to-spot security whole with it.
The purpose is usually to give the executable file the ability to write to a certain file - e.g. a log file - that the regular user cannot write to. When it runs under the owner's ID, it can write to that file.
Having the process execute under a different user id has some other side effects for example coredumps are disabled and the C runtime library ignores or deletes some environment variables.

// setuid
chmod 4555   executable_file

// setgid
chmod 2555   executable_file

Comments:

2009-01-26, 19:48:07
anonymous from United Kingdom  
rating
2009-10-20, 05:56:42
anonymous from India  
very helpful

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: