#!/usr/bin/perl -T use CGI::Carp qw(fatalsToBrowser); use FindBin qw($Bin); if ($Bin =~ /^(\/home\/someuser\/somewebsite\/\w{2,4}\/cgi-bin)/) { $Bin = $1; } use lib "$Bin"; use Site::HTML; use strict; use warnings;The \w{2,4} allows for the different subdomains used for development, testing, etc.
A few notes:
It's not a security thing per se, it just makes the code more readable.if ($Bin =~ m!^(/home/someuser/somewebsite/[a-z]{2,4}/cgi-bin/)!)
if ($Bin =~ m!^(/home/someuser/somewebsite/[a-z]{2,4}/cgi-bin/)! ) { $Bin = $1; } else { die "Go away, stupid script kiddie!\n"; } # or maybe: $Bin =~ m!^(/home/someuser/somewebsite/[a-z]{2,4}/cgi-bin/)! or die "W +here am I?\n"; $Bin = $1;
Alexander
In reply to Re^5: Using relative paths with taint mode
by afoken
in thread Using relative paths with taint mode
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |