Annotation of doc/loncapafiles/sanitycheck.piml, revision 1.7
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.7 ! harris41 6: <!-- $Id: sanitycheck.piml,v 1.6 2002/09/22 08:23:26 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>
37: <perlscript mode='fg'>
38: unless
39: (-e '<TARGET />') # Does file exist?
40: {
41: print("**** ERROR **** Missing <TARGET />\n");
42: }
43: else # It exists, so look at the file metadata more closely.
44: {
45: my @s = stat('<TARGET />');
46: my $uid = $s[4];
47: my $mode = $s[2];
48: my $web_uid = getpwnam('www');
49: my $smode = sprintf("%04o",$mode & 07777);
50:
51: if ($uid ne $web_uid) # If file owned by someone else other than www.
52: {
53: print('**** ERROR **** <TARGET /> should be owned by'.
54: ' www.'."\n".'Try these commands to make things right:'."\n".
55: 'chown www:www /var/lib/mysql/mysql.sock'."\n".
56: 'chmod a-rwx,u+rwx /var/lib/mysql/mysql.sock'."\n");
57: }
1.7 ! harris41 58: else # Check permissions on the file to make sure it is private to www.
1.6 harris41 59: {
60: $smode =~ /^.(.)..$/;
61: my $wflag = $1;
1.7 ! harris41 62: if ($wflag != 7) # Can www use this socket? (Hope so!)
1.6 harris41 63: {
64: print('**** ERROR **** '.
65: '<TARGET /> should be user "rwx" (by'.
66: ' www).'."\n".'Try these commands to make things right:'."\n".
67: 'chown www:www /var/lib/mysql/mysql.sock'."\n".
68: 'chmod a-rwx,u+rwx /var/lib/mysql/mysql.sock'."\n");
69: }
70: $smode=~/^..(..)$/;
71: $wflag=$1;
1.7 ! harris41 72: if ($wflag ne "00") # Can others use this socket? (Hope not!)
1.6 harris41 73: {
74: print('**** ERROR **** '.
75: '<TARGET /> should not be group or everybody accessible'.
76: '.'."\n".'Try these commands to make things right:'."\n".
77: 'chown www:www /var/lib/mysql/mysql.sock'."\n".
78: 'chmod a-rwx,u+rwx /var/lib/mysql/mysql.sock'."\n");
79: }
80: }
81: }
82: </perlscript>
83: </file>
1.1 harris41 84: <file>
85: <target dist='default'>/etc/httpd/conf/loncapa.conf</target>
86: <perlscript mode='fg'>
87: open IN, "<<TARGET />";
88: my $hbug=-1;
89: my $dbug=-1;
90: while (<IN>) {
91: if (/PerlSetVar\s+lonHostID\s+(\S+)/) {
92: my $v=$1;
93: $hbug=0;
94: $hbug=1 if $v=~/\W/;
95: $hbug=1 if $v=~/\_/;
96: }
97: if (/PerlSetVar\s+lonDefDomain\s+(\S+)/) {
98: my $v=$1;
99: $dbug=0;
100: $dbug=1 if $v=~/\W/;
101: $dbug=1 if $v=~/\_/;
1.5 harris41 102: # Avoid namespace conflicts under the web server's DocumentRoot.
103: my @badnames=('raw','userfiles','priv','adm','uploaded');
104: foreach my $bad (@badnames) {
105: $dbug=1 if $v eq $bad;
106: }
1.1 harris41 107: }
108: }
109: if ($hbug) {
110: print "**** ERROR **** <TARGET /> has invalid lonHostID\n";
111: }
112: if ($dbug) {
113: print "**** ERROR **** <TARGET /> has invalid lonDefDomain\n";
114: }
115: </perlscript>
116: </file>
117: <file>
118: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
119: open IN, "<<TARGET />";
120: my $rbug=0;
121: my $dbug=0;
122: my $sbug=0;
123: my $fbug=0;
124: while (<IN>) {
125: if (/\S/) {
126: $rbug=1 if /\r/;
127: my @a=split(/\:/,$_);
128: $dbug=1 if $a[0]=~/\W/;
129: $dbug=1 if $a[0]=~/\_/;
130: $dbug=1 if $a[1]=~/\_/;
131: $dbug=1 if $a[1]=~/\W/;
1.3 albertel 132: $fbug=1 if (@a<5 || @a>6);
133: my $expr='\s.+$';
134: $sbug=1 if ($a[0] =~ /$expr/ ||
135: $a[1] =~ /$expr/ ||
136: $a[2] =~ /$expr/ ||
137: $a[3] =~ /$expr/ ||
138: $a[4] =~ /$expr/ )
139: ;
1.1 harris41 140: }
141: }
142: close IN;
143: if ($rbug) {
144: print "**** ERROR **** <TARGET /> is DOS-formatted\n";
145: }
146: if ($dbug) {
147: print "**** ERROR **** <TARGET /> has invalid host id or domain id\n";
148: }
149: if ($fbug) {
1.3 albertel 150: print "**** ERROR **** <TARGET /> is lacking 5 or 6 columns for every row\n";
1.1 harris41 151: }
152: if ($sbug) {
153: print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
154: }
155: </file>
156: <file>
157: <target dist='default'>/home/httpd/lonTabs/spare.tab</target>
158: open IN, "<<TARGET />";
159: my $rbug=0;
160: my $dbug=0;
161: my $sbug=0;
162: while (<IN>) {
163: if (/\S/) {
164: $rbug=1 if /\r/;
165: $dbug=1 if $_=~/\W.*\n$/;
166: $dbug=1 if $_=~/\_/;
167: $sbug=1 if /\s.+$/;
168: }
169: }
170: close IN;
171: if ($rbug) {
172: print "**** ERROR **** <TARGET /> is DOS-formatted\n";
173: }
174: if ($dbug) {
175: print "**** ERROR **** <TARGET /> has invalid host id\n";
176: }
177: if ($sbug) {
178: print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
179: }
180: </file>
181: </files>
182: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>