File:  [LON-CAPA] / doc / loncapafiles / sanitycheck.piml
Revision 1.22: download - view: text, annotated - select for diffs
Sun Dec 10 23:23:55 2006 UTC (17 years, 5 months ago) by albertel
Branches: MAIN
CVS tags: version_2_3_X, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_99_1, version_2_2_99_0, HEAD
- sanitycheck now alllows - ans . in domains and host ids

    1: <!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN" 
    2: 	"http://lpml.sourceforge.net/DTD/piml.dtd">
    3: <!-- sanitycheck.piml -->
    4: 
    5: <!-- $Id: sanitycheck.piml,v 1.22 2006/12/10 23:23:55 albertel Exp $ -->
    6: 
    7: <!--
    8: 
    9: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   10: 
   11: LON-CAPA is free software; you can redistribute it and/or modify
   12: it under the terms of the GNU General Public License as published by
   13: the Free Software Foundation; either version 2 of the License, or
   14: (at your option) any later version.
   15: 
   16: LON-CAPA is distributed in the hope that it will be useful,
   17: but WITHOUT ANY WARRANTY; without even the implied warranty of
   18: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19: GNU General Public License for more details.
   20: 
   21: You should have received a copy of the GNU General Public License
   22: along with LON-CAPA; if not, write to the Free Software
   23: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24: 
   25: /home/httpd/html/adm/gpl.txt
   26: 
   27: http://www.lon-capa.org/
   28: 
   29: -->
   30: 
   31: <piml>
   32: <targetroot>/</targetroot>
   33: <files>
   34: <file>
   35: <target dist='default'>/etc/hosts</target>
   36: <perlscript mode='fg'>
   37: unless
   38:     (-e '<TARGET />') # Does file exist?
   39:   {
   40:     print("**** ERROR **** Missing <TARGET />\n");
   41:   }
   42: else
   43:   {
   44:     my $numentries = `grep -v '^#' <TARGET /> | grep -c '[[:alpha:]]'`;
   45:     if ($numentries == 1)
   46:       {
   47:         print("**** ERROR **** Malformatted <TARGET />\n");
   48:         print("<TARGET /> typically should have at least two entries, ".
   49: 	      "e.g.:\n");
   50: 	print("127.0.0.1               localhost.localdomain localhost\n");
   51: 	print("35.8.63.26              s16.lite.msu.edu s16\n");
   52:         print("The <TARGET /> file on your machine looks like it was \n".
   53: 	      "messed up due to a common bug with RedHat installations.\n".
   54: 	      "(This weird bug is RedHat's fault, not LON-CAPA's.)\n");
   55:         print("Please read the man pages about \"hosts\" and fix your\n".
   56: 	      "<TARGET /> file.\n");
   57:       }
   58:   }
   59: </perlscript>
   60: </file>
   61: <file>
   62: <target dist='default'>/var/lib/mysql/mysql.sock</target>
   63: <perlscript mode='fg'>
   64: unless
   65:     (-e '<TARGET />') # Does file exist?
   66:   {
   67:     print("**** ERROR **** Missing <TARGET />\n");
   68:   }
   69: <!-- Commented out by Matthew since MySQL insists on doing things its own way
   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('**** WARNING **** <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('**** WARNING **** '.
   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('**** WARNING **** '.
  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:  -->
  110: </perlscript>
  111: </file>
  112: <file>
  113: <target dist='default'>/etc/httpd/conf/loncapa.conf</target>
  114: <target dist='sles10 suse10.1'>/etc/apache2/loncapa.conf</target>
  115: <perlscript mode='fg'>
  116: open IN, "&lt;<TARGET />";
  117: my $hbug=-1;
  118: my $dbug=-1;
  119: while (&lt;IN&gt;) {
  120:  if (/PerlSetVar\s+lonHostID\s+(\S+)/) {
  121:   my $v=$1;
  122:   $hbug=0;
  123:   $hbug=1 if $v=~/\W/;
  124:   $hbug=1 if $v=~/\_/;
  125:  }
  126:  if (/PerlSetVar\s+lonDefDomain\s+(\S+)/) {
  127:   my $v=$1;
  128:   $dbug=0;
  129:   $dbug=1 if $v=~/\W/;
  130:   $dbug=1 if $v=~/\_/;
  131:   # Avoid namespace conflicts under the web server's DocumentRoot.
  132:   my @badnames=('raw','userfiles','priv','adm','uploaded');
  133:   foreach my $bad (@badnames) {
  134:    $dbug=1 if $v eq $bad;
  135:   }
  136:  }
  137: }
  138: if ($hbug) {
  139:   print "**** ERROR **** <TARGET /> has invalid lonHostID\n";
  140: }
  141: if ($dbug) {
  142:   print "**** ERROR **** <TARGET /> has invalid lonDefDomain\n";
  143: }
  144: </perlscript>
  145: </file>
  146: <file>
  147: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
  148: open IN, "&lt;<TARGET />";
  149: my $rbug=0;
  150: my $dbug=0;
  151: my $sbug=0;
  152: my $fbug=0;
  153: my %line;
  154: my $line=0;
  155: while (&lt;IN&gt;) {
  156:  $line++;
  157:  next if (/^(\#|\s*$)/);
  158:  if (/\S/) {
  159:   if (/\r/) {              $rbug=1; push(@{$line{'r'}},$line); }
  160:   my @a=split(/\:/,$_);
  161:   if ($a[0]=~/[^\w\-.]/ ||
  162:       $a[1]=~/[^\w\-.]/ ||
  163:       $a[0]=~/\_/       ||
  164:       $a[1]=~/\_/      ) { $dbug=1; push(@{$line{'d'}},$line); }
  165:   if (@a<4 || @a>5) {      $fbug=1; push(@{$line{'f'}},$line); }
  166:   my $expr='\s.+$';
  167:   if ($a[0] =~ /$expr/ ||
  168:       $a[1] =~ /$expr/ ||
  169:       $a[2] =~ /$expr/ ||
  170:       $a[3] =~ /$expr/ ) { $sbug=1; push(@{$line{'s'}},$line); }
  171: ;
  172:  }
  173: }
  174: close IN;
  175: if ($rbug) {
  176:   print "**** ERROR **** <TARGET /> is DOS-formatted (lines ".join(', ',@{$line{'r'}}).")\n";
  177: }
  178: if ($dbug) {
  179:   print "**** ERROR **** <TARGET /> has invalid host id or domain id (lines ".join(', ',@{$line{'d'}}).")\n";
  180: }
  181: if ($fbug) {
  182:   print "**** ERROR **** <TARGET /> is lacking 4 or 5 columns for every row (lines ".join(', ',@{$line{'f'}}).")\n";
  183: }
  184: if ($sbug) {
  185:   print "**** ERROR **** <TARGET /> has illegal whitespace character (lines ".join(', ',@{$line{'s'}}).")\n";
  186: }
  187: </file>
  188: <file>
  189: <target dist='default'>/home/httpd/lonTabs/spare.tab</target>
  190: open IN, "&lt;<TARGET />";
  191: my $rbug=0;
  192: my $dbug=0;
  193: my $sbug=0;
  194: while (my $line = &lt;IN&gt;) {
  195:  if ($line =~ /\S/) {
  196:   $rbug=1 if $line=~/\r/;
  197:   if ($line =~ /\W.*\n/) {
  198: 	$dbug=$line if ($line !~/\w:(?:primary|default)$/);
  199:   }
  200:   $dbug=$line if $line=~/\_/;
  201:   $sbug=1 if $line=~/\s.+$/;
  202:  }
  203: }
  204: close IN;
  205: if ($rbug) {
  206:   print "**** ERROR **** <TARGET /> is DOS-formatted\n";
  207: }
  208: if ($dbug) {
  209:   print "**** ERROR **** <TARGET /> has invalid host id ($dbug)\n";
  210: }
  211: if ($sbug) {
  212:   print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
  213: }
  214: </file>
  215: </files>
  216: </piml>

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