#! /usr/bin/perl # # Put the full path to perl on the first line, run the program with # `perl CGIservlet`, or put a symbolic link to perl in # the startup directory if you need a special version of perl. # if(grep(/\-\-help/i, @ARGV)) { print << 'ENDOFHELPTEXT'; # CGIservlet: # A HTTPd "connector" for running CGI scripts on unix systems as WWW # accessible Web sites. The servlet starts a true HTTP daemon that channels # HTTP requests to forked daughter processes. CGIservlet.pl is NOT a # full fledged server. Moreover, this servlet is definitely NOT intended # as a replacement of a real server (e.g., Apache). It's design goal was # SIMPLICITY, and not mileage. # # Note that a HTTP server can be accessed on your local machine WITHOUT # internet access (but WITH a DNS?): # use "http://localhost[:port]/[path]" or "http://127.0.0.1[:port]/[path]" # as the URL. It is also easy to restrict access to the servlet to localhost # users (i.e., the computer running the servlet). # # Suggested uses: # - A testbed for CGI-scripts and document-trees outside the primary server. # When developing new scripts and services, you don't want to mess up your # current Web-site. CGIservlet is an easy way to start a temporary (private) # server. CGIservlet allows to test separate HTTP server components, e.g., # user authentication, in isolation. # # - A special purpose temporary server (WWW everywhere/anytime). # We run identification and other experiments over the inter-/intra-net using # CGI-scripts. This means a lot of development and changes and only little # actual run-time. The people doing this do not want "scripting" access to our # departmental server with all its restrictions and security. So we need a # small, lightweigth, easy-to-configure server that can be run by each # investigator on her own account (and risk). # # - Interactive WWW presentations. # Not everyone is content with the features of "standard" office presentation # software. HTML and its associated browsers are an alternative (especially # under Linux). However, you need a server to realize the full interactive # nature of the WWW. CGIservlet with the necessary scripts can be run from # a floppie (a Web server in 100 kB). The CGIservlet can actually run a # (small) web site from RAM, without disk access (if you DO NOT use the # 2>pid.log redirection on startup). # With the "localhost" or "127.0.0.1" id in your browser you can use the # servlet standalone. # # When the servlet is started with the -r option, only requests from "localhost" # or "127.0.0.1" are accepted (default) or from addresses indicated after the # -r switch. # # Running demo's and more information can be found at # http://www.fon.hum.uva.nl/rob/OSS/OSS.html # # ############################################################################ # # Changes (document ALL changes with date, name and email here): # # 05 Apr 2013 - Renamed COOKIE_JAR into HTTP_COOKIE # 28 Mar 2013 - Version 1.4. # 18 Jun 2012 - Added --env, %UserEnv user defined ENV variables. Freeze %ENV. # 06 Jun 2012 - Added HTTP Cookie string to an Environment variable: COOKIE_JAR # 29 May 2012 - Added .log -> / to @RegAliasTranslation, blocks attempts to read # log files. # 22 May 2012 - Blocked "hidden" files and directories starting with "." in # default @RegAliasTranslation. Removed obsolete CVS reference. # 21 May 2012 - Inserted the -m[emory] switch for loading and serving from RAM. # The option was mentioned in the manual, but the cli switch was # never added. # 22 Jul 2003 - Plain output using binary print io. `cat ...` # 22 Jul 2003 - Added 'use CGI::Carp qw(fatalsToBrowser);' line # for debugging. Standard this is commented out # for security reasons (suggested by Jochen_Hayek@ACM.org). # 22 Jul 2003 - Added error checking to doarg (suggested by Jochen_Hayek@ACM.org) # 22 Jul 2003 - Removed SERVER_PORT from HTTP_HOST (Bug found by Jochen_Hayek@ACM.org) # 22 Jul 2003 - Updated documentation. Added CGIservlet directory # to the search path of CGIservletSETUP.pl # 20 May 2003 - Made sure recycled (double) pid's do not mess up the # @brood list and added a --help switch. # 20 May 2003 - Added a maximum running time for child processes # with command line switch -xterm. # 15 Jan 2002 - Version 1.3 # 19 Oct 2001 - Included browsing of directories and a new -s # security switch. With security toggled of # directories can be browsed and all mime-types # are served, either as 'text/plain' or as # 'application/octed-stream'. # 18 May 2001 - Added some HTTP HTTP lines. # 13 Jun 2000 - Included the possibility to add POST request # to GET query-strings (and change the request # method). The -l ($Maxlength) maximum length # option now covers POST requests too. # 8 Dec 1999 - Included hooks for compression when running from RAM. # 2 Dec 1999 - Autoflush enabled. # 2 Dec 1999 - Allow running a Web Site from RAM. # 2 Dec 1999 - Changed the behavior of CGIservletSETUP. CGIservlet # will eval ALL setup files, the one in the CGIscriptor # subdirectory (if any) AND the one in the current # directory. (also added a close(SETUP) command) # 26 Nov 1999 - Added some minimal security for 'automatic', out of # the box installation. # 26 Nov 1999 - Made the text/osshell mime-type functional (i.e., # without any scripts, implement a dynamic web server) # Linited to '.cgi' extension. # 26 Nov 1999 - Added aliasing of URL paths, both one-to-one lookups # and full regular expression, i.e., $Path =~ s/.../.../g # replace commands # 28 Sep 1999 - Made all client supplied HTTP parameter names lowercase # to handle inconsistencies in case use. # 29 Jul 1999 - Allowed for a SETUP configuration file 'CGIservletSETUP.pl'. # Use $beginarg from the 'CGIscriptor/' directory if it exists. # (R.J.J.H.vanSon@gmail.com) # # ############################################################################ # # Known bugs # # 23 Mar 2000 - An odd server side network error is reported by Netscape # when a Post is initiated from a Javascript Submit of a #