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

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.17    ! raeburn     5: <!-- $Id: sanitycheck.piml,v 1.16 2005/03/01 03:40:47 albertel 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:   }
1.15      matthew    69: <!-- Commented out by Matthew since MySQL insists on doing things its own way
1.6       harris41   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:       {
1.14      matthew    80: 	print('**** WARNING **** <TARGET /> should be owned by'.
1.6       harris41   81: 	      ' www.'."\n".'Try these commands to make things right:'."\n".
1.8       matthew    82: 	      'chown www:www <TARGET />'."\n".
                     83: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
1.6       harris41   84:       }
1.7       harris41   85:     else # Check permissions on the file to make sure it is private to www.
1.6       harris41   86:       {
                     87: 	$smode =~ /^.(.)..$/;
                     88: 	my $wflag = $1;
1.7       harris41   89: 	if ($wflag != 7) # Can www use this socket?  (Hope so!)
1.6       harris41   90: 	  {
1.14      matthew    91: 	    print('**** WARNING **** '.
1.6       harris41   92: 	      '<TARGET /> should be user "rwx" (by'.
                     93: 	      ' www).'."\n".'Try these commands to make things right:'."\n".
1.8       matthew    94: 	      'chown www:www <TARGET />'."\n".
                     95: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
1.6       harris41   96: 	  }
                     97: 	$smode=~/^..(..)$/;
                     98: 	$wflag=$1;
1.7       harris41   99: 	if ($wflag ne "00") # Can others use this socket?  (Hope not!)
1.6       harris41  100: 	  {
1.14      matthew   101: 	    print('**** WARNING **** '.
1.6       harris41  102: 	      '<TARGET /> should not be group or everybody accessible'.
                    103: 	      '.'."\n".'Try these commands to make things right:'."\n".
1.8       matthew   104: 	      'chown www:www <TARGET />'."\n".
                    105: 	      'chmod a-rwx,u+rwx <TARGET />'."\n");
1.6       harris41  106: 	  }
                    107:       }
                    108:   }
1.15      matthew   109:  -->
1.6       harris41  110: </perlscript>
                    111: </file>
1.1       harris41  112: <file>
                    113: <target dist='default'>/etc/httpd/conf/loncapa.conf</target>
1.17    ! raeburn   114: <target dist='suse9.3 suse9.2 sles9'>/etc/httpd/loncapa.conf</target>
        !           115: <target dist='sles10'>/etc/apache2/loncapa.conf</target>
1.1       harris41  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=~/\_/;
1.5       harris41  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:   }
1.1       harris41  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: while (&lt;IN&gt;) {
1.10      matthew   155:  next if (/^(\#|\s*$)/);
1.1       harris41  156:  if (/\S/) {
                    157:   $rbug=1 if /\r/;
                    158:   my @a=split(/\:/,$_);
                    159:   $dbug=1 if $a[0]=~/\W/;
                    160:   $dbug=1 if $a[0]=~/\_/;
                    161:   $dbug=1 if $a[1]=~/\_/;
                    162:   $dbug=1 if $a[1]=~/\W/;
1.16      albertel  163:   $fbug=1 if (@a<4 || @a>5);
1.3       albertel  164:   my $expr='\s.+$';
                    165:   $sbug=1 if ($a[0] =~ /$expr/ ||
                    166: 	      $a[1] =~ /$expr/ ||
                    167: 	      $a[2] =~ /$expr/ ||
1.16      albertel  168: 	      $a[3] =~ /$expr/ )
1.3       albertel  169: ;
1.1       harris41  170:  }
                    171: }
                    172: close IN;
                    173: if ($rbug) {
                    174:   print "**** ERROR **** <TARGET /> is DOS-formatted\n";
                    175: }
                    176: if ($dbug) {
                    177:   print "**** ERROR **** <TARGET /> has invalid host id or domain id\n";
                    178: }
                    179: if ($fbug) {
1.16      albertel  180:   print "**** ERROR **** <TARGET /> is lacking 4 or 5 columns for every row\n";
1.1       harris41  181: }
                    182: if ($sbug) {
                    183:   print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
                    184: }
                    185: </file>
                    186: <file>
                    187: <target dist='default'>/home/httpd/lonTabs/spare.tab</target>
                    188: open IN, "&lt;<TARGET />";
                    189: my $rbug=0;
                    190: my $dbug=0;
                    191: my $sbug=0;
                    192: while (&lt;IN&gt;) {
                    193:  if (/\S/) {
                    194:   $rbug=1 if /\r/;
                    195:   $dbug=1 if $_=~/\W.*\n$/;
                    196:   $dbug=1 if $_=~/\_/;
                    197:   $sbug=1 if /\s.+$/;
                    198:  }
                    199: }
                    200: close IN;
                    201: if ($rbug) {
                    202:   print "**** ERROR **** <TARGET /> is DOS-formatted\n";
                    203: }
                    204: if ($dbug) {
                    205:   print "**** ERROR **** <TARGET /> has invalid host id\n";
                    206: }
                    207: if ($sbug) {
                    208:   print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
                    209: }
                    210: </file>
                    211: </files>
                    212: </piml>

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