From d1c17f44c1420464234a08ac979b3d61081bf3bc Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 1 Sep 2015 00:19:35 +0200 Subject: moved to FastCGI (less deps) diff --git a/README b/README index 7d34026..bf51043 100644 --- a/README +++ b/README @@ -31,8 +31,8 @@ LICENSE Installation ============ -# sudo aptitude install apache2 libapache2-mod-perl2 libconfig-inifiles-perl libdbd-mysql-perl libjson-pp-perl libxml-quote-perl librhrd-perl libjs-jquery rivendell-server -# sudo a2enmod ssl authnz_ldap perl proxy_wstunnel +# sudo aptitude install apache2 libapache2-mod-fcgid libconfig-inifiles-perl libcgi-fast-perl libdbd-mysql-perl libjson-pp-perl libxml-quote-perl librhrd-perl libjs-jquery rivendell-server +# sudo a2enmod ssl authnz_ldap fcgid proxy_wstunnel # sudo /etc/init.d/apache2 restart add the following to /etc/apache2/mods-endabled/ldap.conf: @@ -51,9 +51,7 @@ add the following to the virtualhost config: Alias /rh-bin/ /var/www/rhwebimport/rh-bin/ - SetHandler perl-script - PerlResponseHandler ModPerl::Registry - PerlOptions +ParseHeaders + SetHandler fcgid-script Options +ExecCGI Require all granted diff --git a/rh-bin/authtoken.json b/rh-bin/authtoken.json index 3e698ac..be799d1 100755 --- a/rh-bin/authtoken.json +++ b/rh-bin/authtoken.json @@ -22,31 +22,34 @@ # use strict; +use CGI::Fast; use RHRD::rddb; use JSON; -my $status = 'ERROR'; -my $errorstring = 'unknown'; -my $username = ''; -my $token = ''; -if(defined $ENV{REMOTE_USER}) { - my $dbh; - ($dbh, $status, $errorstring) = RHRD::rddb::opendb(); - if(defined $dbh) { - ($token, $status, $errorstring) = RHRD::rddb::get_token($dbh, $ENV{REMOTE_USER}); - $token = '' unless($token); - $username = $ENV{REMOTE_USER}; - RHRD::rddb::closedb($dbh); +while (my $q = CGI::Fast->new) { + my $status = 'ERROR'; + my $errorstring = 'unknown'; + my $username = ''; + my $token = ''; + if(defined $ENV{REMOTE_USER}) { + my $dbh; + ($dbh, $status, $errorstring) = RHRD::rddb::opendb(); + if(defined $dbh) { + ($token, $status, $errorstring) = RHRD::rddb::get_token($dbh, $ENV{REMOTE_USER}); + $token = '' unless($token); + $username = $ENV{REMOTE_USER}; + RHRD::rddb::closedb($dbh); + } + } else { + $errorstring = 'no username defined - are you logged in?'; } -} else { - $errorstring = 'no username defined - are you logged in?'; -} -my %answer; -$answer{'status'} = $status; -$answer{'errorstring'} = $errorstring; -$answer{'username'} = $username; -$answer{'token'} = $token; + my %answer; + $answer{'status'} = $status; + $answer{'errorstring'} = $errorstring; + $answer{'username'} = $username; + $answer{'token'} = $token; -print "Content-type: application/json; charset=UTF-8\n\n"; -print encode_json \%answer; + print "Content-type: application/json; charset=UTF-8\n\n"; + print encode_json \%answer; +} diff --git a/rh-bin/listdropboxes.cgi b/rh-bin/listdropboxes.cgi index a0104c0..03dc4ee 100755 --- a/rh-bin/listdropboxes.cgi +++ b/rh-bin/listdropboxes.cgi @@ -22,74 +22,75 @@ # use strict; -use CGI; +use CGI::Fast; use POSIX; use XML::Quote; use RHRD::rddb; -my $status = 'ERROR'; -my $errorstring = 'unknown'; -my $responsecode = 500; -my @dropboxes = (); +while (my $q = CGI::Fast->new) { + my $status = 'ERROR'; + my $errorstring = 'unknown'; + my $responsecode = 500; + my @dropboxes = (); -my $q = CGI->new; -my $username = $q->param('LOGIN_NAME'); -my $token = $q->param('PASSWORD'); + my $username = $q->param('LOGIN_NAME'); + my $token = $q->param('PASSWORD'); -my $dbh; -($dbh, $status, $errorstring) = RHRD::rddb::opendb(); -if(defined $dbh) { - my $result; - ($result, $status, $errorstring) = RHRD::rddb::check_token($dbh, $username, $token); - if($result == 1) { - $responsecode = 200; - @dropboxes = RHRD::rddb::get_dropboxes($dbh, $username); - unless (defined $dropboxes[0]) { + my $dbh; + ($dbh, $status, $errorstring) = RHRD::rddb::opendb(); + if(defined $dbh) { + my $result; + ($result, $status, $errorstring) = RHRD::rddb::check_token($dbh, $username, $token); + if($result == 1) { + $responsecode = 200; + @dropboxes = RHRD::rddb::get_dropboxes($dbh, $username); + unless (defined $dropboxes[0]) { + $responsecode = 500; + $status = $dropboxes[1]; + $errorstring = $dropboxes[2]; + } + } elsif($result == 0) { + $responsecode = 403; + } else { $responsecode = 500; - $status = $dropboxes[1]; - $errorstring = $dropboxes[2]; } - } elsif($result == 0) { - $responsecode = 403; - } else { - $responsecode = 500; + RHRD::rddb::closedb($dbh); } - RHRD::rddb::closedb($dbh); -} -print "Content-type: application/xml; charset=UTF-8\n\n"; + print "Content-type: application/xml; charset=UTF-8\n\n"; -if($responsecode != 200) { - print "\n"; - print " " . xml_quote($responsecode) . "\n"; - print " " . xml_quote($errorstring) . "\n"; - print "\n"; -} else { - print "\n"; - for my $href (@dropboxes) { - print " \n"; - print " " . xml_quote($href->{'GROUP'}) . "\n"; - print " " . xml_quote($href->{'GROUPDESC'}) . "\n"; - print " " . xml_quote($href->{'GROUPLOWCART'}) . "\n"; - print " " . xml_quote($href->{'GROUPHIGHCART'}) . "\n"; - print " " . floor($href->{'NORMLEVEL'}/100) . "\n"; - print " " . floor($href->{'TRIMLEVEL'}/100) . "\n"; - print " " . xml_quote($href->{'PARAM'}) . "\n"; - print " " . xml_quote($href->{'TYPE'}) . "\n"; - if($href->{'TYPE'} eq "show") { - print " " . xml_quote($href->{'SHOWID'}) . "\n"; - print " " . xml_quote($href->{'SHOWTITLE'}) . "\n"; - print " " . xml_quote($href->{'SHOWLOG'}) . "\n"; - print " " . xml_quote($href->{'SHOWRHYTHM'}) . "\n"; - print " " . xml_quote($href->{'SHOWDOW'}) . "\n"; - print " " . xml_quote($href->{'SHOWSTARTTIME'}) . "\n"; - print " " . xml_quote($href->{'SHOWLEN'}) . "\n"; - } elsif($href->{'TYPE'} eq "jingle") { - print " " . xml_quote($href->{'JINGLETITLE'}) . "\n"; - } elsif($href->{'TYPE'} eq "musicpool") { - print " " . xml_quote($href->{'MUSICPOOLTITLE'}) . "\n"; + if($responsecode != 200) { + print "\n"; + print " " . xml_quote($responsecode) . "\n"; + print " " . xml_quote($errorstring) . "\n"; + print "\n"; + } else { + print "\n"; + for my $href (@dropboxes) { + print " \n"; + print " " . xml_quote($href->{'GROUP'}) . "\n"; + print " " . xml_quote($href->{'GROUPDESC'}) . "\n"; + print " " . xml_quote($href->{'GROUPLOWCART'}) . "\n"; + print " " . xml_quote($href->{'GROUPHIGHCART'}) . "\n"; + print " " . floor($href->{'NORMLEVEL'}/100) . "\n"; + print " " . floor($href->{'TRIMLEVEL'}/100) . "\n"; + print " " . xml_quote($href->{'PARAM'}) . "\n"; + print " " . xml_quote($href->{'TYPE'}) . "\n"; + if($href->{'TYPE'} eq "show") { + print " " . xml_quote($href->{'SHOWID'}) . "\n"; + print " " . xml_quote($href->{'SHOWTITLE'}) . "\n"; + print " " . xml_quote($href->{'SHOWLOG'}) . "\n"; + print " " . xml_quote($href->{'SHOWRHYTHM'}) . "\n"; + print " " . xml_quote($href->{'SHOWDOW'}) . "\n"; + print " " . xml_quote($href->{'SHOWSTARTTIME'}) . "\n"; + print " " . xml_quote($href->{'SHOWLEN'}) . "\n"; + } elsif($href->{'TYPE'} eq "jingle") { + print " " . xml_quote($href->{'JINGLETITLE'}) . "\n"; + } elsif($href->{'TYPE'} eq "musicpool") { + print " " . xml_quote($href->{'MUSICPOOLTITLE'}) . "\n"; + } + print " \n"; } - print " \n"; + print "\n"; } - print "\n"; } -- cgit v0.10.2