Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Does the suid bit have any special meaning for device files in Linux ?

share|improve this question
    
find /dev -perm /ugo+s gives nothing on my machine (nor a few others I checked); does your machine have set id/sticky entries in /dev ? –  derobert Sep 13 '12 at 15:45

1 Answer 1

up vote 3 down vote accepted

I believe it is not. This bit is only used on executable files. It's defined in Linux kernel headers as S_ISUID. If you grep kernel sources for this constant, you will find that it is only used in:

  • should_remove_suid function, which is used on FS operations that should remove SUID/SGID bit,
  • prepare_binprm function in fs/exec.c which is used when prepairing executable file to set EUID on exec,
  • pid_revalidate function in fs/proc/base.c which is used to populate procfs,
  • notify_change function in fs/attr.c which is used when changing file attributes,
  • is_sxid function in include/linux/fs.h which is only used by XFS and GFS specific code and notify_change function,
  • in filesystem specific code (of course)

So it seems to me that this bit is only used (from userspace perspective) when executing files. At least on Linux.

share|improve this answer
    
Don't forget some of these bits serve a purpose for DIRECTories too. –  mdpc Sep 13 '12 at 22:14
    
@mdpc Directories are also files. –  Chris Down Sep 14 '12 at 0:34
    
@mdpc: SUID bit on directory has a meaning at least on ext2/3 filesystem. Some other filesystems may implement some mechanisms similar to SGID bit on directories. But that's filesystem dependent so it only involves filesystem operations. –  Krzysztof Adamski Sep 14 '12 at 6:00
    
Thank you for detailed explanation and answer –  hostmaster Sep 14 '12 at 6:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.