Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item12381: Replace "Web Server Environment" tab
The Foswiki 1.1.x "Web Server Enviroment" tab was replaced with the "Study Server" wizard, which has now been removed. Implement a %SERVERINFORMATION% macro and System.FoswikiServerInformation topic to provide similar functionality. The detailed information is only made available to users with access to the bin/configure tool.
- Loading branch information
Showing
4 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
%META:TOPICINFO{author="ProjectContributor" date="1422413722" format="1.1" version="1"}% | ||
%META:TOPICPARENT{name="InstallationGuide"}% | ||
|
||
---+!! Foswiki Server Information | ||
|
||
This topic lists the detailed server execution environment. As this is | ||
sensitive information, it is only available to users with access to Configure. | ||
|
||
---++ Foswiki information | ||
|
||
| Foswiki Version | %WIKIVERSION% | | ||
| Foswiki Release | %WIKIRELEASE% | | ||
| Foswiki Plugin API | %PLUGINVERSION% | | ||
|
||
See Also: PerlDependencyReport for details on the installed Perl CPAN modules and InstalledPlugins for diagnostics on the installed plugins. | ||
|
||
---++ General execution environment | ||
%SERVERINFORMATION{execution}% | ||
|
||
---++ Environment variables | ||
%SERVERINFORMATION{environment}% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
# See bottom of file for license and copyright information | ||
package Foswiki; | ||
|
||
# Detailed core and plugin dependency report - see | ||
# System.VarSERVERINFORMATION and System.FoswikiServerInformation | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use File::Spec; | ||
use Foswiki::Func; | ||
use Config; | ||
|
||
sub SERVERINFORMATION { | ||
my ( $this, $params ) = @_; | ||
my $authorized; | ||
my $session = $Foswiki::Plugins::SESSION; | ||
|
||
if ( defined $Foswiki::cfg{FeatureAccess}{Configure} | ||
&& length( $Foswiki::cfg{FeatureAccess}{Configure} ) ) | ||
{ | ||
foreach my $authuser ( | ||
split( /[,\s]/, $Foswiki::cfg{FeatureAccess}{Configure} ) ) | ||
{ | ||
if ( $session->{user} eq $authuser ) { | ||
$authorized = 1; | ||
last; | ||
} | ||
} | ||
} | ||
else { | ||
$authorized = Foswiki::Func::isAnAdmin(); | ||
} | ||
|
||
return | ||
"Server information is only accessible to authorized configure users." | ||
unless $authorized; | ||
|
||
my $report; | ||
if ( ( !defined $params->{_DEFAULT} ) | ||
|| $params->{_DEFAULT} eq 'environment' ) | ||
{ | ||
$report .= _report_environment(); | ||
} | ||
|
||
if ( ( !defined $params->{_DEFAULT} ) | ||
|| $params->{_DEFAULT} eq 'execution' ) | ||
{ | ||
$report .= _report_execution(); | ||
} | ||
|
||
return $report; | ||
} | ||
|
||
sub _report_environment { | ||
|
||
my $report = <<DONE; | ||
<noautolink> | ||
%TABLE{sort="off"}% | ||
| *Key* | *Value* | | ||
DONE | ||
|
||
my @cgivars = ( | ||
|
||
# CGI 'Standard' | ||
qw/AUTH_TYPE CONTENT_LENGTH CONTENT_TYPE GATEWAY_INTERFACE/, | ||
qw/PATH_INFO PATH_TRANSLATED QUERY_STRING REMOTE_ADDR/, | ||
qw/REMOTE_HOST REMOTE_IDENT REMOTE_USER REQUEST_METHOD/, | ||
qw/SCRIPT_NAME SERVER_NAME SERVER_PORT SERVER_PROTOCOL/, | ||
qw/SERVER_SOFTWARE/, | ||
|
||
# Apache/common extensions | ||
qw/DOCUMENT_ROOT REQUEST_URI SCRIPT_FILENAME/, | ||
qw/SCRIPT_URI SCRIPT_URL SERVER_ADDR SERVER_ADMIN SERVER_SIGNATURE/, | ||
qw/UNIQUE_ID /, | ||
|
||
# Foswiki Extensions | ||
grep( /^(?:FOSWIKI)_/, keys %ENV ), | ||
|
||
# Perl Environment | ||
grep( /^(?:PERL)/, keys %ENV ), | ||
|
||
# System temporary dirs | ||
qw/TEMP TMP TMPDIR/, | ||
|
||
# HTTP headers & SSL data | ||
grep( /^(?:HTTP|SSL)_/, keys %ENV ), | ||
|
||
# Other | ||
qw/PATH MOD_PERL MOD_PERL_API_VERSION/, | ||
); | ||
|
||
foreach my $key ( sort @cgivars ) { | ||
|
||
#foreach my $key ( sort keys %ENV ) { | ||
my $value = $ENV{$key}; | ||
my $decoded = ''; | ||
if ( $key eq 'HTTP_COOKIE' && $value ) { | ||
|
||
# url decode for readability | ||
#$value =~ s/%7C/ | /go; | ||
$value =~ s/%3D/=/go; | ||
} | ||
$value =~ s/\n/\\n/g if defined $value; | ||
$report .= | ||
"| $key | " . ( ( defined $value ) ? $value : '_undef_' ) . " |\n"; | ||
} | ||
|
||
$report .= '</noautolink>'; | ||
|
||
return $report; | ||
} | ||
|
||
sub _report_execution { | ||
|
||
my $report = <<DONE; | ||
<noautolink> | ||
%TABLE{sort="off"}% | ||
| *Area* | *Details* | | ||
DONE | ||
|
||
$report .= '| @INC Library Path | ' . join( '%BR%', @INC ) . " |\n"; | ||
|
||
# report the umask | ||
my $pUmask = sprintf( '%03o', umask() ); | ||
$report .= "| UMASK | $pUmask |\n"; | ||
|
||
my $uid = getlogin() || getpwuid($>); | ||
my $user = 'userid: ' . ( $uid ? "*$uid*" : 'unknown' ); | ||
$report .= "| User | $user _Your scripts are executing as this user_ |\n"; | ||
|
||
my @gids; | ||
eval { | ||
@gids = map { lc getgrgid($_) } split( ' ', $( ); | ||
}; | ||
if ($@) { | ||
@gids = | ||
( lc( qx(sh -c '( id -un ; id -gn) 2>/dev/null' 2>nul ) || 'n/a' ) ); | ||
} | ||
|
||
$report .= '| Groups | ' . join( ',', @gids ) . " |\n"; | ||
|
||
#OS | ||
my $n = | ||
ucfirst( lc( $Config::Config{osname} ) ) . ' ' | ||
. $Config::Config{osvers} . ' (' | ||
. $Config::Config{archname} . ')'; | ||
$report .= "| Operating system | $n |\n"; | ||
|
||
# Perl version and type | ||
if ( $] =~ /^(\d+)\.(\d{3})(\d{3})$/ ) { | ||
$n = sprintf( "%d.%d.%d", $1, $2, $3 ); | ||
} | ||
else { | ||
$n = $]; | ||
} | ||
$n .= " ($Config::Config{osname})"; | ||
$report .= "| Perl version | $n |\n"; | ||
$report .= | ||
"| File System | Case " | ||
. ( ( File::Spec->case_tolerant() ) ? 'Insensitive' : 'Sensitive' ) | ||
. " |\n"; | ||
$report .= '</noautolink>'; | ||
|
||
return $report; | ||
|
||
} | ||
|
||
1; | ||
|
||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2014-2015 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program 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. For | ||
more details read LICENSE in the root of this distribution. | ||
This program 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. | ||
As per the GPL, removal of this notice is prohibited. |