I made this stupid mistake and it take me some time.


Sticky bit for script file not work

for script file

user:coolder

  1. cat check_euid.sh
  2. echo $EUID
  1. Bin bash check_euid.sh
  2. 1000

change owner to root:root

  1. Bin sudo chown root:root check_euid.sh

add sticky bit for the script

  1. Bin sudo chmod +s check_euid.sh

$EUID will not change !!!

  1. Bin ls
  2. a.c a.out check_euid.sh
  3. Bin sudo chown root:root check_euid.sh
  4. Bin sudo chmod +s check_euid.sh
  5. Bin whoami
  6. coolder
  7. Bin bash check_euid.sh
  8. 1000
  9. Bin

for binary file

user:coolder

  1. Bin cat a.c
  2. #include<unistd.h>
  3. #include<sys/types.h>
  4. int main(void)
  5. {
  6. printf("%d %d", getuid(), geteuid());
  7. }

compile and run

  1. Bin ./a.out
  2. 1000 1000%

effect on binary file !!!

  1. Bin sudo chown root:root a.out
  2. Bin sudo chmod +s a.out
  3. Bin ./a.out
  4. 1000 0%