-
Notifications
You must be signed in to change notification settings - Fork 0
/
diagnostics.cgi
96 lines (82 loc) · 2.13 KB
/
diagnostics.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/perl
print("Content-Type: text/plain\n\n");
$ok = 1;
$cgi_ok = 1;
$beg_admin = "Or ask your server administrator/web hosting provider to install this.\n\n";
print("Testing CGI.pm availability.\n");
eval "use CGI;";
if ($@) {
print("Perl CGI module is not available; try\n".
"(Debian/Ubuntu) apt-get install libhttp-server-simple-perl\n".
"(Redhat/CentOS) yum install perl-cgi\n".
$beg_admin);
$ok = 0;
$cgi_ok = 0;
} else {
print("OK.\n\n");
}
print("Testing LWP.pm availability.\n");
eval "use LWP;";
if ($@) {
print("Perl LWP module is not available; try\n".
"(Debian/Ubuntu) apt-get install libwww-perl\n".
"(Redhat/CentOS) yum install perl-libwww-perl\n".
$beg_admin);
$ok = 0;
} else {
print("OK.\n\n");
}
if ($cgi_ok) {
print("Testing URI.pm availability.\n");
eval "use URI;";
if ($@) {
print("Perl URI module is not available; try\n".
"(Debian/Ubuntu) apt-get install liburi-perl\n".
"(Redhat/CentOS) yum install perl-URI\n".
$beg_admin);
$ok = 0;
} else {
print("OK.\n\n");
}
}
eval "use Cwd;";
if ($@) {
print("Perl Cwd module not available; something is is seriously messed up.\n");
$ok = 0;
}
print("Testing write permissions on cache directory.\n");
if (! -d "cache") {
$cwd = getcwd();
print("No cache directory available.\n".
"Expected cache directory here: $cwd/cache .\n\n");
$ok = 0;
} else {
$result = open($fh, ">cache/_test_");
if (!$result) {
print("Cannot write to cache directory: $!\n".
"Try this: chmod 777 cache\n\n");
$ok = 0;
} else {
unlink("cache/_test_");
print("OK.\n\n");
}
}
print("Checking CGI file permissions.\n");
@statdata = stat("avantify.cgi");
if ($#statdata == -1) {
$cwd = getcwd();
print("File not available: $cwd/avantify.cgi .");
$ok = 0;
} else {
$mode = $statdata[2] & 07777;
if (($mode & 0111) != 0111 || ($mode & 0022) != 0) {
printf("avantify.cgi has suspicious permissions %04o.\n".
"Try: chmod 755 avantify.cgi\n\n", $mode);
$ok = 0;
} else {
print("OK.\n\n");
}
}
if ($ok) {
print("Everything seems to be OK!\n");
}