I understand that we probably cannot do ptrace on suid binaries. However, I'm wondering why we cannot do ptrace after the binary drops its previlege to uid instead of euid.
For example, in the binary the suid binary drops privilege after some steps.
seteuid (euid); ret_chdir = chdir (path); seteuid (ruid); system("whoami"); printf("Enter any char"); scanf("%c", &junk);
In my case when "whoami" is printed, it is the user name of the process but not the owner of the process. When the program is waiting for a junk input, I was trying to attach to the running process with the uid as the user name, but it failed even though the binary had dropped the privilege. Is it possible that ptrace attach uses the saved-uid state to decide that I'm not the owner?