How do I set the taint mode in a perl script with a '#!/usr/bin/env perl'- shebang?

前端 未结 2 927
挽巷
挽巷 2021-02-05 21:55

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

#!/usr/bin/env perl

shebang?

2条回答
  •  北荒
    北荒 (楼主)
    2021-02-05 22:30

    Since taint mode can only be enabled via the -T flag, and env won't accept any flags in a shebang line, your best option is to run the program via perl -T script.pl rather than executing the script directly.

    If you absolutely need to enforce taint mode in the shebang, you could make a taintperl script somewhere in your PATH (e.g. /usr/local/bin) with the following contents:

    #!/bin/sh
    /usr/bin/env perl -T
    

    Then in your Perl script, have

    #!/usr/bin/env taintperl
    

提交回复
热议问题