File:  [LON-CAPA] / doc / loncapafiles / sanitycheck.piml
Revision 1.51: download - view: text, annotated - select for diffs
Thu Jun 20 04:04:55 2024 UTC (5 months ago) by raeburn
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_5_msu, version_2_11_5, HEAD
- Support Debian 10 (buster) and Debian 11 (bullseye) on amd64.

<!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN" 
	"http://lpml.sourceforge.net/DTD/piml.dtd">
<!-- sanitycheck.piml -->

<!-- $Id: sanitycheck.piml,v 1.51 2024/06/20 04:04:55 raeburn Exp $ -->

<!--

This file is part of the LearningOnline Network with CAPA (LON-CAPA).

LON-CAPA is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

LON-CAPA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with LON-CAPA; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

/home/httpd/html/adm/gpl.txt

http://www.lon-capa.org/

-->

<piml>
<targetroot>/</targetroot>
<files>
<file>
<target dist='default'>/etc/hosts</target>
<perlscript mode='fg'>
unless
    (-e '<TARGET />') # Does file exist?
  {
    print("**** ERROR **** Missing <TARGET />\n");
  }
else
  {
    my $numentries = `grep -v '^#' <TARGET /> | grep -c '[[:alpha:]]'`;
    if ($numentries == 1)
      {
        print("**** ERROR **** Malformatted <TARGET />\n");
        print("<TARGET /> typically should have at least two entries, ".
	      "e.g.:\n");
	print("127.0.0.1               localhost.localdomain localhost\n");
	print("35.8.63.26              s16.lite.msu.edu s16\n");
        print("The <TARGET /> file on your machine looks like it was \n".
	      "messed up due to a common bug with RedHat installations.\n".
	      "(This weird bug is RedHat's fault, not LON-CAPA's.)\n");
        print("Please read the man pages about \"hosts\" and fix your\n".
	      "<TARGET /> file.\n");
      }
  }
</perlscript>
</file>
<file>
<target dist='default'>/var/lib/mysql/mysql.sock</target>
<target dist='suse11.2 suse11.3 suse11.4 suse12.1 suse12.2 suse12.3 suse13.1 suse13.2 sles12 sles15'>/var/run/mysql/mysql.sock</target>
<target dist='debian5 debian6 debian10 debian11 debian12 ubuntu6 ubuntu8 ubuntu10 ubuntu12 ubuntu14 ubuntu16 ubuntu18 ubuntu20 ubuntu22 ubuntu24'>/var/run/mysqld/mysqld.sock</target>
<perlscript mode='fg'>
unless
    (-e '<TARGET />') # Does file exist?
  {
    print("**** ERROR **** Missing <TARGET />\n");
  }
<!-- Commented out by Matthew since MySQL insists on doing things its own way
else # It exists, so look at the file metadata more closely.
  {
    my @s = stat('<TARGET />');
    my $uid = $s[4];
    my $mode = $s[2];
    my $web_uid = getpwnam('www');
    my $smode = sprintf("%04o",$mode & 07777);

    if ($uid ne $web_uid) # If file owned by someone else other than www.
      {
	print('**** WARNING **** <TARGET /> should be owned by'.
	      ' www.'."\n".'Try these commands to make things right:'."\n".
	      'chown www:www <TARGET />'."\n".
	      'chmod a-rwx,u+rwx <TARGET />'."\n");
      }
    else # Check permissions on the file to make sure it is private to www.
      {
	$smode =~ /^.(.)..$/;
	my $wflag = $1;
	if ($wflag != 7) # Can www use this socket?  (Hope so!)
	  {
	    print('**** WARNING **** '.
	      '<TARGET /> should be user "rwx" (by'.
	      ' www).'."\n".'Try these commands to make things right:'."\n".
	      'chown www:www <TARGET />'."\n".
	      'chmod a-rwx,u+rwx <TARGET />'."\n");
	  }
	$smode=~/^..(..)$/;
	$wflag=$1;
	if ($wflag ne "00") # Can others use this socket?  (Hope not!)
	  {
	    print('**** WARNING **** '.
	      '<TARGET /> should not be group or everybody accessible'.
	      '.'."\n".'Try these commands to make things right:'."\n".
	      'chown www:www <TARGET />'."\n".
	      'chmod a-rwx,u+rwx <TARGET />'."\n");
	  }
      }
  }
 -->
</perlscript>
</file>
<file>
<target dist='default'>/etc/httpd/conf/loncapa.conf</target>
<target dist='sles10 sles11 sles12 sles15 suse10.1 suse10.2 suse10.3 suse11.1 suse11.2 suse11.3 suse11.4 suse12.1 suse12.2 suse12.3 suse13.1 suse13.2 debian5 debian6 debian10 debian11 debian12 ubuntu6 ubuntu8 ubuntu10 ubuntu12 ubuntu14 ubuntu16 ubuntu18 ubuntu20 ubuntu22 ubuntu24'>/etc/apache2/loncapa.conf</target>
<perlscript mode='fg'>
open IN, "&lt;<TARGET />";
my $hbug=-1;
my $dbug=-1;
while (&lt;IN&gt;) {
 if (/PerlSetVar\s+lonHostID\s+(\S+)/) {
  my $v=$1;
  $hbug=0;
  $hbug=1 if $v=~/[^\w.\-]/;
  $hbug=1 if $v=~/_/;
 }
 if (/PerlSetVar\s+lonDefDomain\s+(\S+)/) {
  my $v=$1;
  $dbug=0;
  $dbug=1 if $v=~/[^\w.\-]/;
  $dbug=1 if $v=~/_/;
  # Avoid namespace conflicts under the web server's DocumentRoot.
  my @badnames=('raw','userfiles','priv','adm','uploaded');
  foreach my $bad (@badnames) {
   $dbug=1 if $v eq $bad;
  }
 }
}
if ($hbug) {
  print "**** ERROR **** <TARGET /> has invalid lonHostID\n";
}
if ($dbug) {
  print "**** ERROR **** <TARGET /> has invalid lonDefDomain\n";
}
</perlscript>
</file>
<file>
<target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
open IN, "&lt;<TARGET />";
my $rbug=0;
my $dbug=0;
my $sbug=0;
my $fbug=0;
my %line;
my $line=0;
while (my $l = &lt;IN&gt;) {
 $line++;
 next if ($l=~/^(\#|\s*$)/);
 if ($l=~/^\^/) {
  if ($l !~ /^\^[\w.\-]/) {
    $dns_bug = 1;
    push(@{$line{'dns'}},$line);
  }
 } elsif ($l=~/\S/) {
  if ($l=~/\r/) {              $rbug=1; push(@{$line{'r'}},$line); }
  my @a=split(/:/,$l);
  if ($a[0]=~/[^\w\-.]/ ||
      $a[1]=~/[^\w\-.]/ ||
      $a[0]=~/\_/       ||
      $a[1]=~/\_/      ) { $dbug=1; push(@{$line{'d'}},$line); }
  if (@a<6 || @a>6) {      $fbug=1; push(@{$line{'f'}},$line); }
  my $expr='\s.+$';
  if ($a[0] =~ /$expr/ ||
      $a[1] =~ /$expr/ ||
      $a[2] =~ /$expr/ ||
      $a[3] =~ /$expr/ ) { $sbug=1; push(@{$line{'s'}},$line); }
;
 }
}
close IN;
if ($rbug) {
  print "**** ERROR **** <TARGET /> is DOS-formatted (lines ".join(', ',@{$line{'r'}}).")\n";
}
if ($dbug) {
  print "**** ERROR **** <TARGET /> has invalid host id or domain id (lines ".join(', ',@{$line{'d'}}).")\n";
}
if ($fbug) {
  print "**** ERROR **** <TARGET /> is lacking 6 columns for every row (lines ".join(', ',@{$line{'f'}}).")\n";
}
if ($sbug) {
  print "**** ERROR **** <TARGET /> has illegal whitespace character (lines ".join(', ',@{$line{'s'}}).")\n";
}
if ($dns_bug) {
  print "**** ERROR **** <TARGET /> host.tab server entry has characters (lines ".join(', ',@{$line{'dns'}}).")\n";
}
</file>
<file>
<target dist='default'>/home/httpd/lonTabs/spare.tab</target>
open IN, "&lt;<TARGET />";
my $rbug=0;
my $dbug=0;
my $sbug=0;
while (my $line = &lt;IN&gt;) {
 if ($line =~ /\S/) {
  $rbug=1 if $line=~/\r/;
  if ($line =~ /\W.*\n/) {
	$dbug=$line if ($line !~/\w:(?:primary|default)$/);
  }
  $dbug=$line if $line=~/\_/;
  $sbug=1 if $line=~/\s.+$/;
 }
}
close IN;
if ($rbug) {
  print "**** ERROR **** <TARGET /> is DOS-formatted\n";
}
if ($dbug) {
  print "**** ERROR **** <TARGET /> has invalid host id ($dbug)\n";
}
if ($sbug) {
  print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
}
</file>
</files>
</piml>

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