Okay, fine... but I will still need my app to execute some binaries as the original user. Maybe PAM isn't the way to do it. Is there not a way I can run app A (as user or root, I don't care, but must be written in perl), and have app A execute various binaries both as the *original* user and some others with root privileges?
Update: Sorry, I guess I misread "some others" as referring to other users instead of other programs. Anyway, you can use sudo to run programs as any user (if you have rights to do so) not just as root.