Make all files warnings complaint
authorJamie Cameron <jcameron@webmin.com>
Sat, 30 Apr 2011 02:18:16 +0000 (19:18 -0700)
committerJamie Cameron <jcameron@webmin.com>
Sat, 30 Apr 2011 02:18:16 +0000 (19:18 -0700)
backup-config/backup.cgi
backup-config/backup.pl
backup-config/cgi_args.pl
backup-config/edit.cgi
backup-config/index.cgi
backup-config/log_parser.pl
backup-config/restore.cgi
backup-config/save.cgi
backup-config/uninstall.pl

index 6bc56d6..af86d2b 100755 (executable)
@@ -1,22 +1,29 @@
 #!/usr/local/bin/perl
 # Do an immediate backup
 
+use strict;
+use warnings;
 require './backup-config-lib.pl';
+our (%in, %text, %config, $module_config_file);
 &ReadParse();
 
 # Validate inputs
 &error_setup($text{'backup_err'});
-$dest = &parse_backup_destination("dest", \%in);
-($configfile, $nofiles, $others) = &parse_backup_what("what", \%in);
-@mods = split(/\0/, $in{'mods'});
+my $dest = &parse_backup_destination("dest", \%in);
+my ($configfile, $nofiles, $others) = &parse_backup_what("what", \%in);
+my @mods = split(/\0/, $in{'mods'});
 @mods || ($nofiles && !$configfile) || &error($text{'backup_emods'});
 
 # Go for it
-($mode, $user, $pass, $server, $path, $port) = &parse_backup_url($dest);
+my ($mode, $user, $pass, $server, $path, $port) = &parse_backup_url($dest);
+my $err;
 if ($mode != 4) {
        # Save somewhere, and tell the user
        &ui_print_header(undef, $text{'backup_title'}, "");
        print &text('backup_doing', &nice_dest($dest, 1)),"<p>\n";
+       my $size;
+       my @files;
+       my @mods;
        $err = &execute_backup(\@mods, $dest, \$size, \@files,
                               $configfile, $nofiles,
                               [ split(/\t+/, $others) ]);
@@ -31,7 +38,9 @@ if ($mode != 4) {
        }
 else {
        # Output file in browser
-       $temp = &transname();
+       my $temp = &transname();
+       my $size;
+       my @mods;
        $err = &execute_backup(\@mods, $temp, \$size, undef,
                               $configfile, $nofiles);
        if ($err) {
@@ -39,6 +48,7 @@ else {
                &error($err);
                }
        print "Content-type: application/octet-stream\n\n";
+       my $buf;
        open(TEMP, $temp);
        while(read(TEMP, $buf, 1024)) {
                print $buf;
index efeb47f..d9739d2 100755 (executable)
@@ -1,17 +1,22 @@
 #!/usr/local/bin/perl
 # Execute a backup on schedule
 
+use strict;
+use warnings;
+our (%text, %config, $no_acl_check);
 $no_acl_check++;
 require './backup-config-lib.pl';
 &foreign_require("mailboxes", "mailboxes-lib.pl");
 
 # Get the backup
-$backup = &get_backup($ARGV[0]);
+my $backup = &get_backup($ARGV[0]);
 $backup || die "Failed to find backup $ARGV[0]";
 
 # Run the pre-backup command, if any
+my $err;
+my $premsg;
 if ($backup->{'pre'} =~ /\S/) {
-       $preout = &backquote_command("($backup->{'pre'}) 2>&1 </dev/null");
+       my $preout = &backquote_command("($backup->{'pre'}) 2>&1 </dev/null");
        $premsg = &text('email_pre', $backup->{'pre'})."\n".
                  $preout."\n";
        if ($?) {
@@ -20,7 +25,8 @@ if ($backup->{'pre'} =~ /\S/) {
        }
 
 # Do it
-@mods = split(/\s+/, $backup->{'mods'});
+my @mods = split(/\s+/, $backup->{'mods'});
+my $size;
 if (!$err) {
        $err = &execute_backup(\@mods, $backup->{'dest'}, \$size, undef,
                               $backup->{'configfile'}, $backup->{'nofiles'},
@@ -28,8 +34,9 @@ if (!$err) {
        }
 
 # Run the post-backup command, if any
+my $postmsg;
 if (!$err && $backup->{'post'} =~ /\S/) {
-       $postout = &backquote_command("($backup->{'post'}) 2>&1 </dev/null");
+       my $postout = &backquote_command("($backup->{'post'}) 2>&1 </dev/null");
        $postmsg = "\n".
                  &text('email_post', $backup->{'post'})."\n".
                  $postout."\n";
@@ -37,14 +44,17 @@ if (!$err && $backup->{'post'} =~ /\S/) {
 
 # Send off the results
 if (($err || $backup->{'emode'} == 0) && $backup->{'email'}) {
-       foreach $m (@mods) {
-               %minfo = &get_module_info($m);
+       my $mlist;
+       foreach my $m (@mods) {
+               my %minfo = &get_module_info($m);
                $mlist .= "    $minfo{'desc'}\n";
                }
-       $host = &get_system_hostname();
-       $nice = &nice_dest($backup->{'dest'}, 1);
+       my $host = &get_system_hostname();
+       my $nice = &nice_dest($backup->{'dest'}, 1);
        $nice =~ s/<[^>]+>//g;
        $err =~ s/<[^>]+>//g;
+       my $msg;
+       my $subject;
        if ($err) {
                $msg = $premsg.
                       $text{'email_mods'}."\n".
@@ -64,7 +74,6 @@ if (($err || $backup->{'emode'} == 0) && $backup->{'email'}) {
                       $postmsg;
                $subject = &text('email_sok', $host);
                }
-       print STDERR $msg,"\n";
        &mailboxes::send_text_mail($config{'from_addr'} ||
                                   &mailboxes::get_from_address(),
                                   $backup->{'email'},
index 0d48cf2..4316b3c 100755 (executable)
@@ -1,4 +1,6 @@
 
+use strict;
+use warnings;
 do 'backup-config-lib.pl';
 
 sub cgi_args
index c2756d5..2fb12f7 100755 (executable)
@@ -1,8 +1,13 @@
 #!/usr/local/bin/perl
 # Show one scheduled backup
 
+use strict;
+use warnings;
 require './backup-config-lib.pl';
+our (%in, %text);
 &ReadParse();
+
+my $backup;
 if ($in{'new'}) {
        &ui_print_header(undef, $text{'edit_title1'}, "");
        $backup = { 'emode' => 0,
@@ -22,13 +27,13 @@ print &ui_form_start("save.cgi", "post");
 print &ui_hidden("new", $in{'new'});
 print &ui_hidden("id", $in{'id'});
 
-@tds = ( "width=30%" );
+my @tds = ( "width=30%" );
 print &ui_hidden_table_start($text{'edit_header'}, "width=100%", 2,
                             "main", 1, \@tds);
 
 # Show modules to backup
-@mods = &list_backup_modules();
-@dmods = split(/\s+/, $backup->{'mods'});
+my @mods = &list_backup_modules();
+my @dmods = split(/\s+/, $backup->{'mods'});
 print &ui_table_row($text{'edit_mods'},
                    &ui_select("mods", \@dmods,
                       [ map { [ $_->{'dir'}, $_->{'desc'} ] } @mods ],
@@ -73,6 +78,7 @@ print &ui_table_row($text{'edit_emode'},
                                [ 1, $text{'edit_emode1'} ] ]));
 
 # Show schedule
+my $job;
 if ($backup) {
        $job = &find_cron_job($backup);
        }
index fdc28c6..bc6a4d1 100755 (executable)
@@ -1,33 +1,38 @@
 #!/usr/local/bin/perl
 # Show all scheduled backups, and a form for doing an immediate one
 
+use strict;
+use warnings;
 require './backup-config-lib.pl';
+our (%text, %in, %config);
 &ReadParse();
+
 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
-@mods = &list_backup_modules();
+my @mods = &list_backup_modules();
 if (!@mods) {
        &ui_print_endpage($text{'index_emods'});
        }
-%mods = map { $_->{'dir'}, $_ } @mods;
+my %mods = map { $_->{'dir'}, $_ } @mods;
 
 # Show tabs
-@tabs = ( [ "backup", $text{'index_tabbackup'}, "index.cgi?mode=backup" ],
-         [ "sched", $text{'index_tabsched'}, "index.cgi?mode=sched" ],
-         [ "restore", $text{'index_tabrestore'}, "index.cgi?mode=restore" ],
-       );
+my @tabs = ( [ "backup", $text{'index_tabbackup'}, "index.cgi?mode=backup" ],
+            [ "sched", $text{'index_tabsched'}, "index.cgi?mode=sched" ],
+            [ "restore", $text{'index_tabrestore'}, "index.cgi?mode=restore" ],
+          );
 print &ui_tabs_start(\@tabs, "tab", $in{'mode'} || "backup", 1);
 
 print &ui_tabs_start_tab("tab", "sched");
-@backups = &list_backups();
+my @backups = &list_backups();
+my $using_strftime = 0;
 if (@backups) {
        # Show all scheduled backups
        print "<a href='edit.cgi?new=1'>$text{'index_add'}</a><br>\n";
        print &ui_columns_start([ $text{'index_dest'},
                                  $text{'index_mods'},
                                  $text{'index_sched'} ], 100);
-       foreach $b (@backups) {
-               local @m = map { $mods{$_}->{'desc'} }
-                              split(/\s+/, $b->{'mods'});
+       foreach my $b (@backups) {
+               my @m = map { $mods{$_}->{'desc'} }
+                           split(/\s+/, $b->{'mods'});
                print &ui_columns_row(
                        [ "<a href='edit.cgi?id=$b->{'id'}'>".
                          &nice_dest($b->{'dest'})."</a>",
@@ -54,7 +59,7 @@ print &ui_tabs_start_tab("tab", "backup");
 print &ui_form_start("backup.cgi/backup.tgz", "post");
 print &ui_table_start($text{'index_header'}, undef, 2);
 
-@dmods = split(/\s+/, $config{'mods'});
+my @dmods = split(/\s+/, $config{'mods'});
 print &ui_table_row($text{'edit_mods'},
                    &ui_select("mods", \@dmods,
                       [ map { [ $_->{'dir'}, $_->{'desc'} ] } @mods ],
@@ -77,7 +82,6 @@ print &ui_tabs_start_tab("tab", "restore");
 print &ui_form_start("restore.cgi", "form-data");
 print &ui_table_start($text{'index_header2'}, undef, 2);
 
-@dmods = split(/\s+/, $config{'mods'});
 print &ui_table_row($text{'edit_mods2'},
                    &ui_select("mods", \@dmods,
                       [ map { [ $_->{'dir'}, $_->{'desc'} ] } @mods ],
index 8c84737..ceb1420 100755 (executable)
@@ -1,7 +1,10 @@
 # log_parser.pl
 # Functions for parsing this module's logs
 
+use strict;
+use warnings;
 do 'backup-config-lib.pl';
+our (%text);
 
 # parse_webmin_log(user, script, action, type, object, &params)
 # Converts logged information from this module into human-readable form
index 7bb952b..6e7e653 100755 (executable)
@@ -1,20 +1,23 @@
 #!/usr/local/bin/perl
 # Do an immediate restore
 
+use strict;
+use warnings;
 require './backup-config-lib.pl';
+our (%in, %text, %config, $module_config_file);
 &ReadParseMime();
 
 # Validate inputs
 &error_setup($text{'restore_err'});
-$src = &parse_backup_destination("src", \%in);
-@mods = split(/\0/, $in{'mods'});
+my $src = &parse_backup_destination("src", \%in);
+my @mods = split(/\0/, $in{'mods'});
 @mods || &error($text{'restore_emods'});
 
 # Do it ..
-($mode, $user, $pass, $server, $path, $port) = &parse_backup_url($src);
+my ($mode, $user, $pass, $server, $path, $port) = &parse_backup_url($src);
 if ($mode == 3) {
        # Create temp file for uploaded file
-       $temp = &transname();
+       my $temp = &transname();
        open(TEMP, ">$temp");
        print TEMP $in{$path};
        close(TEMP);
@@ -23,8 +26,9 @@ if ($mode == 3) {
 &ui_print_header(undef, $text{'restore_title'}, "");
 print &text($in{'test'} ? 'restore_testing' : 'restore_doing',
            &nice_dest($src)),"<p>\n";
-$err = &execute_restore(\@mods, $src, \@files, $in{'apply'}, $in{'test'});
-&unlink_file($temp) if ($mode == 3);
+my @files;
+my $err = &execute_restore(\@mods, $src, \@files, $in{'apply'}, $in{'test'});
+&unlink_file($src) if ($mode == 3);
 if ($err) {
        print &text('restore_failed', $err),"<p>\n";
        }
index 1c70440..478b981 100755 (executable)
@@ -1,10 +1,14 @@
 #!/usr/local/bin/perl
 # Create, update or delete a scheduled backup
 
+use strict;
+use warnings;
 require './backup-config-lib.pl';
+our (%in, %text, $cron_cmd, $module_name);
 &ReadParse();
 
 # Find the backup job
+my ($job, $backup);
 if (!$in{'new'}) {
        $backup = &get_backup($in{'id'});
        $job = &find_cron_job($backup);
@@ -25,7 +29,7 @@ if ($in{'delete'}) {
 else {
        # Validate inputs
        &error_setup($text{'save_err'});
-       @mods = split(/\0/, $in{'mods'});
+       my @mods = split(/\0/, $in{'mods'});
        $backup->{'mods'} = join(" ", @mods);
        $backup->{'dest'} = &parse_backup_destination("dest", \%in);
        &cron::parse_times_input($backup, \%in);
@@ -69,8 +73,9 @@ if ($in{'run'}) {
        &ui_print_unbuffered_header(undef, $text{'run_title'}, "");
 
        # Run the pre-backup command, if any
+       my $err;
        if ($backup->{'pre'} =~ /\S/) {
-               $preout = &backquote_command(
+               my $preout = &backquote_command(
                        "($backup->{'pre'}) 2>&1 </dev/null");
                print &text('email_pre',
                        "<tt>".&html_escape($backup->{'pre'})."</tt>")."<br>\n".
@@ -80,11 +85,12 @@ if ($in{'run'}) {
                        }
                }
 
-       @mods = split(/\s+/, $backup->{'mods'});
-       $nice = &nice_dest($backup->{'dest'}, 1);
+       my @mods = split(/\s+/, $backup->{'mods'});
+       my $nice = &nice_dest($backup->{'dest'}, 1);
        if (!$err) {
                print &text('run_doing', scalar(@mods),
                            "<tt>$nice</tt>"),"<br>\n";
+               my $size;
                $err = &execute_backup(
                        \@mods, $backup->{'dest'}, \$size, undef,
                        $backup->{'configfile'}, $backup->{'nofiles'},
@@ -100,7 +106,7 @@ if ($in{'run'}) {
 
        # Run the post-backup command, if any
        if (!$err && $backup->{'post'} =~ /\S/) {
-               $postout = &backquote_command(
+               my $postout = &backquote_command(
                        "($backup->{'post'}) 2>&1 </dev/null");
                print &text('email_post',
                      "<tt>".&html_escape($backup->{'post'})."</tt>")."<br>\n".
@@ -110,7 +116,6 @@ if ($in{'run'}) {
        &webmin_log("run", "backup", $backup->{'dest'}, $backup);
        &ui_print_footer("edit.cgi?id=$in{'id'}", $text{'edit_return'},
                         "index.cgi?mode=sched", $text{'index_return'});
-       exit;
        }
 else {
        &redirect("index.cgi?mode=sched");
index 3a19c7d..7343f29 100755 (executable)
@@ -1,12 +1,14 @@
 # uninstall.pl
 # Called when webmin is uninstalled
 
+use strict;
+use warnings;
 require 'backup-config-lib.pl';
 
 sub module_uninstall
 {
-foreach $backup (&list_backups()) {
-       $job = &find_cron_job($backup);
+foreach my $backup (&list_backups()) {
+       my $job = &find_cron_job($backup);
        if ($job) {
                &cron::delete_cron_job($job);
                }