#
#========================================================================
#
-# Version 2.0.0beta1, released 30 Mar 2003.
+# Version 2.0.0beta2, released 11 May 2003.
#
# See http://backuppc.sourceforge.net.
#
if ( !defined($bpc) ) {
ErrorExit($Lang->{BackupPC__Lib__new_failed__check_apache_error_log})
- if ( !($bpc = BackupPC::Lib->new) );
+ if ( !($bpc = BackupPC::Lib->new(undef, undef, 1)) );
$TopDir = $bpc->TopDir();
$BinDir = $bpc->BinDir();
%Conf = $bpc->Conf();
#
if ( $Conf{BackupPCUserVerify}
&& $> != (my $uid = (getpwnam($Conf{BackupPCUser}))[2]) ) {
- ErrorExit(eval("qq{$Lang->{Wrong_user__my_userid_is___}}"));
+ ErrorExit(eval("qq{$Lang->{Wrong_user__my_userid_is___}}"), <<EOF);
+This script needs to run as the user specified in \$Conf{BackupPCUser},
+which is set to $Conf{BackupPCUser}.
+<p>
+This is an installation problem. If you are using mod_perl then
+it appears that Apache is not running as user $Conf{BackupPCUser}.
+If you are not using mod_perl, then most like setuid is not working
+properly on BackupPC_Admin. Check the permissions on
+$Conf{CgiDir}/BackupPC_Admin and look at the documentation.
+EOF
}
if ( !defined($Hosts) || $bpc->HostsMTime() != $HostsMTime ) {
}
foreach my $host ( sort(keys(%Status)) ) {
my($fullDur, $incrCnt, $incrAge, $fullSize, $fullRate, $reasonHilite);
+ my($shortErr);
my @Backups = $bpc->BackupInfoRead($host);
my $fullCnt = $incrCnt = 0;
my $fullAge = $incrAge = -1;
$incrAge = " " if ( $incrAge eq "" );
$reasonHilite = $Conf{CgiStatusHilightColor}{$Status{$host}{reason}};
$reasonHilite = " bgcolor=\"$reasonHilite\"" if ( $reasonHilite ne "" );
+ if ( $Status{$host}{state} ne "Status_backup_in_progress"
+ && $Status{$host}{state} ne "Status_restore_in_progress"
+ && $Status{$host}{error} ne "" ) {
+ ($shortErr = $Status{$host}{error}) =~ s/(.{48}).*/$1.../;
+ $shortErr = " ($shortErr)";
+ }
$str = <<EOF;
<tr$reasonHilite><td> ${HostLink($host)} </td>
- <td align="center"> ${UserLink($Hosts->{$host}{user})} </td>
+ <td align="center"> ${UserLink(defined($Hosts->{$host})
+ ? $Hosts->{$host}{user} : "")} </td>
<td align="center"> $fullCnt </td>
<td align="center"> $fullAge </td>
<td align="center"> $fullSize </td>
<td align="center"> $incrCnt </td>
<td align="center"> $incrAge </td>
<td align="center"> $Lang->{$Status{$host}{state}} </td>
- <td> $Lang->{$Status{$host}{reason}} </td></tr>
+ <td> $Lang->{$Status{$host}{reason}}$shortErr </td></tr>
EOF
if ( @Backups == 0 ) {
$hostCntNone++;
}
$statusStr .= eval("qq{$Lang->{Last_status_is_state_StatusHost_state_reason_as_of_startTime}}");
- if ( $StatusHost{error} ne "" ) {
+ if ( $StatusHost{state} ne "Status_backup_in_progress"
+ && $StatusHost{state} ne "Status_restore_in_progress"
+ && $StatusHost{error} ne "" ) {
$statusStr .= eval("qq{$Lang->{Last_error_is____EscHTML_StatusHost_error}}");
}
my $priorStr = "Pings";
$jobStr .= <<EOF;
<tr><td> ${HostLink($host)} </td>
<td align="center"> $Jobs{$host}{type} </td>
- <td align="center"> ${UserLink($Hosts->{$host}{user})} </td>
+ <td align="center"> ${UserLink(defined($Hosts->{$host})
+ ? $Hosts->{$host}{user} : "")} </td>
<td> $startTime </td>
<td> $cmd </td>
<td align="center"> $Jobs{$host}{pid} </td>
}
foreach my $host ( sort(keys(%Status)) ) {
next if ( $Status{$host}{reason} ne "Reason_backup_failed"
- || $Status{$host}{error} =~ /^Can't find host \Q$host/ );
+ && (!$Status{$host}{userReq}
+ || $Status{$host}{reason} ne "Reason_no_ping") );
my $startTime = timeStamp2($Status{$host}{startTime});
my($errorTime, $XferViewStr);
if ( $Status{$host}{errorTime} > 0 ) {
$statusStr .= <<EOF;
<tr><td> ${HostLink($host)} </td>
<td align="center"> $Status{$host}{type} </td>
- <td align="center"> ${UserLink($Hosts->{$host}{user})} </td>
+ <td align="center"> ${UserLink(defined($Hosts->{$host})
+ ? $Hosts->{$host}{user} : "")} </td>
<td align="right"> $startTime </td>
<td> $XferViewStr </td>
<td align="right"> $errorTime </td>
$Conf{CgiNavBarBgColor} ||= "#ddeeee";
$Conf{CgiHeaderBgColor} ||= "#99cc33";
+ if ( !defined($ENV{REMOTE_USER}) ) {
+ $mesg .= <<EOF;
+<p>
+Note: \$ENV{REMOTE_USER} is not set, which could mean there is an
+installation problem. BackupPC_Admin expects Apache to authenticate
+the user and pass their user name into this script as the REMOTE_USER
+environment variable. See the documentation.
+EOF
+ }
+
$bpc->ServerMesg("log User $User (host=$In{host}) got CGI error: $head")
if ( defined($bpc) );
if ( !defined($Lang->{Error}) ) {
my($host) = @_;
my $ipAddr = $host;
- if ( $Hosts->{$host}{dhcp}
+ if ( defined($Hosts->{$host}) && $Hosts->{$host}{dhcp}
&& $ENV{REMOTE_ADDR} =~ /^(\d+[\.\d]*)$/ ) {
$ipAddr = $1;
my($netBiosHost, $netBiosUser) = $bpc->NetBiosInfoGet($ipAddr);