X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FLib.pm;h=3345d9916f76a1d7bdfbd720998dc406f3df04e6;hp=aee4743082b3f8b53d4f14cbdf5098e9b20ee30b;hb=99b9efe77451800084c477ed2139100f830cb7db;hpb=ce708288691ba7dd95a8dac7a468bc0e4c1d6588 diff --git a/lib/BackupPC/CGI/Lib.pm b/lib/BackupPC/CGI/Lib.pm index aee4743..3345d99 100644 --- a/lib/BackupPC/CGI/Lib.pm +++ b/lib/BackupPC/CGI/Lib.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0beta0, released 20 Mar 2004. +# Version 2.1.2, released 5 Sep 2005. # # See http://backuppc.sourceforge.net. # @@ -102,8 +102,10 @@ sub NewRequest $Lang = $bpc->Lang(); $ConfigMTime = $bpc->ConfigMTime(); } elsif ( $bpc->ConfigMTime() != $ConfigMTime ) { - $bpc->ServerMesg("log Re-read config file because mtime changed"); - $bpc->ServerMesg("server reload"); + $bpc->ConfigRead(); + %Conf = $bpc->Conf(); + $Lang = $bpc->Lang(); + $ConfigMTime = $bpc->ConfigMTime(); } # @@ -154,6 +156,15 @@ EOF {map {$_, 1} split(",", $Hosts->{$host}{moreUsers}) } } } + + # + # Untaint the host name + # + if ( $In{host} =~ /^([\w.\s-]+)$/ ) { + $In{host} = $1; + } else { + delete($In{host}); + } } sub timeStamp2 @@ -278,12 +289,16 @@ sub GetStatusInfo { my($status) = @_; ServerConnect(); + %Status = () if ( $status =~ /\bhosts\b/ ); + %StatusHost = () if ( $status =~ /\bhost\(/ ); my $reply = $bpc->ServerMesg("status $status"); $reply = $1 if ( $reply =~ /(.*)/s ); eval($reply); # ignore status related to admin and trashClean jobs if ( $status =~ /\bhosts\b/ ) { - delete($Status{$bpc->adminJob}); + foreach my $host ( grep(/admin/, keys(%Status)) ) { + delete($Status{$host}) if ( $bpc->isAdminJob($host) ); + } delete($Status{$bpc->trashJob}); } } @@ -320,9 +335,10 @@ sub CheckPermission $Privileged ||= $Conf{CgiAdminUsers} eq "*"; } $PrivAdmin = $Privileged; + return $Privileged if ( !defined($host) ); + $Privileged ||= $User eq $Hosts->{$host}{user}; $Privileged ||= defined($Hosts->{$host}{moreUsers}{$User}); - return $Privileged; } @@ -334,7 +350,7 @@ sub CheckPermission # sub GetUserHosts { - my($host, $getAll) = @_; + my($getAll) = @_; my @hosts; if ( $getAll && CheckPermission() ) { @@ -389,23 +405,23 @@ sub Header { my($title, $content, $noBrowse, $contentSub, $contentPost) = @_; my @adminLinks = ( - { link => "", name => $Lang->{Status}, + { link => "", name => $Lang->{Status}}, + { link => "?action=adminOpts", name => $Lang->{Admin_Options}, + priv => 1}, + { link => "?action=summary", name => $Lang->{PC_Summary}}, + { link => "?action=view&type=LOG", name => $Lang->{LOG_file}, + priv => 1}, + { link => "?action=LOGlist", name => $Lang->{Old_LOGs}, priv => 1}, - { link => "?action=adminOpts", name => $Lang->{Admin_Options} }, - { link => "?action=summary", name => $Lang->{PC_Summary}, + { link => "?action=emailSummary", name => $Lang->{Email_summary}, priv => 1}, - { link => "?action=view&type=LOG", name => $Lang->{LOG_file} }, - { link => "?action=LOGlist", name => $Lang->{Old_LOGs} }, - { link => "?action=emailSummary", name => $Lang->{Email_summary} }, - { link => "?action=view&type=config", name => $Lang->{Config_file} }, - { link => "?action=view&type=hosts", name => $Lang->{Hosts_file} }, - { link => "?action=queue", name => $Lang->{Current_queues} }, - { link => "?action=view&type=docs", name => $Lang->{Documentation}, + { link => "?action=view&type=config", name => $Lang->{Config_file}, priv => 1}, - { link => "http://backuppc.sourceforge.net/faq", name => "FAQ", + { link => "?action=view&type=hosts", name => $Lang->{Hosts_file}, priv => 1}, - { link => "http://backuppc.sourceforge.net", name => "SourceForge", + { link => "?action=queue", name => $Lang->{Current_queues}, priv => 1}, + @{$Conf{CgiNavBarLinks} || []}, ); my $host = $In{host}; @@ -414,15 +430,15 @@ sub Header $title -$Conf{CSSstylesheet} + $Conf{CgiHeaders} -
+
EOF if ( defined($Hosts) && defined($host) && defined($Hosts->{$host}) ) { print "
"; - NavSectionTitle("${EscURI($host)}"); + NavSectionTitle("${EscHTML($host)}"); print <