home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / patchSG0002222.idb / var / www / cgi-bin / webdist.cgi.z / webdist.cgi
Encoding:
Text File  |  1997-07-30  |  5.0 KB  |  184 lines

  1. #!/usr/sbin/perl
  2.  
  3.  
  4. ## Copyright 1995, Silicon Graphics, Inc.
  5. ## All Rights Reserved.
  6. ##
  7. ## This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  8. ## the contents of this file may not be disclosed to third parties, copied or
  9. ## duplicated in any form, in whole or in part, without the prior written
  10. ## permission of Silicon Graphics, Inc.
  11. ##
  12. ## RESTRICTED RIGHTS LEGEND:
  13. ## Use, duplication or disclosure by the Government is subject to restrictions
  14. ## as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  15. ## and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  16. ## successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  17. ## rights reserved under the Copyright Laws of the United States.
  18.  
  19.  
  20. #__________________________________________________________
  21. #
  22. #   SGI Patch 2222 disables the webdist cgi scripts for security
  23. #   reasons. These scripts will be removed entirely in the
  24. #   next release.
  25. #__________________________________________________________
  26.  
  27. # webdist feature is disabled - display a message and exit.
  28.  
  29. print <<ENDOFTEXT ;
  30. Content-type: text/html
  31.  
  32. <HTML>
  33. <HEAD><TITLE>WebDist: feature disabled.</TITLE></HEAD>
  34. <BODY><H2>WebDist: feature disabled.</H2>
  35. This feature has been disabled.
  36. </BODY>
  37. </HTML>
  38. ENDOFTEXT
  39.  
  40. exit ;
  41.  
  42. #__________________________________________________________
  43.  
  44.  
  45. # Process cgi args
  46.  
  47. if( $ENV{'REQUEST_METHOD'} eq "GET" )
  48. {
  49.    $buffer=$ENV{'QUERY_STRING'} ;
  50. }
  51. else
  52. {
  53.    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}) ;
  54. }
  55. @pairs = split(/&/, $buffer) ;
  56. foreach (@pairs)
  57. {
  58.    tr/+/ / ;
  59.    ($name,$value)=  split(/=/) ;
  60.    $value        =~ s/%(..)/pack("c",hex($1))/ge ;
  61.    $name         =~ s/%(..)/pack("c",hex($1))/ge ;
  62.  
  63.    $in{$name} = $value;
  64.  
  65. }
  66.  
  67.  
  68. # extract params
  69. $distloc=$in{distloc};
  70. $pageloc=$in{pageloc};
  71.  
  72. # trim off undesirable meta chars.
  73. $distloc =~ s/[|;]//g ;
  74. $pageloc =~ s/[|;]//g ;
  75.  
  76. if ($distloc eq "") {
  77.     &report_fatal_error("<H3>Error: Distribution Directory cannot be empty!</H3>");
  78. }
  79.  
  80.  
  81. # Execute webdist here to create the page
  82.  
  83. $pid = fork;
  84.  
  85. if ($pid == 0) {
  86.  
  87.     # set environment variable so that xconfirm window is displayed
  88.     # this var is not set in a CGI script
  89.     $ENV{"DISPLAY"} = ":0.0";
  90.  
  91.     # Close stdout so that xconfirm writes to /dev/null
  92.     close(STDOUT);
  93.     open(STDOUT, "/dev/null");
  94.  
  95.     exec("/usr/bin/X11/xconfirm",
  96.      "-c",
  97.      "-exclusive",
  98.      "-B", "Dismiss",
  99.      "-icon", "info",
  100.      "-header", "Web Software Distribution Tool",
  101.      "-noframe",
  102.      "-t", "The Web Software Distribution Page is being created.",
  103.      "-t", "This may take a few minutes if there are many products.",
  104.      "-t", "",
  105.      "-t", "You may dismiss this dialog at any time without stopping",
  106.      "-t", "the Web Distribution Tool by pressing \"Dismiss\".",
  107.      "-t", "",
  108.      "-t", "You may cancel creating this page by pressing the",
  109.      "-t", "\"Stop\" button in your Web browser (eg Netscape).");
  110.  
  111.      exit 0;
  112. }
  113.  
  114. $output = `/usr/etc/webdist $distloc $pageloc 2>&1`;
  115.  
  116. kill(2, $pid);
  117.  
  118. $filename = "/usr/tmp/webdist.$$.html";
  119.  
  120. if ($? != 0) {
  121.     &report_fatal_error($output);
  122. } else {
  123.     print "Content-type: text/html\n\n";
  124.     print "<HTML>\n";
  125.     print "<BODY BACKGROUND=\"/webdist/images/background.jpeg\">\n";
  126.     
  127.     unless (open(OUT, ">$filename")) {
  128.     print "<H3>Error: Cannot open temporary file $filename</H3>";
  129.     } else {
  130.     print OUT "$output";
  131.     print "<H3 ALIGN=CENTER>Web Software Distribution Page Created.<BR>\n";
  132.     print "(You can see what the page will look like below)</H3>\n";
  133.     print "<HR>\n";
  134.     print "<H3 ALIGN=CENTER>Installing the Web Software Distribution Page<BR>\n";
  135.     print "(Do this now, while you can still refer to this page for reference)</H3>";
  136.     print "<P>\n";
  137.     print "The new Web Software Distribution Page has been created at\n";
  138.     print "location <SAMP>$filename</SAMP>.\n";
  139.     $dist = `basename $distloc`;
  140.     chop($dist);
  141.     webdist:chop($disthost = `hostname`);
  142.     print "<P> You will need to <B>move this file</B> to\n";
  143.     print "the location <SAMP>/var/www/htdocs/dist/$dist.html</SAMP>.\n";
  144.     print "</P>\n";
  145.     print "<HR>\n";
  146.     print "<H3 ALIGN=CENTER>Using the Web Software Distribution Page</H3>\n";
  147.     print "<P>\n";
  148.     print "After installing this page, users on the network\n";
  149.     print "can install software from it by using\n";
  150.     print "the URL <SAMP>http://$disthost/dist/$dist.html</SAMP>.\n";
  151.     print "</P>\n";
  152.     print "<HR>\n";
  153.     print "<P>\n";
  154.     print "The following is what the new Web Software Distribution Page will look like:";
  155.     print "</P>\n";
  156.     print "<HR>\n";
  157.     print "$output";
  158.     }
  159.  
  160. }
  161.  
  162.  
  163. #
  164. # Report fatal error 
  165. #
  166.  
  167. sub report_fatal_error {
  168.     local ($msg) = @_;
  169.  
  170.     print "Content-type: text/html\n\n";
  171.     print "<HTML>\n";
  172.     print "<HEAD>\n";
  173.     print "<BODY BACKGROUND=\"/webdist/images/background.jpeg\">\n";
  174.     print "<TITLE>Web Software Distribution Tool Error</TITLE>\n";
  175.     print "</HEAD>\n";
  176.     print "<BODY BACKGROUND=\"webdist/images/background.jpeg\">\n";
  177.     print "<H3>Web Software Distribution Tool Error</H3>\n";
  178.     print "$msg<P>\n";
  179.     print "Return to <A HREF=../webdist.html>webdist</A> page.";
  180.     print "</BODY>\n";
  181.  
  182.     exit 1;
  183. }
  184.