summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-14 00:48:22 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-14 00:48:22 +0000
commit4f08be1ae828ab7298a05c25a080b93f8b03a48c (patch)
treee4b2dac87d4295c4dc37661e45820246c52d2631
parentf9d43fcd9f82d2316f91548acd99c794f7de4071 (diff)
Improved detail in configure, and two new functions exec() and eval() are more accountable
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6312 e03df62e-2008-0410-955e-edbf42e46eb7
-rwxr-xr-xconfigure6
-rw-r--r--make/utilities.pm107
2 files changed, 67 insertions, 46 deletions
diff --git a/configure b/configure
index b76988fb3..0ed5100bd 100755
--- a/configure
+++ b/configure
@@ -1376,7 +1376,7 @@ sub getcompilerflags {
while (<FLAGS>) {
if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) {
close(FLAGS);
- return translate_functions($1);
+ return translate_functions($1,$file);
}
}
close(FLAGS);
@@ -1389,7 +1389,7 @@ sub getlinkerflags {
while (<FLAGS>) {
if ($_ =~ /^\/\* \$LinkerFlags: (.+) \*\/$/) {
close(FLAGS);
- return translate_functions($1);
+ return translate_functions($1,$file);
}
}
close(FLAGS);
@@ -1402,7 +1402,7 @@ sub getdependencies {
while (<FLAGS>) {
if ($_ =~ /^\/\* \$ModDep: (.+) \*\/$/) {
close(FLAGS);
- return translate_functions($1);
+ return translate_functions($1,$file);
}
}
close(FLAGS);
diff --git a/make/utilities.pm b/make/utilities.pm
index 0109bf929..5e0193361 100644
--- a/make/utilities.pm
+++ b/make/utilities.pm
@@ -121,54 +121,75 @@ sub pkgconfig_get_lib_dirs($$$)
# Translate a $CompileFlags etc line and parse out function calls
# to functions within these modules at configure time.
-sub translate_functions($)
+sub translate_functions($$)
{
- my ($line) = @_;
- while ($line =~ /exec\("(.+?)"\)/)
+ eval
{
- my $replace = `$1`;
- chomp($replace);
- $line =~ s/exec\("(.+?)"\)/$replace/;
- }
- while ($line =~ /eval\("(.+?)"\)/)
- {
- my $tmpfile;
- do
+ my ($line,$module) = @_;
+
+ # This is only a cursory check, just designed to catch casual accidental use of backticks.
+ # There are pleanty of ways around it, but its not supposed to be for security, just checking
+ # that people are using the new configuration api as theyre supposed to and not just using
+ # backticks instead of eval(), being as eval has accountability. People wanting to get around
+ # the accountability will do so anyway.
+ if (($line =~ /`/) && ($line !~ /eval\(.+?`.+?\)/))
{
- $tmpfile = tmpnam();
- } until sysopen(TF, $tmpfile, O_RDWR|O_CREAT|O_EXCL, 0700);
- print TF $1;
- close TF;
- my $replace = `perl $tmpfile`;
- chomp($replace);
- $line =~ s/eval\("(.+?)"\)/$replace/;
- }
- while ($line =~ /pkgconflibs\("(.+?)","(.+?)","(.+?)"\)/)
- {
- my $replace = pkgconfig_get_lib_dirs($1, $2, $3);
- $line =~ s/pkgconflibs\("(.+?)","(.+?)","(.+?)"\)/$replace/;
- }
- while ($line =~ /pkgconflibs\("(.+?)","(.+?)",""\)/)
- {
- my $replace = pkgconfig_get_lib_dirs($1, $2, "");
- $line =~ s/pkgconflibs\("(.+?)","(.+?)",""\)/$replace/;
- }
- while ($line =~ /pkgconfincludes\("(.+?)","(.+?)",""\)/)
- {
- my $replace = pkgconfig_get_include_dirs($1, $2, "");
- $line =~ s/pkgconfincludes\("(.+?)","(.+?)",""\)/$replace/;
- }
- while ($line =~ /pkgconfincludes\("(.+?)","(.+?)","(.+?)"\)/)
- {
- my $replace = pkgconfig_get_include_dirs($1, $2, $3);
- $line =~ s/pkgconfincludes\("(.+?)","(.+?)","(.+?)"\)/$replace/;
- }
- while ($line =~ /rpath\("(.+?)"\)/)
+ die "Developers should no longer use backticks in configuration macros. Please use exec() and eval() macros instead. Offending line: $line (In module: $module)";
+ }
+ while ($line =~ /exec\("(.+?)"\)/)
+ {
+ print "Executing program ... \033[1;32m$1\033[0m\n";
+ my $replace = `$1`;
+ chomp($replace);
+ $line =~ s/exec\("(.+?)"\)/$replace/;
+ }
+ while ($line =~ /eval\("(.+?)"\)/)
+ {
+ print "Evaluating perl code ... ";
+ my $tmpfile;
+ do
+ {
+ $tmpfile = tmpnam();
+ } until sysopen(TF, $tmpfile, O_RDWR|O_CREAT|O_EXCL, 0700);
+ print "(Created and executed \033[1;32m$tmpfile)\033[0m\n";
+ print TF $1;
+ close TF;
+ my $replace = `perl $tmpfile`;
+ chomp($replace);
+ $line =~ s/eval\("(.+?)"\)/$replace/;
+ }
+ while ($line =~ /pkgconflibs\("(.+?)","(.+?)","(.+?)"\)/)
+ {
+ my $replace = pkgconfig_get_lib_dirs($1, $2, $3);
+ $line =~ s/pkgconflibs\("(.+?)","(.+?)","(.+?)"\)/$replace/;
+ }
+ while ($line =~ /pkgconflibs\("(.+?)","(.+?)",""\)/)
+ {
+ my $replace = pkgconfig_get_lib_dirs($1, $2, "");
+ $line =~ s/pkgconflibs\("(.+?)","(.+?)",""\)/$replace/;
+ }
+ while ($line =~ /pkgconfincludes\("(.+?)","(.+?)",""\)/)
+ {
+ my $replace = pkgconfig_get_include_dirs($1, $2, "");
+ $line =~ s/pkgconfincludes\("(.+?)","(.+?)",""\)/$replace/;
+ }
+ while ($line =~ /pkgconfincludes\("(.+?)","(.+?)","(.+?)"\)/)
+ {
+ my $replace = pkgconfig_get_include_dirs($1, $2, $3);
+ $line =~ s/pkgconfincludes\("(.+?)","(.+?)","(.+?)"\)/$replace/;
+ }
+ while ($line =~ /rpath\("(.+?)"\)/)
+ {
+ my $replace = make_rpath($1);
+ $line =~ s/rpath\("(.+?)"\)/$replace/;
+ }
+ return $line;
+ };
+ if ($@)
{
- my $replace = make_rpath($1);
- $line =~ s/rpath\("(.+?)"\)/$replace/;
+ print "\n\nConfiguration failed. The following error occured:\n\n$@\n";
+ exit;
}
- return $line;
}
1;