Annotation of doc/loncapafiles/sanitycheck.piml, revision 1.10
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.10 ! matthew 6: <!-- $Id: sanitycheck.piml,v 1.9 2002/11/26 15:05:19 matthew 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.9 matthew 37: <target dist='redhat7'>/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>) {
1.10 ! matthew 126: next if (/^(\#|\s*$)/);
1.1 harris41 127: if (/\S/) {
128: $rbug=1 if /\r/;
129: my @a=split(/\:/,$_);
130: $dbug=1 if $a[0]=~/\W/;
131: $dbug=1 if $a[0]=~/\_/;
132: $dbug=1 if $a[1]=~/\_/;
133: $dbug=1 if $a[1]=~/\W/;
1.3 albertel 134: $fbug=1 if (@a<5 || @a>6);
135: my $expr='\s.+$';
136: $sbug=1 if ($a[0] =~ /$expr/ ||
137: $a[1] =~ /$expr/ ||
138: $a[2] =~ /$expr/ ||
139: $a[3] =~ /$expr/ ||
140: $a[4] =~ /$expr/ )
141: ;
1.1 harris41 142: }
143: }
144: close IN;
145: if ($rbug) {
146: print "**** ERROR **** <TARGET /> is DOS-formatted\n";
147: }
148: if ($dbug) {
149: print "**** ERROR **** <TARGET /> has invalid host id or domain id\n";
150: }
151: if ($fbug) {
1.3 albertel 152: print "**** ERROR **** <TARGET /> is lacking 5 or 6 columns for every row\n";
1.1 harris41 153: }
154: if ($sbug) {
155: print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
156: }
157: </file>
158: <file>
159: <target dist='default'>/home/httpd/lonTabs/spare.tab</target>
160: open IN, "<<TARGET />";
161: my $rbug=0;
162: my $dbug=0;
163: my $sbug=0;
164: while (<IN>) {
165: if (/\S/) {
166: $rbug=1 if /\r/;
167: $dbug=1 if $_=~/\W.*\n$/;
168: $dbug=1 if $_=~/\_/;
169: $sbug=1 if /\s.+$/;
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\n";
178: }
179: if ($sbug) {
180: print "**** ERROR **** <TARGET /> has illegal whitespace character\n";
181: }
182: </file>
183: </files>
184: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>