Fix a bunch of warnings
authorJamie Cameron <jcameron@webmin.com>
Mon, 25 Jul 2011 20:50:30 +0000 (13:50 -0700)
committerJamie Cameron <jcameron@webmin.com>
Mon, 25 Jul 2011 20:50:30 +0000 (13:50 -0700)
https://www.virtualmin.com/node/18946

backup-config/backup-config-lib.pl
backup-config/backup.pl

index 04ff4b3..5ef8deb 100755 (executable)
@@ -18,9 +18,9 @@ our (%text, $module_config_directory, %config);
 &init_config();
 &foreign_require("cron", "cron-lib.pl");
 
-my $cron_cmd = "$module_config_directory/backup.pl";
-my $backups_dir = "$module_config_directory/backups";
-my $manifests_dir = "/tmp/backup-config-manifests";
+our $cron_cmd = "$module_config_directory/backup.pl";
+our $backups_dir = "$module_config_directory/backups";
+our $manifests_dir = "/tmp/backup-config-manifests";
 
 =head2 list_backup_modules
 
@@ -331,9 +331,11 @@ if ($_[4]) {
 
 # Add other files
 foreach my $f (@{$_[6]}) {
+       next if (!$f);
        if (-d $f) {
                # A directory .. recursively expand
                foreach my $sf (&expand_directory($f)) {
+                       next if (!$sf);
                        push(@files, $sf);
                        push(@{$manifestfiles{"other"}}, $sf);
                        }
@@ -360,7 +362,7 @@ foreach $m (@mods, "_others") {
        }
 
 # Make sure we have something to do
-@files = grep { -e $_ } @files;
+@files = grep { $_ && -e $_ } @files;
 @files || (return $text{'backup_enone'});
 
 if (!$_[5]) {
@@ -669,11 +671,13 @@ if ($mode == 0) {
        }
 elsif ($mode == 1) {
        return &text($port ? 'nice_ftpp' : 'nice_ftp',
-                    "<tt>$server</tt>", "<tt>$path</tt>", "<tt>$port</tt>");
+                    "<tt>$server</tt>", "<tt>$path</tt>",
+                    $port ? "<tt>$port</tt>" : "");
        }
 elsif ($mode == 2) {
        return &text($port ? 'nice_sshp' : 'nice_ssh',
-                    "<tt>$server</tt>", "<tt>$path</tt>", "<tt>$port</tt>");
+                    "<tt>$server</tt>", "<tt>$path</tt>",
+                    $port ? "<tt>$port</tt>" : "");
        }
 elsif ($mode == 3) {
        return $text{'nice_upload'};
index d9739d2..a0358d4 100755 (executable)
@@ -14,7 +14,7 @@ $backup || die "Failed to find backup $ARGV[0]";
 
 # Run the pre-backup command, if any
 my $err;
-my $premsg;
+my $premsg = "";
 if ($backup->{'pre'} =~ /\S/) {
        my $preout = &backquote_command("($backup->{'pre'}) 2>&1 </dev/null");
        $premsg = &text('email_pre', $backup->{'pre'})."\n".
@@ -34,7 +34,7 @@ if (!$err) {
        }
 
 # Run the post-backup command, if any
-my $postmsg;
+my $postmsg = "";
 if (!$err && $backup->{'post'} =~ /\S/) {
        my $postout = &backquote_command("($backup->{'post'}) 2>&1 </dev/null");
        $postmsg = "\n".
@@ -52,10 +52,10 @@ if (($err || $backup->{'emode'} == 0) && $backup->{'email'}) {
        my $host = &get_system_hostname();
        my $nice = &nice_dest($backup->{'dest'}, 1);
        $nice =~ s/<[^>]+>//g;
-       $err =~ s/<[^>]+>//g;
        my $msg;
        my $subject;
        if ($err) {
+               $err =~ s/<[^>]+>//g;
                $msg = $premsg.
                       $text{'email_mods'}."\n".
                       $mlist.