chiark / gitweb /
mason diversion etc.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 26 Jan 2013 00:11:00 +0000 (00:11 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 26 Jan 2013 00:11:00 +0000 (00:11 +0000)
AwayMsg.pm
mason/autohandler
run-mason.cgi

index acfb0ce..72c5946 100644 (file)
@@ -31,14 +31,7 @@ sub hquote ($) {
 }
 
 sub db_connect () {
-    my $dbf;
-    foreach my $d (@INC) {
-       $dbf = "$d/data/away.db";
-       if (stat $dbf) {
-           chdir($d) or die $!;
-           last;
-       }
-    }
+    my $dbf = "$ENV{'NJAWAYMSG'}/data/away.db";
     $dbh = DBI->connect("dbi:SQLite:$dbf",'','',
                         { AutoCommit=>0,
                           RaiseError=>1, ShowErrorStatement=>1
index 22b062a..469f482 100644 (file)
@@ -1,8 +1,24 @@
 <%once>
 use CGI::Auth::Flexible;
+
+sub do_redirect_mason ($$$$) {
+    my ($c, $ar, $new_url, $cookie) = @_;
+    $m->auto_send_headers(0);
+    CGI::Auth::Flexible::do_redirect_cgi($c,$ar,$new_url,$cookie);
+}
+
 my $verifier = CGI::Auth::Flexible->new_verifier(
-   dir => "/home/ian/things/Nj-awaymsg/nj-awaymsg.git/data",
-   CGI::Auth::Flexible->mason_params();
-   );
-my $authreq = $verifier->new_mason_request(\%ARGS);
+    dir => "$ENV{'NJAWAYMSG'}/data",
+#    do_redirect => \&do_redirect_mason,
+    handle_divert => sub { $m->auto_send_headers(0); return 0; },
+#    print => sub { my ($c,$ar,@t) = @_; $m->print(@t); },
+    encrypted_only => 0,
+    );
+</%once>
+<%perl>
+my $cgi = $m->cgi_object();
+my $ar = $verifier->new_request($cgi);
+if ($ar->check_ok()) {
+   $m->call_next();   
+}
 </%perl>
index 3f42cc5..91916cc 100755 (executable)
@@ -15,8 +15,6 @@ unshift @INC, $perllib;
 my $pathsofar = $comp_root;
 die "$pathsofar $!" unless stat $pathsofar;
 
-system 'printenv |sort >&2';
-
 my $path_info = $ENV{'PATH_INFO'};
 $path_info='' if !defined $path_info;