diff -ruN e-smith-backup-2.4.0/root/etc/e-smith/web/functions/backup e-smith-backup-2.4.0.new/root/etc/e-smith/web/functions/backup --- e-smith-backup-2.4.0/root/etc/e-smith/web/functions/backup 2014-02-02 22:08:41.000000000 -0800 +++ e-smith-backup-2.4.0.new/root/etc/e-smith/web/functions/backup 2014-02-02 22:57:24.000000000 -0800 @@ -1161,6 +1161,7 @@ my $backupwkIncOnlyTimeout; my $compression; my $VFSType = $q->param ('VFSType'); + my $error=""; my $dof; my @usbdisks; my %dlabels = (); @@ -1230,13 +1231,11 @@ push @usbdisks, $vollbl; } } - unless ($usbdisks[0]){ - esmith::cgi::genResult( - $fm->{cgi}, $fm->localise('ERR_NO_USB_DISK')); - return - } - } + push @usbdisks, $fm->localise('ERR_NO_USB_DISK'); + $error='nousb'; + } + } print $q->startform( -method => 'POST', @@ -1431,6 +1430,7 @@ print "\n"; + if ($error eq 'nousb') {$VFSType = "nousb";} print $q->start_table ({width => "100%", -class => "sme-noborders"}); print $q->Tr($q->th({-class => "sme-layout"}, $q->submit( @@ -1462,7 +1462,7 @@ { my ($q) = @_; - my $status = $q->param ('workstnbackup'); + my $status = $q->param ('workstnbackup') || ""; my $inconly = $q->param ('incOnlyTimeout'); my $dof = $q->param('dof'); my $ampm; @@ -1472,13 +1472,39 @@ $q, undef, $fm->localise('UPDATING_WORKSTN_CONF') ); + + my $rec = $conf->get('backupwk'); + unless (defined $rec) + { + $rec = $conf->new_record('backupwk', {type=>'service'}); + } + + unless ( $status eq 'on') + { + # set service to disabled + my $old = $conf->get('UnsavedChanges')->value; + + $rec->set_prop('status', 'disabled'); + $conf->get('UnsavedChanges')->set_value($old); + system("/sbin/e-smith/signal-event", "conf-backup") == 0 + or die($fm->localise('ERR_CONF_BACKUP')."\n"); + + esmith::cgi::genResult($q, $fm->localise('SUCCESSFULLY_DISABLED_WORKSTN')); + return; + } + #-------------------------------------------------- # Untaint parameters and check for validity #-------------------------------------------------- my $VFSType = $q->param ('VFSType'); - + if ( $VFSType eq 'nousb') + { + esmith::cgi::genResult($q, $fm->localise('ERR_NO_USB_DISK')); + return; + } + my $backupwkStation = $q->param ('backupwkStation'); if ( $VFSType eq 'usb') { $backupwkStation = 'localhost' } if ($backupwkStation =~ /^\s*(\S+)\s*$/) { @@ -1587,12 +1613,6 @@ return; } - my $rec = $conf->get('backupwk'); - unless (defined $rec) - { - $rec = $conf->new_record('backupwk', {type=>'service'}); - } - $rec->set_prop('SmbHost', $backupwkStation); $rec->set_prop('SmbShare', $backupwkFolder); $rec->set_prop('Login', $backupwkLogin); @@ -1619,9 +1639,6 @@ } $rec->set_prop('Program', $module); - - if (defined $status && $status eq 'on') - { my $backupwkHour = $q->param ('backupwkHour'); if ($backupwkHour =~ /^(.*)$/) { @@ -1688,22 +1705,6 @@ esmith::cgi::genResult( $q, $fm->localise('SUCCESSFULLY_ENABLED_WORKSTN').$q->br(). $fm->localise('WITH_BACKUP_TIME')."$backupwkHour:$backupwkMin"); - } - else - { - # set service to disabled - my $old = $conf->get('UnsavedChanges')->value; - - $rec->set_prop('status', 'disabled'); - $conf->get('UnsavedChanges')->set_value($old); - - system("/sbin/e-smith/signal-event", "conf-backup") == 0 - or die($fm->localise('ERR_CONF_BACKUP')."\n"); - - esmith::cgi::genResult( - $q, $fm->localise('SUCCESSFULLY_DISABLED_WORKSTN') - ); - } return; }