LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 12-06-2006, 11:22 PM   #1
awaiz
LQ Newbie
 
Registered: May 2006
Posts: 4

Rep: Reputation: 0
set uid and sticky bit question.


Hi All,

setuid;
can i set uid on files and directories ?? if not what will happen if a uid is set on a file.
if uid is set on a executable, will users other than the owner will be able to delete and modify the executable ?
stick bit: does the concept of sticky bit mean only the owner will be able to delete the file in that directory?
if a dir has write permissions to others, will others group be able to delete the files if no sticky bit is set?

how do i determine if an os is 32 bit or 64 bit if uname -a does not give appropriate info.

regards,
Awaiz.
 
Old 12-07-2006, 12:27 AM   #2
vimalkumar_k
LQ Newbie
 
Registered: Nov 2006
Posts: 14

Rep: Reputation: 0
SUID:
=======
SUID is generally set for executables... suppose u have an executable file "/hello" with owner and group both as root, and u set an SUID to this executable, the concept is that, (wt i believe),

when u execute the above file as a normal user, say joe:

[joe@localhost ~]$ cd /
[joe@localhost /]$ ./hello

then the /hello is executed as if root is executing it (i.e., it's owner is executing it)..

To modify or delete a file set by SUID depends on the "write" permission of the file set to others.

sticky-bit:
=============
The concept of sticky bit comes mainly in an environment where, say 3 users in the same group (i.e, have same secondary group) are sharing a directory .. say /shared

In this case, first the group of the dir. is changed using:

[root@localhost /]# chgrp mygroup /shared

Not to say, the user's sec. group should be "mygroup"

Then add SGID to this dir. using :
[root@localhost /]# chmod g+s /shared

Now, every file created in this directory would have group as "mygroup" , and have rw permission for mygroup.

In this case, any user in the mygroup can read, write or delete files in this directory...

When we have to restrict, like, only the user who created the file should delete it, but he can view/change other files in the same directory, the stickybit is implemented.

[root@localhost /]# chmod o+t /shared

This prevent other users in the same group from deleting files that dont belong to them.. however they can make changes to others files...

But ofcourse, this restriction is not considered when root tries to delete a file here... As u know, root has the complete power!!

I think this should help u know sticky-bit n SUID...
 
Old 12-07-2006, 12:39 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If a directory has the sticky bit set, then you can't delete someone else's files. This is how the /tmp directory is created. This allows all users to create files there. If you don't want someone else to be able to make changes to your own file, then change the permissions of the file itself to prevent it. Deleting a file writes to the directory and not the file itself. ( To the kernel, a directory is a file ) That is why the sticky bit is needed for world writable directories, because without it someone with write access to the directory could delete any file.

Last edited by jschiwal; 12-07-2006 at 08:32 AM.
 
Old 12-07-2006, 12:40 AM   #4
awaiz
LQ Newbie
 
Registered: May 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Hi Vimal,

Do these special permissions work only on specific kernel versions?? coz i have tried setting up these permissions on EL4(dont remember the version of the kernel)but dont seem to work.
any idea ??

Awaiz.
 
Old 12-07-2006, 07:14 AM   #5
doc.nice
Member
 
Registered: Oct 2004
Location: Germany
Distribution: Debian
Posts: 274

Rep: Reputation: 34
Attention: SUID is NOT generally set on executables, as mentioned above.
This would be a big securtity flaw, as a simple buig in an application yould be used to execute harmful code with root rights.
SUID is often used for applications that i.e. need direct access to hardware devices that are normally only accessible to root.
shell scripts can't be set SUID for security reasons.

the SGID and sticky descriptions above seem to be right.
 
Old 12-07-2006, 11:08 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The suid, sguid bits are standard in Linux and Unix unless you have a very old Unix. There are some other permission features which you may not have or are not supported by the filesystem. One example is ACL's. They allow you to use the setfattr and setfacl commands to add more granularity to the permission system.
Using ACLs you can set permissions for certain users and groups. You can give groupA and groupB and user mikes full access and give groupC and user sallyg read-only access. The ext2 and ext3 filesytems allow you to use additional file attributes such as immutable. ( man lsattr, man chattr ). The selinux kernel adds a security model where you can control which process is allowed to alter a file. Even root can't change such a file in this case. Fedora Core uses a kernel with SELinux by default.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About Sticky bit... masudur_iiu General 4 09-13-2006 10:23 AM
ProFTPD: Set umask so that directories are created with 'sticky bit' on. dutch2005 Linux - Software 1 09-06-2005 05:06 AM
Sticky Bit tarballed Linux - General 4 07-03-2002 03:54 PM
Sticky bit question...need help rootlinux Linux - General 1 01-26-2002 05:12 PM
sticky bit motiram Linux - General 1 08-01-2001 12:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 03:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration