chiark / gitweb /
automatic agpl compliance: wip, before rationalise locations and dirs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 18 Feb 2013 15:27:25 +0000 (15:27 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 18 Feb 2013 15:27:25 +0000 (15:27 +0000)
cgi-auth-flexible.pm

index 06625631bcf4ece5ab4ee41fd97d71b80474fed2..2be63b4a242926ff1ef9c9a88dcec34dc6c4acf0 100644 (file)
@@ -47,6 +47,7 @@ use Digest;
 use Digest::HMAC;
 use Digest::SHA;
 use Data::Dumper;
+use File::Copy;
 
 #---------- public utilities ----------
 
@@ -197,6 +198,29 @@ sub gen_plain_footer_html ($$) {
            '</address>');
 }
 
+#---------- licence and source code ----------
+
+sub dump_licence ($$$) {
+    
+    my ($c,$r, $fh) = @_;
+    foreach my $incdir ($r->_ch('getsource_includedirs')) {
+       
+    }
+}
+
+sub source_dump_get_path ($$$) {
+    my ($c,$r, $thing) = @_;
+    die if $thing =~ m/\W/;
+    my $pat = $r->{S}('source_dump_path_pat');
+    my $leaf = sprintf $pat, $thing;
+    return $r->_absify_path($leaf);
+}
+
+sub source_dump_thing ($$$) {
+    my ($c,$r, $thing, $outfn) = @_;
+    my $path = $r->_ch('source_dump_get_path', $thing);
+    copy($path, $utfn
+
 #---------- verifier object methods ----------
 
 sub new_verifier {
@@ -207,6 +231,8 @@ sub new_verifier {
            assocdb_dbh => undef, # must have AutoCommit=0, RaiseError=1
            assocdb_path => 'caf-assocs.db',
            keys_path => 'caf-keys',
+           source_dump_path_pat => 'caf-%s.dump',
+           source_dump_get_path => \&source_dump_get_path,
            assocdb_dsn => undef,
            assocdb_user => '',
            assocdb_password => '',
@@ -253,6 +279,8 @@ sub new_verifier {
            gen_login_form => \&gen_plain_login_form,
            gen_login_link => \&gen_plain_login_link,
            gen_postmainpage_form => \&gen_postmainpage_form,
+           source_dump_thing => \&source_dump_thing,
+           source_includedirs => sub { grep { !m#^/etc/# } @INC; },
            gettext => sub { gettext($_[2]); },
            print => sub { print $_[2] or die $!; },
             debug => sub { }, # like print; msgs contain trailing \n
@@ -395,8 +423,13 @@ sub _debug ($@) {
 sub _get_path ($$) {
     my ($v,$keybase) = @_;
     my $leaf = $v->{S}{"${keybase}_path"};
-    my $dir = $v->{S}{dir};
+    return $r->_absify_path($leaf);
+}
+
+sub _absify_path ($$) {
+    my ($v,$leaf) = @_;
     return $leaf if $leaf =~ m,^/,;
+    my $dir = $v->{S}{dir};
     die "relying on cwd by default ?!  set dir" unless defined $dir;
     return "$dir/$leaf";
 }
@@ -820,6 +853,11 @@ sub check_ok ($) {
     my $params = $divert->{Params};
     my $cookie = $r->construct_cookie($cookiesecret);
 
+    if ($kind =~ m/^SPECIAL-(LICENCE|SOURCE)$/) {
+       $r->_ch('dump_'.lc $1, \*STDOUT);
+       return 0;
+    }
+
     if ($kind =~ m/^REDIRECT-/) {
        # for redirects, we honour stored NextParams and SetCookie,
        # as we would for non-divert