如何在带有'#!/usr/bin/env perl'- shebang的perl脚本中设置污点模式? [英] How do I set the taint mode in a perl script with a '#!/usr/bin/env perl'- shebang?

查看:114
本文介绍了如何在带有'#!/usr/bin/env perl'- shebang的perl脚本中设置污点模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在带有a的perl脚本中设置污点模式

how do I set the taint mode in a perl script with a

#!/usr/bin/env perl

shebang?

推荐答案

您可以在shebang行上传递PERL5OPT环境变量:

You can pass the PERL5OPT environment variable on the shebang line:

#!/usr/bin/env PERL5OPT=-T perl

这对我来说似乎倒退了.

This seems all rather backwards to me.

另一种选择是,如果检测到脚本不在打开状态,则在异味模式下重新执行该脚本:

Another option, is to re-execute the script under taint mode if you detect it's not on:

#!/usr/bin/env perl

warn 'Taint mode is '.(${^TAINT} ? 'on' : 'off'); # For debugging

exec($^X,'-T',$0,@ARGV) unless ${^TAINT};

# do stuff under taint mode here

显然,这是启动性能的主要损失.

Obviously, this is a major startup performance hit.

这篇关于如何在带有'#!/usr/bin/env perl'- shebang的perl脚本中设置污点模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆