File:  [LON-CAPA] / doc / loncapafiles / sanitycheck.piml
Revision 1.29: download - view: text, annotated - select for diffs
Tue Dec 29 07:04:38 2009 UTC (14 years, 4 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Support for SuSE 11.2.

    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.29 2009/12/29 07:04:38 raeburn 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: <target dist='debian5 ubuntu6 ubuntu8'>/var/run/mysqld/mysqld.sock</target>
   64: <perlscript mode='fg'>
   65: unless
   66:     (-e '<TARGET />') # Does file exist?
   67:   {
   68:     print("**** ERROR **** Missing <TARGET />\n");
   69:   }
   70: <!-- Commented out by Matthew since MySQL insists on doing things its own way
   71: else # It exists, so look at the file metadata more closely.
   72:   {
   73:     my @s = stat('<TARGET />');
   74:     my $uid = $s[4];
   75:     my $mode = $s[2];
   76:     my $web_uid = getpwnam('www');
   77:     my $smode = sprintf("%04o",$mode & 07777);
   78: 
   79:     if ($uid ne $web_uid) # If file owned by someone else other than www.
   80:       {
   81: 	print('**** WARNING **** <TARGET /> should be owned by'.
   82: 	      ' www.'."\n".'Try these commands to make things right:'."\n".
   83: 	      'chown www:www <TARGET />'."\n".
   84: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
   85:       }
   86:     else # Check permissions on the file to make sure it is private to www.
   87:       {
   88: 	$smode =~ /^.(.)..$/;
   89: 	my $wflag = $1;
   90: 	if ($wflag != 7) # Can www use this socket?  (Hope so!)
   91: 	  {
   92: 	    print('**** WARNING **** '.
   93: 	      '<TARGET /> should be user "rwx" (by'.
   94: 	      ' www).'."\n".'Try these commands to make things right:'."\n".
   95: 	      'chown www:www <TARGET />'."\n".
   96: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
   97: 	  }
   98: 	$smode=~/^..(..)$/;
   99: 	$wflag=$1;
  100: 	if ($wflag ne "00") # Can others use this socket?  (Hope not!)
  101: 	  {
  102: 	    print('**** WARNING **** '.
  103: 	      '<TARGET /> should not be group or everybody accessible'.
  104: 	      '.'."\n".'Try these commands to make things right:'."\n".
  105: 	      'chown www:www <TARGET />'."\n".
  106: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
  107: 	  }
  108:       }
  109:   }
  110:  -->
  111: </perlscript>
  112: </file>
  113: <file>
  114: <target dist='default'>/etc/httpd/conf/loncapa.conf</target>
  115: <target dist='sles10 suse10.1 suse10.2 suse10.3 suse11.1 susee11.2 debian5 ubuntu6 ubuntu8'>/etc/apache2/loncapa.conf</target>
  116: <perlscript mode='fg'>
  117: open IN, "&lt;<TARGET />";
  118: my $hbug=-1;
  119: my $dbug=-1;
  120: while (&lt;IN&gt;) {
  121:  if (/PerlSetVar\s+lonHostID\s+(\S+)/) {
  122:   my $v=$1;
  123:   $hbug=0;
  124:   $hbug=1 if $v=~/[^\w.\-]/;
  125:   $hbug=1 if $v=~/_/;
  126:  }
  127:  if (/PerlSetVar\s+lonDefDomain\s+(\S+)/) {
  128:   my $v=$1;
  129:   $dbug=0;
  130:   $dbug=1 if $v=~/[^\w.\-]/;
  131:   $dbug=1 if $v=~/_/;
  132:   # Avoid namespace conflicts under the web server's DocumentRoot.
  133:   my @badnames=('raw','userfiles','priv','adm','uploaded');
  134:   foreach my $bad (@badnames) {
  135:    $dbug=1 if $v eq $bad;
  136:   }
  137:  }
  138: }
  139: if ($hbug) {
  140:   print "**** ERROR **** <TARGET /> has invalid lonHostID\n";
  141: }
  142: if ($dbug) {
  143:   print "**** ERROR **** <TARGET /> has invalid lonDefDomain\n";
  144: }
  145: </perlscript>
  146: </file>
  147: <file>
  148: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
  149: open IN, "&lt;<TARGET />";
  150: my $rbug=0;
  151: my $dbug=0;
  152: my $sbug=0;
  153: my $fbug=0;
  154: my %line;
  155: my $line=0;
  156: while (my $l = &lt;IN&gt;) {
  157:  $line++;
  158:  next if ($l=~/^(\#|\s*$)/);
  159:  if ($l=~/^\^/) {
  160:   if ($l !~ /^\^[\w.\-]/) {
  161:     $dns_bug = 1;
  162:     push(@{$line{'dns'}},$line);
  163:   }
  164:  } elsif ($l=~/\S/) {
  165:   if ($l=~/\r/) {              $rbug=1; push(@{$line{'r'}},$line); }
  166:   my @a=split(/:/,$l);
  167:   if ($a[0]=~/[^\w\-.]/ ||
  168:       $a[1]=~/[^\w\-.]/ ||
  169:       $a[0]=~/\_/       ||
  170:       $a[1]=~/\_/      ) { $dbug=1; push(@{$line{'d'}},$line); }
  171:   if (@a<4 || @a>5) {      $fbug=1; push(@{$line{'f'}},$line); }
  172:   my $expr='\s.+$';
  173:   if ($a[0] =~ /$expr/ ||
  174:       $a[1] =~ /$expr/ ||
  175:       $a[2] =~ /$expr/ ||
  176:       $a[3] =~ /$expr/ ) { $sbug=1; push(@{$line{'s'}},$line); }
  177: ;
  178:  }
  179: }
  180: close IN;
  181: if ($rbug) {
  182:   print "**** ERROR **** <TARGET /> is DOS-formatted (lines ".join(', ',@{$line{'r'}}).")\n";
  183: }
  184: if ($dbug) {
  185:   print "**** ERROR **** <TARGET /> has invalid host id or domain id (lines ".join(', ',@{$line{'d'}}).")\n";
  186: }
  187: if ($fbug) {
  188:   print "**** ERROR **** <TARGET /> is lacking 4 or 5 columns for every row (lines ".join(', ',@{$line{'f'}}).")\n";
  189: }
  190: if ($sbug) {
  191:   print "**** ERROR **** <TARGET /> has illegal whitespace character (lines ".join(', ',@{$line{'s'}}).")\n";
  192: }
  193: if ($dns_bug) {
  194:   print "**** ERROR **** <TARGET /> host.tab server entry has characters (lines ".join(', ',@{$line{'dns'}}).")\n";
  195: }
  196: </file>
  197: <file>
  198: <target dist='default'>/home/httpd/lonTabs/spare.tab</target>
  199: open IN, "&lt;<TARGET />";
  200: my $rbug=0;
  201: my $dbug=0;
  202: my $sbug=0;
  203: while (my $line = &lt;IN&gt;) {
  204:  if ($line =~ /\S/) {
  205:   $rbug=1 if $line=~/\r/;
  206:   if ($line =~ /\W.*\n/) {
  207: 	$dbug=$line if ($line !~/\w:(?:primary|default)$/);
  208:   }
  209:   $dbug=$line if $line=~/\_/;
  210:   $sbug=1 if $line=~/\s.+$/;
  211:  }
  212: }
  213: close IN;
  214: if ($rbug) {
  215:   print "**** ERROR **** <TARGET /> is DOS-formatted\n";
  216: }
  217: if ($dbug) {
  218:   print "**** ERROR **** <TARGET /> has invalid host id ($dbug)\n";
  219: }
  220: if ($sbug) {
  221:   print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
  222: }
  223: </file>
  224: </files>
  225: </piml>

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