I made this stupid mistake and it take me some time.
Sticky bit for script file not work
for script file
user:coolder
cat check_euid.sh
echo $EUID
➜ Bin bash check_euid.sh
1000
change owner to root:root
➜ Bin sudo chown root:root check_euid.sh
add sticky bit for the script
➜ Bin sudo chmod +s check_euid.sh
$EUID will not change !!!
➜ Bin ls
a.c a.out check_euid.sh
➜ Bin sudo chown root:root check_euid.sh
➜ Bin sudo chmod +s check_euid.sh
➜ Bin whoami
coolder
➜ Bin bash check_euid.sh
1000
➜ Bin
for binary file
user:coolder
➜ Bin cat a.c
#include<unistd.h>
#include<sys/types.h>
int main(void)
{
printf("%d %d", getuid(), geteuid());
}
compile and run
➜ Bin ./a.out
1000 1000%
effect on binary file !!!
➜ Bin sudo chown root:root a.out
➜ Bin sudo chmod +s a.out
➜ Bin ./a.out
1000 0%