cgi error script

The cgi error script attempts to print out a useful error message when a cgi script fails instead of the rather meaningless "Internal Server Error".

The script is /user/web/cgi-bin/cgierror.pl. It is fairly simple. If a user script generated the error, it prints a message indicating to whom the script belongs and showing relevant parts of the error logs. For non user scripts, it prints an error message. If no script is involved, the "Internal Server Error" message is printed.

To enable the script, you must edit srm.conf. Add the following line:

ErrorDocument 500 /cgi-bin/cgierror.pl
A HUP signal needs to be sent to the server when the configuration files are changed.

If for some reason cgierror.pl is unable to run correctly, the server will handle it gracefully and report an "Internal Server Error".

Thermometers

The web pages for the thermometers are in /user/web/htdocs/facility/labtemps. There are two cgi scripts. cgi-bin/therm.pl polls each thermometer and displays the current temperature. cgi-bin/thermimg.pl generates the thermometer graphic.

The script bin/thermgraph.pl is run from a cron job at 11:05am and 11:05pm. It generates the page graphs.html and all of the graph images in graphs/.

The file thermometers contains the locations of all the current thermometers. Each line describes one thermometer. A thermometer description contains a room name, a server name, a warning theshold, and a room number. Each field is delimited by tabs. The file looks like:

machine room    console         75      3300
aleutian lab    kiska           80      3352
dance lab       waltz           80      3353
rock lab        quartzite       80      3308
This file is used by the scripts to generate the web pages and graphs.

Installing Thermometers

The software for the thermometers is installed locally on each thermometer server in /usr/cpssbin/thermometer. The script /soft/sysadm/therm/therm.install will install the thermometer software. It must be run as root.

The install script copies a number of scripts into /usr/cpssbin/thermometer, modifies the crontab, /etc/services and adds a startup script.

The warning threshold defaults to 75. To change this you need to edit /usr/cpssbin/thermometer/warn.

There is a bug with the thermometer startup script. It grabs the console when the machine boots up. I do not know how to fix this.

You need to add a new thermometer to /user/web/htdocs/facility/labtemps/theremometers by hand.

A QTek thermometer must be attached to each thermometer server. Please see the "Qtek Software Thermometer User Guide" for details about the thermometers. Special cables need to be made for the thermometers. See the guide for details. The thermometers must be attached to an RS232 serial port. It may be necessary to change the jumpers in the server. On an ULTRA-10, the jumpers are JP3 and JP4.

Technical Report Library

The technical report library is managed by a variety of different scripts. The actual server is the Dienst Technical Report Server. The general dienst stuff can be found in /user/web/dienst.

The technical report submission script is /user/web/cgi-bin/tech-sub.

The local tech report information is in /user/web/htadmin.

The tech report information is stored in tech_reports.bib. This should belong to group faculty and be writable by group. Online versions of the tech reports are stored in ./TR.

updateDB.pl updates the tech report library. It is called by updateall which runs nightly.

authoraliases is a human generated file used by updateDB.pl. It contains a list of aliases an author is knowned by (e.g. B. Smith=Smith,Bob). This is to ensure that papers written by the same author will appear together. Periodically a human should view the tech reports sorted by author, looking for possible aliases to be added.

Periodically the dienst server gets confused. When this happens, it generates an error when someone tries to view a tech report. The solution is to kill the server and restart it. Kill the server by using

and start it with the command: Sometimes it complains about not being able to bind to a certain port. Just wait and try again. It will start eventually.

Changes to Source

The following changes were made to the dienst code. A contact field was added to each tech report. This contact is displayed if no on line version of the document is available. The contact is typically the email address of the faculty member associated with the paper.

The contact information is displayed in UI_Server/trs.pl. Indexer/access_tr_database.pl and Indexer/parse_bib_file.pl extract the information from the bib file and were modified to handle the contact field.

The author alias feature was added to dienst. The code for this is in updateDB.pl.

CGI Mail Script

In order to monitor email sent by cgi scripts, sendmail has been modified on atlantic. The reason for monitoring email is that in the past we have had problems with web scripts generating too many messages and because all mail is from nobody, it was difficult to track down which page or script was actually responsible for the problem.

Everytime a cgi script mails a message, it is logged to /user/web/logs/mail_log. Log entries look like:

[Tue Dec  1 17:53:21 EST 1998] SCRIPT=/cgi-user/xujinshe/chen.sh ARGS=-i xujinshe
[Tue Dec  1 08:12:22 EST 1998] SCRIPT=/cgi-user/barrios1/formmail3.pl URL=http://ism.ferris.edu/students/b/bigottmi/ ARGS=-t
SCRIPT indicates which script sent the mail. URL indicates which page referenced the script.

/usr/lib/sendmail is a link to /usr/lib/sendmail.web which looks like the following:

#!/opt/bin/perl
 
#
#  only log if the mail is from nobody
#
$ENV{'PATH'}="";
if ($< == 60001)
{
        open (LOGFILE, ">>/user/web/logs/mail_log") || die "Cannot open logfile";
        flock (LOGFILE, 2);
        seek (LOGFILE, 0, 2);
        $date=`/usr/bin/date`;
        chop $date;
        print LOGFILE "[$date] ";
        print LOGFILE "SCRIPT=$ENV{'SCRIPT_NAME'} ";
        if ($ENV{'DOCUMENT_URI'})
        {
                print LOGFILE "URL=$ENV{'DOCUMENT_URI'} ";
        }
        elsif ($ENV{'HTTP_REFERER'})
        {
                print LOGFILE "URL=$ENV{'HTTP_REFERER'} ";
        }
        print LOGFILE "ARGS=@ARGV\n";
        close(LOGFILE);
        #flock(LOGFILE,8);
}
exec '/usr/lib/sendmail.bin', @ARGV;

The original sendmail has been renamed /usr/lib/sendmail.bin.

man2html

I wrote my own version of man2html. It started out simple enough, but it took on a life of its own. It consists of two parts. /user/web/cgi-bin/man2html is a straightforward perl script that handles multiple man pages and key word searches. /user/web/cgi-bin/troff2html is a compiled C program that does most of the real work. The source for troff2html is in /user/web/cgi-src, but you probably do not want to look at it. :)

man2html handles most man pages. There are a few rare troff constructs it does not handle correctly, and some pages are formatted strangely. It gets it right 99% of the time.

In order for troff2html to handle pic requests correctly, /user/web/htdocs/tmp must be a symbolic link to /tmp.

Online Voting

The cgi scripts for Online Voting are in /user/cgi/web/Vote. This directory is protected with htaccess. Every student has a password. Their password is their student id. This password file is generated automatically by a cronjob on sargasso:
15 05 * * * /soft/sparc/adm/Scripts/pidpasswd.pl > /user/cgi/web/Vote/.htpasswd

In order for voting to work, the script withrow.pl must be able to write in the Results/Withrow directory. Currently withro.pl is setuid calend44 and Results/Withrow has acls on it that permit calend44 to write there.

If the voting script fails, it should print out a message to the voter telling them that something went wrong.

The voting results are stored in Results. To start a new vote, simply clear the contents of this directory. NOTE!! Do not do this until the people handling the Withrow award have counted the votes.