フォルダにsuid権限があるとはどういう意味ですか? [コピー]

フォルダにsuid権限があるとはどういう意味ですか? [コピー]

ファイルに対する suid 権限を持つことが何を意味するのかを知っています。これは、他のユーザーがファイルに対する実行権限を持っている場合、そのファイルの所有者として実行されることを意味します。しかし、フォルダにsuid権限があるとはどういう意味ですか?いくつかのテストをしてみましたが、フォルダには特別なものがないようです。誰でもこれを説明するのに役立ちますか?ありがとうございます。

私はOracle Linux 7.6を使用しています。

root:[~]# cat /etc/*release*
Oracle Linux Server release 7.6
NAME="Oracle Linux Server"
VERSION="7.6"
ID="ol"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.6"
PRETTY_NAME="Oracle Linux Server 7.6"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:7:6:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7"
ORACLE_BUGZILLA_PRODUCT_VERSION=7.6
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=7.6
Red Hat Enterprise Linux Server release 7.6 (Maipo)
Oracle Linux Server release 7.6
cpe:/o:oracle:linux:7:6:server
root:[~]#

以下は、新しくインストールされたサーバーでのテストです。

root:[~]# pwd
/root
root:[~]# ls -lad /root
dr-xr-x---. 9 root root 4096 Aug 16 22:07 /root
root:[~]# mkdir test
root:[~]# ls -lad test
drwxr-xr-x. 2 root root 4096 Aug 16 22:07 test
root:[~]#
root:[~]# useradd a
root:[~]# passwd a
Changing password for user a.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
root:[~]# chmod u+s test
root:[~]#
root:[~]# su - a
[a@localhost ~]$ cd /root/test
-bash: cd: /root/test: Permission denied
[a@localhost ~]$ cd /root
-bash: cd: /root: Permission denied
[a@localhost ~]$ logout
root:[~]#
root:[~]# ls -lad /root
dr-xr-x---. 10 root root 4096 Aug 16 22:07 /root
root:[~]# chmod o+x /root
root:[~]#
root:[~]# su - a
Last login: Fri Aug 16 22:08:54 CST 2019 on pts/0
[a@localhost ~]$ cd /root/test
[a@localhost test]$
[a@localhost test]$ pwd
/root/test
[a@localhost test]$ ls -la .
total 8
drwsr-xr-x.  2 root root 4096 Aug 16 22:07 .
dr-xr-x--x. 10 root root 4096 Aug 16 22:07 ..
[a@localhost test]$ touch file1
touch: cannot touch ‘file1’: Permission denied
[a@localhost test]$ logout
root:[~]#
root:[~]# chmod o+w test/
root:[~]#
root:[~]# su - a
Last login: Fri Aug 16 22:09:31 CST 2019 on pts/0
[a@localhost ~]$
[a@localhost ~]$ cd /root/test
[a@localhost test]$ touch file1
[a@localhost test]$ ls -la
total 8
drwsr-xrwx.  2 root root 4096 Aug 16 22:11 .
dr-xr-x--x. 10 root root 4096 Aug 16 22:07 ..
-rw-rw-r--.  1 a    a       0 Aug 16 22:11 file1
[a@localhost test]$ mkdir folder1
[a@localhost test]$ ls -la
total 12
drwsr-xrwx.  3 root root 4096 Aug 16 22:11 .
dr-xr-x--x. 10 root root 4096 Aug 16 22:07 ..
-rw-rw-r--.  1 a    a       0 Aug 16 22:11 file1
drwxrwxr-x.  2 a    a    4096 Aug 16 22:11 folder1
[a@localhost test]$

ご覧のとおり、ユーザーがa作成したファイルとフォルダは/root/test所有者とグループを継承しないようです。所有者とグループではaありませんroot。私のテストに問題がありますか?私はLinuxに初めて触れました。

ベストアンサー1

GNUマニュアルによると、これは、このディレクトリ(サブフォルダを含む)に作成されたファイルがそのグループとユーザーを継承することを意味します。

一部のシステムでは、ディレクトリのset-user-IDビットは、新しいサブディレクトリのset-user-IDビットと同様に、新しいサブファイルの所有権に同様の影響を与えます。これらのメカニズムにより、新しいファイルを共有するためにchmodまたはchownを使用する必要性が減り、ユーザーがファイルを共有しやすくなります。

おすすめ記事