[system] / trunk / webwork2 / bin / check_modules.pl Repository:
ViewVC logotype

View of /trunk/webwork2/bin/check_modules.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4904 - (download) (as text) (annotate)
Tue Mar 27 17:04:02 2007 UTC (6 years, 1 month ago) by glarose
File size: 2673 byte(s)
Preliminary commit of code to restrict access to assignments by client
IP address.  This commit adds the database tables for IP address
restriction, updates check_modules.pl to require Net::IP for address
matching, adds database calls in DB.pm for manipulating locations and
addresses, and adds location restriction to the set editing in
ProblemSetDetail.

This commit does not add actual restriction to sets, nor the ability
to create locations to which to restrict access.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 
    6 my @applicationsList = qw(
    7   mkdir
    8   mv
    9   mysql
   10   tar
   11   latex
   12   pdflatex
   13   dvipng
   14   tth
   15   giftopnm
   16   ppmtopgm
   17   pnmtops
   18   pnmtopng
   19   pngtopnm
   20 );
   21 
   22 my @apache1ModulesList = qw(
   23   Apache
   24   Apache::Constants
   25   Apache::Cookie
   26   Apache::Log
   27   Apache::Request
   28 );
   29 
   30 my @apache2ModulesList = qw(
   31   Apache2::Request
   32   Apache2::Cookie
   33   Apache2::ServerRec
   34   Apache2::ServerUtil
   35 );
   36 
   37 my @modulesList = qw(
   38   Benchmark
   39   Carp
   40   CGI
   41   Data::Dumper
   42   Data::UUID
   43   Date::Format
   44   Date::Parse
   45   DateTime
   46   DBD::mysql
   47   DBI
   48   Digest::MD5
   49   Errno
   50   File::Copy
   51   File::Find
   52   File::Path
   53   File::Spec
   54   File::stat
   55   File::Temp
   56   GD
   57   Getopt::Long
   58   Getopt::Std
   59   HTML::Entities
   60   HTML::Tagset
   61   IO::File
   62   Iterator
   63   Iterator::Util
   64   Mail::Sender
   65   MIME::Parser
   66   MIME::Base64
   67   Net::IP
   68   Net::LDAPS
   69   Net::SMTP
   70   Opcode
   71   PHP::Serialization
   72   Pod::Usage
   73   Safe
   74   SOAP::Lite
   75   Socket
   76   SQL::Abstract
   77   String::ShellQuote
   78   Text::Wrap
   79   Time::HiRes
   80   Time::Zone
   81   URI::Escape
   82   XML::Parser
   83   XML::Parser::EasyTree
   84   XML::Writer
   85   XMLRPC::Lite
   86 );
   87 
   88 # modules used by disabled code
   89 # RQP::Render (RQP)
   90 # SOAP::Lite (PG::Remote)
   91 
   92 my $apache_version = shift @ARGV;
   93 unless (defined $apache_version and $apache_version =~ /^apache[12]$/) {
   94   warn "invalid apache version specified -- assuming apache1\n";
   95   warn "usage: $0 { apache1 | apache2 }\n";
   96   sleep 1;
   97   $apache_version = "apache1";
   98 }
   99 
  100 if ($apache_version eq "apache1") {
  101   push @modulesList, @apache1ModulesList;
  102 } elsif ($apache_version eq "apache2") {
  103   push @modulesList, @apache2ModulesList;
  104 }
  105 
  106 my @PATH = split(/:/, $ENV{PATH});
  107 check_apps(@applicationsList);
  108 
  109 check_modules(@modulesList);
  110 
  111 sub check_apps {
  112   my @applicationsList = @_;
  113   print "\nChecking your \$PATH for executables required by WeBWorK...\n";
  114   print "\$PATH=", shift @PATH, "\n";
  115   print join ("\n", map("      $_", @PATH)), "\n\n";
  116 
  117   foreach my $app (@applicationsList)  {
  118     my $found = which($app);
  119     if ($found) {
  120       print "   $app found at $found\n";
  121     } else {
  122       print "** $app not found in \$PATH\n";
  123     }
  124   }
  125 }
  126 
  127 sub which {
  128   my $app = shift;
  129   foreach my $path (@PATH) {
  130     return "$path/$app" if -e "$path/$app";
  131   }
  132 }
  133 
  134 sub check_modules {
  135   my @modulesList = @_;
  136 
  137   print "\nChecking your \@INC for modules required by WeBWorK...\n";
  138   my @inc = @INC;
  139   print "\@INC=", shift @inc, "\n";
  140   print join ("\n", map("     $_", @inc)), "\n\n";
  141 
  142   foreach my $module (@modulesList)  {
  143     eval "use $module";
  144     if ($@) {
  145       my $file = $module;
  146       $file =~ s|::|/|g;
  147       $file .= ".pm";
  148       if ($@ =~ /Can't locate $file in \@INC/) {
  149         print "** $module not found in \@INC\n";
  150       } else {
  151         print "** $module found, but failed to load: $@";
  152       }
  153     } else {
  154       print "   $module found and loaded\n";
  155     }
  156   }
  157 }

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9