Detecting taint mode

David Cantrell david at
Tue Feb 27 14:41:57 GMT 2007

On Sun, Feb 25, 2007 at 09:58:19PM +0100, dakkar wrote:
> David Cantrell wrote:
> > Anyone got a nifty way of detecting whether you're running in taint-mode
> > which doesn't rely on ${^TAINT}?  Cos that magic variable ain't
> > available in 5.6.2.
> Might be ugly, but:
>  my $x=eval {system "/bin/true"};
>  print "Taint!\n" if $@;
> seems to work.

Not on Windows or VMS it won't.

>                In other words, an easy way is to trigger the taint check
> inside an 'eval', and see if it died.

Yeah, I ended up doing this:

use Cwd;
if(eval { chdir(getcwd()) }) {
    # stuff that can't run in Taint mode

Conveniently, I don't particularly want to run that stuff if you started
as root and then dropped privs, which is the only other case I can think
of where chdir(getcwd()) would fail.

David Cantrell | top google result for "internet beard fetish club"

What is the difference between hearing aliens through the
fillings in your teeth and hearing Jesus in your heart?

More information about the mailing list