Skip to content

Commit

Permalink
FIX #90
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 17, 2018
1 parent 1c1f9dd commit d4d815d
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions wwwroot/cgi-bin/awstats.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1780,22 +1780,24 @@ sub Read_Config {
}else{if ($Debug){debug("Unable to open config file: $searchdir$SiteConfig", 2);}}
}

#CL - Added to open config if full path is passed to awstats
if ( !$FileConfig ) {

my $SiteConfigBis = File::Spec->rel2abs($SiteConfig);
debug("Finally, try to open an absolute path : $SiteConfigBis", 2);

if ( -f $SiteConfigBis && open(CONFIG, "$SiteConfigBis")) {
$FileConfig = "$SiteConfigBis";
$FileSuffix = '';
if ($Debug){debug("Opened config: $SiteConfigBis", 2);}
$SiteConfig=$SiteConfigBis;
}
else {
if ($Debug){debug("Unable to open config file: $SiteConfigBis", 2);}
}
}
#CL - Added to open config if full path is passed to awstats
# Disabled by LDR for security reason.
# If we need to execute config into other dir
#if ( !$FileConfig ) {
#
# my $SiteConfigBis = File::Spec->rel2abs($SiteConfig);
# debug("Finally, try to open an absolute path : $SiteConfigBis", 2);
#
# if ( -f $SiteConfigBis && open(CONFIG, "$SiteConfigBis")) {
# $FileConfig = "$SiteConfigBis";
# $FileSuffix = '';
# if ($Debug){debug("Opened config: $SiteConfigBis", 2);}
# $SiteConfig=$SiteConfigBis;
# }
# else {
# if ($Debug){debug("Unable to open config file: $SiteConfigBis", 2);}
# }
#}

if ( !$FileConfig ) {
if ($DEBUGFORCED || !$ENV{'GATEWAY_INTERFACE'}){
Expand Down

1 comment on commit d4d815d

@ThiefMaster
Copy link

@ThiefMaster ThiefMaster commented on d4d815d Jan 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "fix" just made me waste half an hour debugging why my config was no longer loaded after upgrading awstats.

The error message still indicates an absolute path is possible:

Sat Jan  1 02:59:11 2022 - DEBUG 1 - Couldn't open config file "awstats./opt/awstats/etc/awstats.conf.conf", nor "awstats.conf", nor "/opt/awstats/etc/awstats.conf" after searching in path "/opt/awstats/cgi-bin, /etc/awstats, /usr/local/etc/awstats, /etc, /etc/opt/awstats, /opt/awstats/etc/awstats.conf": No such file or directory

And FWIW, when using AWSTATS_FORCE_CONFIG then the absolute path SHOULD be used and not ignored - same when a config path is specified via -config on the command line.

In case anyone else finds this: -configdir=/opt/awstats/etc -config=awstats does the job.

Please sign in to comment.