Annotation of doc/loncapafiles/sanitycheck.piml, revision 1.13

1.4       harris41    1: <!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN" 
                      2: 	"http://lpml.sourceforge.net/DTD/piml.dtd">
1.1       harris41    3: <!-- sanitycheck.piml -->
                      4: 
1.13    ! harris41    5: <!-- $Id: sanitycheck.piml,v 1.12 2003/01/07 21:12:54 harris41 Exp $ -->
1.1       harris41    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>
1.12      harris41   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>
1.6       harris41   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: else # It exists, so look at the file metadata more closely.
                     70:   {
                     71:     my @s = stat('<TARGET />');
                     72:     my $uid = $s[4];
                     73:     my $mode = $s[2];
                     74:     my $web_uid = getpwnam('www');
                     75:     my $smode = sprintf("%04o",$mode & 07777);
                     76: 
                     77:     if ($uid ne $web_uid) # If file owned by someone else other than www.
                     78:       {
                     79: 	print('**** ERROR **** <TARGET /> should be owned by'.
                     80: 	      ' www.'."\n".'Try these commands to make things right:'."\n".
1.8       matthew    81: 	      'chown www:www <TARGET />'."\n".
                     82: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
1.6       harris41   83:       }
1.7       harris41   84:     else # Check permissions on the file to make sure it is private to www.
1.6       harris41   85:       {
                     86: 	$smode =~ /^.(.)..$/;
                     87: 	my $wflag = $1;
1.7       harris41   88: 	if ($wflag != 7) # Can www use this socket?  (Hope so!)
1.6       harris41   89: 	  {
                     90: 	    print('**** ERROR **** '.
                     91: 	      '<TARGET /> should be user "rwx" (by'.
                     92: 	      ' www).'."\n".'Try these commands to make things right:'."\n".
1.8       matthew    93: 	      'chown www:www <TARGET />'."\n".
                     94: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
1.6       harris41   95: 	  }
                     96: 	$smode=~/^..(..)$/;
                     97: 	$wflag=$1;
1.7       harris41   98: 	if ($wflag ne "00") # Can others use this socket?  (Hope not!)
1.6       harris41   99: 	  {
                    100: 	    print('**** ERROR **** '.
                    101: 	      '<TARGET /> should not be group or everybody accessible'.
                    102: 	      '.'."\n".'Try these commands to make things right:'."\n".
1.8       matthew   103: 	      'chown www:www <TARGET />'."\n".
                    104: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
1.6       harris41  105: 	  }
                    106:       }
                    107:   }
                    108: </perlscript>
                    109: </file>
1.1       harris41  110: <file>
                    111: <target dist='default'>/etc/httpd/conf/loncapa.conf</target>
                    112: <perlscript mode='fg'>
                    113: open IN, "&lt;<TARGET />";
                    114: my $hbug=-1;
                    115: my $dbug=-1;
                    116: while (&lt;IN&gt;) {
                    117:  if (/PerlSetVar\s+lonHostID\s+(\S+)/) {
                    118:   my $v=$1;
                    119:   $hbug=0;
                    120:   $hbug=1 if $v=~/\W/;
                    121:   $hbug=1 if $v=~/\_/;
                    122:  }
                    123:  if (/PerlSetVar\s+lonDefDomain\s+(\S+)/) {
                    124:   my $v=$1;
                    125:   $dbug=0;
                    126:   $dbug=1 if $v=~/\W/;
                    127:   $dbug=1 if $v=~/\_/;
1.5       harris41  128:   # Avoid namespace conflicts under the web server's DocumentRoot.
                    129:   my @badnames=('raw','userfiles','priv','adm','uploaded');
                    130:   foreach my $bad (@badnames) {
                    131:    $dbug=1 if $v eq $bad;
                    132:   }
1.1       harris41  133:  }
                    134: }
                    135: if ($hbug) {
                    136:   print "**** ERROR **** <TARGET /> has invalid lonHostID\n";
                    137: }
                    138: if ($dbug) {
                    139:   print "**** ERROR **** <TARGET /> has invalid lonDefDomain\n";
                    140: }
                    141: </perlscript>
                    142: </file>
                    143: <file>
                    144: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
                    145: open IN, "&lt;<TARGET />";
                    146: my $rbug=0;
                    147: my $dbug=0;
                    148: my $sbug=0;
                    149: my $fbug=0;
                    150: while (&lt;IN&gt;) {
1.10      matthew   151:  next if (/^(\#|\s*$)/);
1.1       harris41  152:  if (/\S/) {
                    153:   $rbug=1 if /\r/;
                    154:   my @a=split(/\:/,$_);
                    155:   $dbug=1 if $a[0]=~/\W/;
                    156:   $dbug=1 if $a[0]=~/\_/;
                    157:   $dbug=1 if $a[1]=~/\_/;
                    158:   $dbug=1 if $a[1]=~/\W/;
1.3       albertel  159:   $fbug=1 if (@a<5 || @a>6);
                    160:   my $expr='\s.+$';
                    161:   $sbug=1 if ($a[0] =~ /$expr/ ||
                    162: 	      $a[1] =~ /$expr/ ||
                    163: 	      $a[2] =~ /$expr/ ||
                    164: 	      $a[3] =~ /$expr/ ||
                    165: 	      $a[4] =~ /$expr/ )
                    166: ;
1.1       harris41  167:  }
                    168: }
                    169: close IN;
                    170: if ($rbug) {
                    171:   print "**** ERROR **** <TARGET /> is DOS-formatted\n";
                    172: }
                    173: if ($dbug) {
                    174:   print "**** ERROR **** <TARGET /> has invalid host id or domain id\n";
                    175: }
                    176: if ($fbug) {
1.3       albertel  177:   print "**** ERROR **** <TARGET /> is lacking 5 or 6 columns for every row\n";
1.1       harris41  178: }
                    179: if ($sbug) {
                    180:   print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
                    181: }
                    182: </file>
                    183: <file>
                    184: <target dist='default'>/home/httpd/lonTabs/spare.tab</target>
                    185: open IN, "&lt;<TARGET />";
                    186: my $rbug=0;
                    187: my $dbug=0;
                    188: my $sbug=0;
                    189: while (&lt;IN&gt;) {
                    190:  if (/\S/) {
                    191:   $rbug=1 if /\r/;
                    192:   $dbug=1 if $_=~/\W.*\n$/;
                    193:   $dbug=1 if $_=~/\_/;
                    194:   $sbug=1 if /\s.+$/;
                    195:  }
                    196: }
                    197: close IN;
                    198: if ($rbug) {
                    199:   print "**** ERROR **** <TARGET /> is DOS-formatted\n";
                    200: }
                    201: if ($dbug) {
                    202:   print "**** ERROR **** <TARGET /> has invalid host id\n";
                    203: }
                    204: if ($sbug) {
                    205:   print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
                    206: }
                    207: </file>
                    208: </files>
                    209: </piml>

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