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

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

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