in reply to Re^3: Setuid script not working
in thread Setuid script not working

Linux, like many other Unix variants, ignores the setuid-bit on scripts. So your script runs as unprivileged user. Unprivileged users aren't allowed to change the UID or GID, hence the "Operation not permitted" error.

Perl once had a separate interpreter, suidperl, that was installed setuid root, and that should respect the setuid-bit on scripts. It never worked as secure as it should, so it was deprecated and finally removed.

Consider using sudo, as recommended in perl587delta. Read perlsec for a different approach. A third approach may be splitting the job into a privileged daemon and an unprivileged front-end, communicating over unix domain sockets or named pipes.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)