# Blosxom debug tool # blosxomdebug # # Fletcher T. Penney # Version 1.1 - October 6, 2003 # # THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY OF ANY KIND. # USE AT YOUR OWN RISK! package blosxomdebug; use File::stat; my $debug = ""; # Placeholder for html content my $permissions = ""; my %debugfilelist = ( 'Blosxom Script' => $0, 'Data Directory' => $blosxom::datadir, 'Plugin Directory' => $blosxom::plugin_dir, 'Plugin State Directory' => $blosxom::plugin_state_dir, 'Static Directory' => $blosxom::static_dir); my $debugfile = ""; my $debugmode = ""; my $debugaction = ""; my @debugplugins = ""; sub debug { # Here is where we run diagnostics and generate html output add_header(); debug_files_directories(); debug_blosxom_settings(); debug_plugins(); debug_security(); $debug .= "

"; $blosxom::output = $debug . $blosxom::output; 1; } sub add_header { $debug = "

Debug Mode is Enabled

AKA Blosxom Made Easy

by Fletcher T. Penney

Remove the blosxomdebug file from your cgi directory to disable.
This information is designed to be useful in debugging problems with your blosxom installation.
It may be possible to make use of this information in attacking your web site, so it should not be active unless necessary.

For more information, or to leave comments or suggestions, visit my website."; } sub debug_files_directories { $debug .= "

File and Directory Paths and Permissions

\n \n"; foreach ( sort keys %debugfilelist) { $debug .= "$debugmode"; } else { $debug .= "\$static_dir" if ( $_ =~ /Static Directory/); $debug .= "\$datadir" if ( $_ =~ /Data Directory/); $debug .= "\$plugin_dir" if ( $_ =~ /Plugin Directory/); $debug .= "\$plugin_state_dir" if ( $_ =~ /Plugin State Directory/); $debug .= "N/A" if ( $_ =~ /Blosxom Script/); $debug .= "\n"; $debugaction = ""; } $debug .="
File/Directory Path Blosxom Variable Permissions Minimum Permissions Actions to Take
$_
$debugfilelist{$_}"; $debugfile = $debugfilelist{$_}; if (-e $debugfile) { $debugmode = sprintf("%4o",stat($debugfile)->mode); $debugmode =~ s/.*(\d\d\d)$/$1/; # Here we can verify certain permissions and color code errors if ($_ =~ /Blosxom Script/) { $debugmode = "$debugmode" if ( $debugmode !~ /^[5|7][5|7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[5|7][5|7]/); $debug .= "N/A"; } if ($_ =~ /Data Directory/) { $debugmode = "$debugmode" if ( $debugmode !~ /^[5-7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[5-7][5-7]/); $debug .= "\$datadir"; } if ($_ =~ /Plugin Directory/) { $debugmode = "$debugmode" if ( $debugmode !~ /^[5-7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[5-7][5-7]/); $debug .= "\$plugin_dir"; } if ($_ =~ /Plugin State Directory/) { $debugmode = "$debugmode" if ( $debugmode !~ /^[7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[7]/); $debug .= "\$plugin_state_dir"; } if ($_ =~ /Static Directory/) { $debugmode = "$debugmode" if ( $debugmode !~ /^[7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[7]/); $debug .= "\$static_dir"; } # If no error, then code green $debugmode = "$debugmode" if ( $debugmode !~ /font color/); $debugaction = "Fix the permissions on this file/folder" if ($debugmode !~ /(ff0000|00ff00)/); $debug .= "File Not Found"; $debugaction = "Create the file/folder specified in the Path column; OR
Correct the variable so that it points to the correct location"; } $debug .= "
"; $debug .= "550/555" if ($_ =~ /(Blosxom Script|Data Directory|Plugin Directory)/); $debug .= "770/777" if ($_ =~ /(Plugin State Directory|Static Directory)/); $debug .= "$debugaction
"; } sub debug_blosxom_settings { $debug .= "

Blosxom Settings

Article File Extension\$file_extension $blosxom::file_extension Comments
Blosxom URL \$url $blosxom::url The url to access this blog
Default Flavour \$default_flavour$blosxom::default_flavour
Blog Title \$blog_title $blosxom::blog_title
Depth \$depth$blosxom::depth
Max. Number of Entries \$num_entries$blosxom::num_entries
Show Future Entries? \$show_future_entries$blosxom::show_future_entries
Generate Static Entries? \$static_entries$blosxom::static_entries
Static Flavours \@static_flavours@blosxom::static_flavours

Server Settings

(Not all of these will be filled in...)
Server Name $ENV{'SERVER_NAME'}
Script Name $ENV{'SCRIPT_NAME'} The server settings: http://$ENV{'SERVER_NAME'}$ENV{'SCRIPT_NAME'}
should match \$url: $blosxom::url
(Sort of)
Server Software $ENV{'SERVER_SOFTWARE'}
Web Server Document Root $ENV{'DOCUMENT_ROOT'}
Cookies for this page $ENV{'HTTP_COOKIE'}
CGI Path Info $ENV{'PATH_INFO'}
User ID of Blosxom $>
User Name of Blosxom " . getpwuid("$>") . "
Group ID of Blosxom $)
User Name of Blosxom " . getgrgid("$)") . "
"; } sub debug_plugins { $debug .="

Plugins

(Listed in load order) "; if ( $blosxom::plugin_dir and opendir PLUGINS, $blosxom::plugin_dir ) { foreach my $plugin ( grep { /^\w+$/ && -f "$blosxom::plugin_dir/$_" } sort readdir(PLUGINS) ) { $debug .= "\n"; } } $debug .= "
PluginPermissionsEnabled?Comment
$plugin"; if (-r "$blosxom::plugin_dir/$plugin") { $debugmode = sprintf("%4o",stat("$blosxom::plugin_dir/$plugin")->mode); $debugmode =~ s/.*(\d\d\d)$/$1/; $debugmode = "$debugmode" if ( $debugmode !~ /^[4-7][4-7]/); $debugmode = "$debugmode" if ( $debugmode !~ /^\d[4-7][4-7]/); $debugmode = "$debugmode" if ( $debugmode !~ /font color/); $debug .= $debugmode; } else { $debug .= "File not Found\?"; } $debug .= ""; $plugin =~ s/^\d*//; if ($blosxom::plugins{$plugin} eq 1) { $debug .= "Yes"; } else { $debug .= "NoThis may be disabled on purpose... More help in future releases"; } $debug .= "
"; } sub debug_security { $debug .="

Security Issues

"; foreach ( sort keys %debugfilelist) { next if ($_ =~ /(Static Directory|Blosxom Script)/); $debug .= "\n"; } $debug .= "
FolderPathAt Risk?
Web Server Document Root$ENV{'DOCUMENT_ROOT'}N/A
$_
$debugfilelist{$_}"; # If the directory being examined is within the server document root, # But not "underneath" the redirected blosxom location, # It may be accessed directly from a web browser # Unless an .htaccess file is set up if (($debugfilelist{$_} =~ /^$ENV{'DOCUMENT_ROOT'}/) && ($debugfilelist{$_} !~ /^$ENV{'DOCUMENT_ROOT'}$ENV{'SCRIPT_NAME'}/)) { $debug .= "Yes"; } else { $debug .= "No"; } $debug .= "
\n If a directory is noted to be \"At Risk\" this simply means that it is contained within your web server's path.
Someone could gain access to it by entering the url into their web browser.
Use of an .htaccess file is recommended for extra security (Setting this up is beyond the scope of this program.)
"; } 1;