[interchange-cvs] interchange - heins modified 3 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Wed Sep 10 13:50:00 EDT 2003
User: heins
Date: 2003-09-10 16:50:52 GMT
Modified: lib/Vend Config.pm Server.pm Page.pm
Log:
* Add RedirectCache directive which allows redirected page requests to
be set to mv_tmp_session then written to the target from which it was
redirected. This allows a complete web site to be mirrored to static
HTML as it is requested, accompanied with the proper setting of
AcceptRedirect in Interchange and ErrorDocument in the Apache server.
To use:
* Set ErrorDocument 404 to the Interchange URL in Apache.
* Set "AcceptRedirect Yes" in interchange.cfg.
* Set "RedirectCache /var/www/html" in interchange.cfg (use
your document root in place of /var/www/html).
When a page http://yourdomain.tld/subdir/page.html is not found,
Interchange gets a redirect which causes it to set mv_tmp_session=1.
If Interchange doesn't find the page, then it returns "missing" and
no writing is done. If IC does find the page, it is written to
/var/www/html/subdir/page.html and the page will be found on next
access.
Exclude on HTTP server side can be done with permissions -- don't set
it writable by IC daemon if you don't want it written.
TODO: Improve permissions mask setting options, allow excludes from IC
side, add NoClobber option.
* Fix problem where defining blank GlobalSub would kill *all* globalsubs.
Revision Changes Path
2.125 +28 -12 interchange/lib/Vend/Config.pm
rev 2.125, prev_rev 2.124
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.124
retrieving revision 2.125
diff -u -r2.124 -r2.125
--- Config.pm 27 Jul 2003 16:06:53 -0000 2.124
+++ Config.pm 10 Sep 2003 16:50:51 -0000 2.125
@@ -1,6 +1,6 @@
# Vend::Config - Configure Interchange
#
-# $Id: Config.pm,v 2.124 2003/07/27 16:06:53 racke Exp $
+# $Id: Config.pm,v 2.125 2003/09/10 16:50:51 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -48,7 +48,7 @@
use Vend::File;
use Vend::Data;
-$VERSION = substr(q$Revision: 2.124 $, 10);
+$VERSION = substr(q$Revision: 2.125 $, 10);
my %CDname;
my %CPname;
@@ -327,6 +327,7 @@
['DomainTail', 'yesno', 'Yes'],
['TrustProxy', 'list_wildcard_full', ''],
['AcrossLocks', 'yesno', 'No'],
+ ['DNSBL', 'array', ''],
['RobotUA', 'list_wildcard', ''],
['RobotIP', 'list_wildcard_full', ''],
['RobotHost', 'list_wildcard_full', ''],
@@ -523,11 +524,28 @@
['UserDB', 'locale', ''],
['UserDatabase', undef, ''], #undocumented
['RobotLimit', 'integer', 0],
+ my $rfh = $s->{rfh};
+ if($Vend::write_redirect and ! $rfh) {
+ $rfh = gensym();
+ my $fn = $Vend::Cfg->{RedirectCache} . $CGI::path_info;
+ my $save = umask(022);
+ open $rfh, "> $fn"
+ or do {
+ ::logError("Unable to write redirected page %s: %s", $fn, $!);
+ undef $Vend::write_redirect;
+ undef $rfh;
+ };
+ $s->{rfh} = $rfh;
+ umask $save;
+ }
+
['OrderLineLimit', 'integer', 0],
['StaticPage', 'warn', ''],
+ print $rfh $$body if $rfh;
['StaticPath', 'warn', ''],
['StaticPattern', 'warn', ''],
['StaticSuffix', 'warn', ''],
+ ['RedirectCache', undef, ''],
['HTMLsuffix', undef, '.html'],
['CustomShipping', undef, ''],
['DefaultShipping', undef, 'default'],
@@ -601,6 +619,7 @@
return undef;
}
+ print $rfh $$body if $rfh;
sub get_catalog_default {
my ($directive) = @_;
my $directives = catalog_directives();
@@ -857,6 +876,7 @@
#print "found $_\n";
undef $ifdef;
undef $begin_ifdef;
+ close $http->{rfh} if $http->{rfh};
next;
}
if(/^\s*${leadinghash}if(n?)def\s+(.*)/i) {
@@ -3958,16 +3978,13 @@
return if $Vend::ExternalProgram;
-#::logDebug("parsing subroutine $var, " . substr($value, 0, 20) ) unless $C;
- unless (defined $value and $value) {
- $c = {};
- return $c;
- }
-#::logDebug("into parse for $var") unless $C;
-
no strict 'refs';
$c = defined $C ? $C->{$var} : ${"Global::$var"};
+ unless (defined $value and $value) {
+ return $c || {};
+ }
+
$value =~ s/^(\w+\s+)?\s*sub\s+(\w+\s*)?{/sub {/;
if($1 and $2) {
@@ -3992,7 +4009,7 @@
}
$name =~ s/\s+//g;
-#::logDebug("into parse for $var, found sub named $name") unless $C;
+
# Untainting
$value =~ /([\000-\377]*)/;
$value = $1;
@@ -4013,9 +4030,8 @@
$c->{$name} = $C->{ActionMap}{_mvsafe}->reval($value);
}
-#::logDebug("Parsing subroutine/variable (C=$C) $var=$name");
config_error("Bad $var '$name': $@") if $@;
-#::logDebug("Parsed subroutine/variable $var=$name code=$c->{$name}") unless $C;
+
return $c;
}
2.40 +25 -2 interchange/lib/Vend/Server.pm
rev 2.40, prev_rev 2.39
Index: Server.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Server.pm,v
retrieving revision 2.39
retrieving revision 2.40
diff -u -r2.39 -r2.40
--- Server.pm 31 Jul 2003 19:33:40 -0000 2.39
+++ Server.pm 10 Sep 2003 16:50:51 -0000 2.40
@@ -1,6 +1,6 @@
# Vend::Server - Listen for Interchange CGI requests as a background server
#
-# $Id: Server.pm,v 2.39 2003/07/31 19:33:40 racke Exp $
+# $Id: Server.pm,v 2.40 2003/09/10 16:50:51 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -26,7 +26,7 @@
package Vend::Server;
use vars qw($VERSION);
-$VERSION = substr(q$Revision: 2.39 $, 10);
+$VERSION = substr(q$Revision: 2.40 $, 10);
use POSIX qw(setsid strftime);
use Vend::Util;
@@ -205,6 +205,29 @@
respond('', \$msg);
die($msg);
};
+
+ if($Global::DNSBL) {
+ my @quads = split /\./, $CGI::remote_addr;
+ my $intro = join ".", reverse(@quads), '';
+ my $blocked;
+ for(@{$Global::DNSBL}) {
+ my $addr = gethostbyname($intro . $_)
+ or next;
+ $blocked = 1;
+ }
+ if($blocked) {
+ my $msg = ::get_locale_message( 403, "Listed on avoid list.",);
+ my $content_type = $msg =~ /<html/i ? 'text/html' : 'text/plain';
+ my $len = length($msg);
+ $Vend::StatusLine = <<EOF;
+Status: 403 Forbidden
+Content-Type: $content_type
+Content-Length: $len
+EOF
+ respond('', \$msg);
+ die($msg);
+ }
+ }
($::IV, $::VN, $::SV) = $g->{VarName}
? ($g->{IV}, $g->{VN}, $g->{IgnoreMultiple})
2.15 +4 -2 interchange/lib/Vend/Page.pm
rev 2.15, prev_rev 2.14
Index: Page.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Page.pm,v
retrieving revision 2.14
retrieving revision 2.15
diff -u -r2.14 -r2.15
--- Page.pm 31 Jul 2003 13:35:35 -0000 2.14
+++ Page.pm 10 Sep 2003 16:50:51 -0000 2.15
@@ -1,6 +1,6 @@
# Vend::Page - Handle Interchange page routing
#
-# $Id: Page.pm,v 2.14 2003/07/31 13:35:35 mheins Exp $
+# $Id: Page.pm,v 2.15 2003/09/10 16:50:51 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -46,13 +46,15 @@
use vars qw/$VERSION/;
-$VERSION = substr(q$Revision: 2.14 $, 10);
+$VERSION = substr(q$Revision: 2.15 $, 10);
my $wantref = 1;
sub display_special_page {
my($name, $subject) = @_;
my($page);
+
+ undef $Vend::write_redirect;
$name =~ m/[\[<]+/g
and do {
More information about the interchange-cvs
mailing list