File:  [LON-CAPA] / doc / loncapafiles / sanitycheck.piml
Revision 1.11: download - view: text, annotated - select for diffs
Fri Dec 13 23:15:50 2002 UTC (21 years, 5 months ago) by albertel
Branches: MAIN
CVS tags: version_0_6_2, version_0_6, HEAD
- Matthew was INNNSAAANNNEEE!!!!

    1: <!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN" 
    2: 	"http://lpml.sourceforge.net/DTD/piml.dtd">
    3: <!-- sanitycheck.piml -->
    4: <!-- Scott Harrison -->
    5: 
    6: <!-- $Id: sanitycheck.piml,v 1.11 2002/12/13 23:15:50 albertel Exp $ -->
    7: 
    8: <!--
    9: 
   10: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   11: 
   12: LON-CAPA is free software; you can redistribute it and/or modify
   13: it under the terms of the GNU General Public License as published by
   14: the Free Software Foundation; either version 2 of the License, or
   15: (at your option) any later version.
   16: 
   17: LON-CAPA is distributed in the hope that it will be useful,
   18: but WITHOUT ANY WARRANTY; without even the implied warranty of
   19: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20: GNU General Public License for more details.
   21: 
   22: You should have received a copy of the GNU General Public License
   23: along with LON-CAPA; if not, write to the Free Software
   24: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   25: 
   26: /home/httpd/html/adm/gpl.txt
   27: 
   28: http://www.lon-capa.org/
   29: 
   30: -->
   31: 
   32: <piml>
   33: <targetroot>/</targetroot>
   34: <files>
   35: <file>
   36: <target dist='default'>/var/lib/mysql/mysql.sock</target>
   37: <perlscript mode='fg'>
   38: unless
   39:     (-e '<TARGET />') # Does file exist?
   40:   {
   41:     print("**** ERROR **** Missing <TARGET />\n");
   42:   }
   43: else # It exists, so look at the file metadata more closely.
   44:   {
   45:     my @s = stat('<TARGET />');
   46:     my $uid = $s[4];
   47:     my $mode = $s[2];
   48:     my $web_uid = getpwnam('www');
   49:     my $smode = sprintf("%04o",$mode & 07777);
   50: 
   51:     if ($uid ne $web_uid) # If file owned by someone else other than www.
   52:       {
   53: 	print('**** ERROR **** <TARGET /> should be owned by'.
   54: 	      ' www.'."\n".'Try these commands to make things right:'."\n".
   55: 	      'chown www:www <TARGET />'."\n".
   56: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
   57:       }
   58:     else # Check permissions on the file to make sure it is private to www.
   59:       {
   60: 	$smode =~ /^.(.)..$/;
   61: 	my $wflag = $1;
   62: 	if ($wflag != 7) # Can www use this socket?  (Hope so!)
   63: 	  {
   64: 	    print('**** ERROR **** '.
   65: 	      '<TARGET /> should be user "rwx" (by'.
   66: 	      ' www).'."\n".'Try these commands to make things right:'."\n".
   67: 	      'chown www:www <TARGET />'."\n".
   68: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
   69: 	  }
   70: 	$smode=~/^..(..)$/;
   71: 	$wflag=$1;
   72: 	if ($wflag ne "00") # Can others use this socket?  (Hope not!)
   73: 	  {
   74: 	    print('**** ERROR **** '.
   75: 	      '<TARGET /> should not be group or everybody accessible'.
   76: 	      '.'."\n".'Try these commands to make things right:'."\n".
   77: 	      'chown www:www <TARGET />'."\n".
   78: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
   79: 	  }
   80:       }
   81:   }
   82: </perlscript>
   83: </file>
   84: <file>
   85: <target dist='default'>/etc/httpd/conf/loncapa.conf</target>
   86: <perlscript mode='fg'>
   87: open IN, "&lt;<TARGET />";
   88: my $hbug=-1;
   89: my $dbug=-1;
   90: while (&lt;IN&gt;) {
   91:  if (/PerlSetVar\s+lonHostID\s+(\S+)/) {
   92:   my $v=$1;
   93:   $hbug=0;
   94:   $hbug=1 if $v=~/\W/;
   95:   $hbug=1 if $v=~/\_/;
   96:  }
   97:  if (/PerlSetVar\s+lonDefDomain\s+(\S+)/) {
   98:   my $v=$1;
   99:   $dbug=0;
  100:   $dbug=1 if $v=~/\W/;
  101:   $dbug=1 if $v=~/\_/;
  102:   # Avoid namespace conflicts under the web server's DocumentRoot.
  103:   my @badnames=('raw','userfiles','priv','adm','uploaded');
  104:   foreach my $bad (@badnames) {
  105:    $dbug=1 if $v eq $bad;
  106:   }
  107:  }
  108: }
  109: if ($hbug) {
  110:   print "**** ERROR **** <TARGET /> has invalid lonHostID\n";
  111: }
  112: if ($dbug) {
  113:   print "**** ERROR **** <TARGET /> has invalid lonDefDomain\n";
  114: }
  115: </perlscript>
  116: </file>
  117: <file>
  118: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
  119: open IN, "&lt;<TARGET />";
  120: my $rbug=0;
  121: my $dbug=0;
  122: my $sbug=0;
  123: my $fbug=0;
  124: while (&lt;IN&gt;) {
  125:  next if (/^(\#|\s*$)/);
  126:  if (/\S/) {
  127:   $rbug=1 if /\r/;
  128:   my @a=split(/\:/,$_);
  129:   $dbug=1 if $a[0]=~/\W/;
  130:   $dbug=1 if $a[0]=~/\_/;
  131:   $dbug=1 if $a[1]=~/\_/;
  132:   $dbug=1 if $a[1]=~/\W/;
  133:   $fbug=1 if (@a<5 || @a>6);
  134:   my $expr='\s.+$';
  135:   $sbug=1 if ($a[0] =~ /$expr/ ||
  136: 	      $a[1] =~ /$expr/ ||
  137: 	      $a[2] =~ /$expr/ ||
  138: 	      $a[3] =~ /$expr/ ||
  139: 	      $a[4] =~ /$expr/ )
  140: ;
  141:  }
  142: }
  143: close IN;
  144: if ($rbug) {
  145:   print "**** ERROR **** <TARGET /> is DOS-formatted\n";
  146: }
  147: if ($dbug) {
  148:   print "**** ERROR **** <TARGET /> has invalid host id or domain id\n";
  149: }
  150: if ($fbug) {
  151:   print "**** ERROR **** <TARGET /> is lacking 5 or 6 columns for every row\n";
  152: }
  153: if ($sbug) {
  154:   print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
  155: }
  156: </file>
  157: <file>
  158: <target dist='default'>/home/httpd/lonTabs/spare.tab</target>
  159: open IN, "&lt;<TARGET />";
  160: my $rbug=0;
  161: my $dbug=0;
  162: my $sbug=0;
  163: while (&lt;IN&gt;) {
  164:  if (/\S/) {
  165:   $rbug=1 if /\r/;
  166:   $dbug=1 if $_=~/\W.*\n$/;
  167:   $dbug=1 if $_=~/\_/;
  168:   $sbug=1 if /\s.+$/;
  169:  }
  170: }
  171: close IN;
  172: if ($rbug) {
  173:   print "**** ERROR **** <TARGET /> is DOS-formatted\n";
  174: }
  175: if ($dbug) {
  176:   print "**** ERROR **** <TARGET /> has invalid host id\n";
  177: }
  178: if ($sbug) {
  179:   print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
  180: }
  181: </file>
  182: </files>
  183: </piml>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>