3

タイトルが示すように、Unix ライクなシステムはディレクトリの SUID ビットに意味を与えますか? もしそうなら、それはどういう意味ですか?

SVTX (保存されたテキスト、またはスティッキー) ビットには意味があります。ファイルに書き込むことができない限り、このディレクトリからファイルを削除してはなりません。たとえば、/tmp で使用されます。

SGID (set GID) ビットには意味があります。このディレクトリに作成されたファイルは、そのディレクトリを所有するグループに属します (ただし、後で chown(2) を明示的に呼び出すことで割り当てを変更できます)。

SUIDビットはどうですか?

4

4 に答える 4

6

Node の回答のフォローアップとして、mount(8) の FreeBSD man ページから以下を投稿します。

             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.

そして、suid ビットを参照する chmod(2) man ページのセクション:

           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 も特別なマウント フラグを有効にする必要があり、そのディレクトリ内のファイルの動作が変わると思います。

于 2009-03-09T20:36:03.533 に答える
1

ディレクトリに設定すると、このディレクトリ内に作成されたすべてのファイルとディレクトリは、ファイルの作成者に関係なく、SUID ディレクトリ自体と同じ所有者になります。これはあまり使用されない機能ですが、場合によっては便利です。(ソース

更新: Linux 2.6.25.5-1.1-default #1 SMP x86_64 GNU/Linux openSUSE 11.0 (X86-64) でこれを試しました。

mkdir tmp
chmod 4777 tmp
su othergroup
touch testfile

効果はありませんでした。

于 2009-03-09T20:26:32.853 に答える
0

SUID ビットは、ファイルの実行時 (実行可能の場合) に、そのファイルを実行したユーザーではなく、そのファイルの所有者の ID でプロセスが実行されることを示します。

特権昇格を許可するためにユーティリティ プログラムが「suid root」になっている場合がいくつかあります。

編集:元の質問(ファイルではなくディレクトリを参照)を読み間違えました-教育目的で回答を変更せずに残します;-)

于 2009-03-09T20:25:45.040 に答える