File:  [LON-CAPA] / doc / loncapafiles / sanitycheck.piml
Revision 1.12: download - view: text, annotated - select for diffs
Tue Jan 7 21:12:54 2003 UTC (21 years, 4 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
BUG 1085 FIXED.  A common redhat glitch (due to anaconda installation code
I think) is fixed; /etc/hosts is monitored, should have 2 or more
non-commented lines.

    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.12 2003/01/07 21:12:54 harris41 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'>/etc/hosts</target>
   37: <perlscript mode='fg'>
   38: unless
   39:     (-e '<TARGET />') # Does file exist?
   40:   {
   41:     print("**** ERROR **** Missing <TARGET />\n");
   42:   }
   43: else
   44:   {
   45:     my $numentries = `grep -v '^#' <TARGET /> | grep -c '[[:alpha:]]'`;
   46:     if ($numentries == 1)
   47:       {
   48:         print("**** ERROR **** Malformatted <TARGET />\n");
   49:         print("<TARGET /> typically should have at least two entries, ".
   50: 	      "e.g.:\n");
   51: 	print("127.0.0.1               localhost.localdomain localhost\n");
   52: 	print("35.8.63.26              s16.lite.msu.edu s16\n");
   53:         print("The <TARGET /> file on your machine looks like it was \n".
   54: 	      "messed up due to a common bug with RedHat installations.\n".
   55: 	      "(This weird bug is RedHat's fault, not LON-CAPA's.)\n");
   56:         print("Please read the man pages about \"hosts\" and fix your\n".
   57: 	      "<TARGET /> file.\n");
   58:       }
   59:   }
   60: </perlscript>
   61: </file>
   62: <file>
   63: <target dist='default'>/var/lib/mysql/mysql.sock</target>
   64: <perlscript mode='fg'>
   65: unless
   66:     (-e '<TARGET />') # Does file exist?
   67:   {
   68:     print("**** ERROR **** Missing <TARGET />\n");
   69:   }
   70: else # It exists, so look at the file metadata more closely.
   71:   {
   72:     my @s = stat('<TARGET />');
   73:     my $uid = $s[4];
   74:     my $mode = $s[2];
   75:     my $web_uid = getpwnam('www');
   76:     my $smode = sprintf("%04o",$mode & 07777);
   77: 
   78:     if ($uid ne $web_uid) # If file owned by someone else other than www.
   79:       {
   80: 	print('**** ERROR **** <TARGET /> should be owned by'.
   81: 	      ' www.'."\n".'Try these commands to make things right:'."\n".
   82: 	      'chown www:www <TARGET />'."\n".
   83: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
   84:       }
   85:     else # Check permissions on the file to make sure it is private to www.
   86:       {
   87: 	$smode =~ /^.(.)..$/;
   88: 	my $wflag = $1;
   89: 	if ($wflag != 7) # Can www use this socket?  (Hope so!)
   90: 	  {
   91: 	    print('**** ERROR **** '.
   92: 	      '<TARGET /> should be user "rwx" (by'.
   93: 	      ' www).'."\n".'Try these commands to make things right:'."\n".
   94: 	      'chown www:www <TARGET />'."\n".
   95: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
   96: 	  }
   97: 	$smode=~/^..(..)$/;
   98: 	$wflag=$1;
   99: 	if ($wflag ne "00") # Can others use this socket?  (Hope not!)
  100: 	  {
  101: 	    print('**** ERROR **** '.
  102: 	      '<TARGET /> should not be group or everybody accessible'.
  103: 	      '.'."\n".'Try these commands to make things right:'."\n".
  104: 	      'chown www:www <TARGET />'."\n".
  105: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
  106: 	  }
  107:       }
  108:   }
  109: </perlscript>
  110: </file>
  111: <file>
  112: <target dist='default'>/etc/httpd/conf/loncapa.conf</target>
  113: <perlscript mode='fg'>
  114: open IN, "&lt;<TARGET />";
  115: my $hbug=-1;
  116: my $dbug=-1;
  117: while (&lt;IN&gt;) {
  118:  if (/PerlSetVar\s+lonHostID\s+(\S+)/) {
  119:   my $v=$1;
  120:   $hbug=0;
  121:   $hbug=1 if $v=~/\W/;
  122:   $hbug=1 if $v=~/\_/;
  123:  }
  124:  if (/PerlSetVar\s+lonDefDomain\s+(\S+)/) {
  125:   my $v=$1;
  126:   $dbug=0;
  127:   $dbug=1 if $v=~/\W/;
  128:   $dbug=1 if $v=~/\_/;
  129:   # Avoid namespace conflicts under the web server's DocumentRoot.
  130:   my @badnames=('raw','userfiles','priv','adm','uploaded');
  131:   foreach my $bad (@badnames) {
  132:    $dbug=1 if $v eq $bad;
  133:   }
  134:  }
  135: }
  136: if ($hbug) {
  137:   print "**** ERROR **** <TARGET /> has invalid lonHostID\n";
  138: }
  139: if ($dbug) {
  140:   print "**** ERROR **** <TARGET /> has invalid lonDefDomain\n";
  141: }
  142: </perlscript>
  143: </file>
  144: <file>
  145: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
  146: open IN, "&lt;<TARGET />";
  147: my $rbug=0;
  148: my $dbug=0;
  149: my $sbug=0;
  150: my $fbug=0;
  151: while (&lt;IN&gt;) {
  152:  next if (/^(\#|\s*$)/);
  153:  if (/\S/) {
  154:   $rbug=1 if /\r/;
  155:   my @a=split(/\:/,$_);
  156:   $dbug=1 if $a[0]=~/\W/;
  157:   $dbug=1 if $a[0]=~/\_/;
  158:   $dbug=1 if $a[1]=~/\_/;
  159:   $dbug=1 if $a[1]=~/\W/;
  160:   $fbug=1 if (@a<5 || @a>6);
  161:   my $expr='\s.+$';
  162:   $sbug=1 if ($a[0] =~ /$expr/ ||
  163: 	      $a[1] =~ /$expr/ ||
  164: 	      $a[2] =~ /$expr/ ||
  165: 	      $a[3] =~ /$expr/ ||
  166: 	      $a[4] =~ /$expr/ )
  167: ;
  168:  }
  169: }
  170: close IN;
  171: if ($rbug) {
  172:   print "**** ERROR **** <TARGET /> is DOS-formatted\n";
  173: }
  174: if ($dbug) {
  175:   print "**** ERROR **** <TARGET /> has invalid host id or domain id\n";
  176: }
  177: if ($fbug) {
  178:   print "**** ERROR **** <TARGET /> is lacking 5 or 6 columns for every row\n";
  179: }
  180: if ($sbug) {
  181:   print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
  182: }
  183: </file>
  184: <file>
  185: <target dist='default'>/home/httpd/lonTabs/spare.tab</target>
  186: open IN, "&lt;<TARGET />";
  187: my $rbug=0;
  188: my $dbug=0;
  189: my $sbug=0;
  190: while (&lt;IN&gt;) {
  191:  if (/\S/) {
  192:   $rbug=1 if /\r/;
  193:   $dbug=1 if $_=~/\W.*\n$/;
  194:   $dbug=1 if $_=~/\_/;
  195:   $sbug=1 if /\s.+$/;
  196:  }
  197: }
  198: close IN;
  199: if ($rbug) {
  200:   print "**** ERROR **** <TARGET /> is DOS-formatted\n";
  201: }
  202: if ($dbug) {
  203:   print "**** ERROR **** <TARGET /> has invalid host id\n";
  204: }
  205: if ($sbug) {
  206:   print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
  207: }
  208: </file>
  209: </files>
  210: </piml>

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