0

In some material to describe SGID ,when any user executes a file with SGID bit set on it, it will always be executed with the group ownership of that file, irrespective of who is running it.

sudo groups arch1
arch1 : arch

User ach1 belong to the group arch.

arch@MiWiFi-R3-srv:~$ cat  /tmp/myarch.sh
whoami
arch@MiWiFi-R3-srv:~$ chmod 750   /tmp/myarch.sh
arch@MiWiFi-R3-srv:~$ ls -al   /tmp/myarch.sh
-rwxr-x--- 1 arch arch 8 Aug 23 17:22 /tmp/myarch.sh

Execute it in arch account,the output is arch.
Execute it in arch1 account,the output is arch1.

arch@MiWiFi-R3-srv:~$ chmod 2750   /tmp/myarch.sh
arch@MiWiFi-R3-srv:~$ ls -al   /tmp/myarch.sh
-rwxr-s--- 1 arch arch 8 Aug 23 17:22 /tmp/myarch.sh

Execute it in arch account,the output is arch.
Execute it in arch1 account,the output is arch1,output is not arch.

How to understand "it will always be executed with the group ownership of that file, irrespective of who is running it", it is no meaning to set mode 2750, the mode status 0750 take same effect!

showkey
  • 323

0 Answers0