Unixライクなシステムは、ディレクトリのSUIDビットに意味があると考えていますか?

StackOverflow https://stackoverflow.com/questions/627880

質問

タイトルのとおり、UnixライクなシステムはディレクトリのSUIDビットに意味を与えていますか?

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

SG >

SUIDビットはどうですか?

役に立ちましたか?

解決

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)のマニュアルページセクション:

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

他のヒント

こちらからコピー:

  

ほとんどのシステムでは、ディレクトリのset-group-IDビットが設定されている場合、新しく作成されたサブファイルはディレクトリと同じグループを継承し、新しく作成されたサブディレクトリは親ディレクトリのset-group-IDビットを継承します。いくつかのシステムでは、ディレクトリのset-user-IDビットは、新しいサブファイルの所有権と新しいサブディレクトリのset-user-IDビットに同様の影響を及ぼします。これらのメカニズムにより、新しいファイルを共有するためにchmodまたはchownを使用する必要性が減り、ユーザーはファイルをより簡単に共有できます。

     

これらの便利なメカニズムは、ディレクトリのset-user-IDおよびset-group-IDビットに依存しています。 chmodやmkdirなどのコマンドがディレクトリのこれらのビットを定期的にクリアすると、メカニズムの利便性が低下し、ファイルを共有するのが難しくなります。したがって、ユーザーがシンボリックモードで特に言及するか、数値モードで設定しない限り、chmodなどのコマンドはディレクトリのset-user-IDまたはset-group-IDビットに影響しません。

ディレクトリに設定すると、このディレクトリ内で作成されたすべてのファイルとディレクトリは、ファイルの作成者に関係なく、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

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

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

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

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top