Today, I was trying to run psql from a program when I got this error:
Insecure $ENV{PATH} while running setuid at ...
At first, I thought that psql would be testing something about the user, but in fact, psql is a perl script that runs in secure mode. In other words, this applies to any tool written in perl.
The perl interpreter makes sure that the current user identifier is the same as the effective user identifier. When there is a mismatch, the interpreter breaks with that error.