Annotation of doc/loncapafiles/sanitycheck.piml, revision 1.8
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: <!-- Scott Harrison -->
5:
1.8 ! matthew 6: <!-- $Id: sanitycheck.piml,v 1.7 2002/09/22 08:32:46 harris41 Exp $ -->
1.1 harris41 7:
8: <!--
9:
10: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
11:
12: LON-CAPA is free software; you can redistribute it and/or modify
13: it under the terms of the GNU General Public License as published by
14: the Free Software Foundation; either version 2 of the License, or
15: (at your option) any later version.
16:
17: LON-CAPA is distributed in the hope that it will be useful,
18: but WITHOUT ANY WARRANTY; without even the implied warranty of
19: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: GNU General Public License for more details.
21:
22: You should have received a copy of the GNU General Public License
23: along with LON-CAPA; if not, write to the Free Software
24: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25:
26: /home/httpd/html/adm/gpl.txt
27:
28: http://www.lon-capa.org/
29:
30: -->
31:
32: <piml>
33: <targetroot>/</targetroot>
34: <files>
1.6 harris41 35: <file>
36: <target dist='default'>/var/lib/mysql/mysql.sock</target>
1.8 ! matthew 37: <target dist='redhat7.2 redhat7.3'>/tmp/mysql.sock</target>
1.6 harris41 38: <perlscript mode='fg'>
39: unless
40: (-e '<TARGET />') # Does file exist?
41: {
42: print("**** ERROR **** Missing <TARGET />\n");
43: }
44: else # It exists, so look at the file metadata more closely.
45: {
46: my @s = stat('<TARGET />');
47: my $uid = $s[4];
48: my $mode = $s[2];
49: my $web_uid = getpwnam('www');
50: my $smode = sprintf("%04o",$mode & 07777);
51:
52: if ($uid ne $web_uid) # If file owned by someone else other than www.
53: {
54: print('**** ERROR **** <TARGET /> should be owned by'.
55: ' www.'."\n".'Try these commands to make things right:'."\n".
1.8 ! matthew 56: 'chown www:www <TARGET />'."\n".
! 57: 'chmod a-rwx,u+rwx <TARGET />'."\n");
1.6 harris41 58: }
1.7 harris41 59: else # Check permissions on the file to make sure it is private to www.
1.6 harris41 60: {
61: $smode =~ /^.(.)..$/;
62: my $wflag = $1;
1.7 harris41 63: if ($wflag != 7) # Can www use this socket? (Hope so!)
1.6 harris41 64: {
65: print('**** ERROR **** '.
66: '<TARGET /> should be user "rwx" (by'.
67: ' www).'."\n".'Try these commands to make things right:'."\n".
1.8 ! matthew 68: 'chown www:www <TARGET />'."\n".
! 69: 'chmod a-rwx,u+rwx <TARGET />'."\n");
1.6 harris41 70: }
71: $smode=~/^..(..)$/;
72: $wflag=$1;
1.7 harris41 73: if ($wflag ne "00") # Can others use this socket? (Hope not!)
1.6 harris41 74: {
75: print('**** ERROR **** '.
76: '<TARGET /> should not be group or everybody accessible'.
77: '.'."\n".'Try these commands to make things right:'."\n".
1.8 ! matthew 78: 'chown www:www <TARGET />'."\n".
! 79: 'chmod a-rwx,u+rwx <TARGET />'."\n");
1.6 harris41 80: }
81: }
82: }
83: </perlscript>
84: </file>
1.1 harris41 85: <file>
86: <target dist='default'>/etc/httpd/conf/loncapa.conf</target>
87: <perlscript mode='fg'>
88: open IN, "<<TARGET />";
89: my $hbug=-1;
90: my $dbug=-1;
91: while (<IN>) {
92: if (/PerlSetVar\s+lonHostID\s+(\S+)/) {
93: my $v=$1;
94: $hbug=0;
95: $hbug=1 if $v=~/\W/;
96: $hbug=1 if $v=~/\_/;
97: }
98: if (/PerlSetVar\s+lonDefDomain\s+(\S+)/) {
99: my $v=$1;
100: $dbug=0;
101: $dbug=1 if $v=~/\W/;
102: $dbug=1 if $v=~/\_/;
1.5 harris41 103: # Avoid namespace conflicts under the web server's DocumentRoot.
104: my @badnames=('raw','userfiles','priv','adm','uploaded');
105: foreach my $bad (@badnames) {
106: $dbug=1 if $v eq $bad;
107: }
1.1 harris41 108: }
109: }
110: if ($hbug) {
111: print "**** ERROR **** <TARGET /> has invalid lonHostID\n";
112: }
113: if ($dbug) {
114: print "**** ERROR **** <TARGET /> has invalid lonDefDomain\n";
115: }
116: </perlscript>
117: </file>
118: <file>
119: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
120: open IN, "<<TARGET />";
121: my $rbug=0;
122: my $dbug=0;
123: my $sbug=0;
124: my $fbug=0;
125: while (<IN>) {
126: if (/\S/) {
127: $rbug=1 if /\r/;
128: my @a=split(/\:/,$_);
129: $dbug=1 if $a[0]=~/\W/;
130: $dbug=1 if $a[0]=~/\_/;
131: $dbug=1 if $a[1]=~/\_/;
132: $dbug=1 if $a[1]=~/\W/;
1.3 albertel 133: $fbug=1 if (@a<5 || @a>6);
134: my $expr='\s.+$';
135: $sbug=1 if ($a[0] =~ /$expr/ ||
136: $a[1] =~ /$expr/ ||
137: $a[2] =~ /$expr/ ||
138: $a[3] =~ /$expr/ ||
139: $a[4] =~ /$expr/ )
140: ;
1.1 harris41 141: }
142: }
143: close IN;
144: if ($rbug) {
145: print "**** ERROR **** <TARGET /> is DOS-formatted\n";
146: }
147: if ($dbug) {
148: print "**** ERROR **** <TARGET /> has invalid host id or domain id\n";
149: }
150: if ($fbug) {
1.3 albertel 151: print "**** ERROR **** <TARGET /> is lacking 5 or 6 columns for every row\n";
1.1 harris41 152: }
153: if ($sbug) {
154: print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
155: }
156: </file>
157: <file>
158: <target dist='default'>/home/httpd/lonTabs/spare.tab</target>
159: open IN, "<<TARGET />";
160: my $rbug=0;
161: my $dbug=0;
162: my $sbug=0;
163: while (<IN>) {
164: if (/\S/) {
165: $rbug=1 if /\r/;
166: $dbug=1 if $_=~/\W.*\n$/;
167: $dbug=1 if $_=~/\_/;
168: $sbug=1 if /\s.+$/;
169: }
170: }
171: close IN;
172: if ($rbug) {
173: print "**** ERROR **** <TARGET /> is DOS-formatted\n";
174: }
175: if ($dbug) {
176: print "**** ERROR **** <TARGET /> has invalid host id\n";
177: }
178: if ($sbug) {
179: print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
180: }
181: </file>
182: </files>
183: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>