Difference between inbuilt suid programs and user defined root suid programs under bash shell?

Hey guys,

Suppose i run passwd via bash shell. It is a suid program, which temporarily runs as root(owner) and modifies the user entries.

However, when i write a C file and give 4755 permission and root ownership to the 'a.out' file , it doesn't run as root in bash shell. I verified this by comparing uid and euid within the program which turned out to be the same. However, in zsh shell, it runs with root privileges

My question is : Why does an inbuilt program like suid is able to run with root privileges in bash shell while a user defined suid root program is not ?

Hi,
What does "a.out" doing ?
It try to launch bash in setuid root ?
You shall know that bash not work by default in setuid root, you must use "-p" option.

In man:

Regards.

I think in a C-program you need to

seteuid (0)