系统相关
首页 > 系统相关> > linux – 任何类似Unix的系统是否都意味着目录上的SUID位?

linux – 任何类似Unix的系统是否都意味着目录上的SUID位?

作者:互联网

正如标题所说,任何类似Unix的系统都会对目录中的SUID位赋予意义,如果是这样,它意味着什么?

SVTX(保存文本或粘滞)位有一个含义 – 除非您可以写入该文件,否则不能从该目录中删除文件.例如,它用在/ tmp上.

SGID(设置GID)位具有含义 – 在此目录中创建的文件应属于拥有该目录的组(尽管稍后可通过显式调用chown(2)来更改该分配).

SUID位怎么样?

解决方法:

作为Node的回答的后续内容,我将在FreeBSD man页面中发布以下mount(8):

             suiddir
                 A directory on the mounted file system will respond to
                 the SUID bit being set, by setting the owner of any new
                 files to be the same as the owner of the directory.  New
                 directories will inherit the bit from their parents.
                 Execute bits are removed from the file, and it will not
                 be given to root.

                 This feature is designed for use on fileservers serving
                 PC users via ftp, SAMBA, or netatalk.  It provides secu-
                 rity holes for shell users and as such should not be used
                 on shell machines, especially on home directories.  This
                 option requires the SUIDDIR option in the kernel to work.
                 Only UFS file systems support this option.  See chmod(2)
                 for more information.

和chmod(2)手册页部分引用了suid位:

           4000    (the setuid bit).  Executable files with this bit set will
               run with effective uid set to the uid of the file owner.
               Directories with this bit set will force all files and sub-
               directories created in them to be owned by the directory
               owner and not by the uid of the creating process, if the
               underlying file system supports this feature: see chmod(2)
               and the suiddir option to mount(8).

请注意,这是一个安全风险,并且知道在启用它时你正在做什么,在FreeBSD中,但我相信Linux也需要启用特殊的mount标志,并且会改变该目录中文件的行为方式.

标签:unix,linux,macos,freebsd,setuid
来源: https://codeday.me/bug/20190717/1485649.html