Added cron job to cleanup /tmp/.webmin
authorJamie Cameron <jcameron@webmin.com>
Mon, 27 Aug 2007 04:38:04 +0000 (04:38 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 27 Aug 2007 04:38:04 +0000 (04:38 +0000)
38 files changed:
config-aix
config-cobalt-linux
config-coherent-linux
config-corel-linux
config-debian-linux
config-freebsd
config-generic-linux
config-gentoo-linux
config-hpux
config-irix
config-lib.pl
config-macos
config-mandrake-linux
config-msc-linux
config-netbsd
config-open-linux
config-openbsd
config-openmamba-linux [new file with mode: 0644]
config-openserver
config-osf1
config-redhat-linux
config-slackware-linux
config-sol-linux
config-solaris
config-suse-linux
config-trustix-linux
config-turbo-linux
config-united-linux
config-unixware
config-windows
cron/cron-lib.pl
cron/postinstall.pl [new file with mode: 0644]
cron/tempdelete.pl [new file with mode: 0644]
cron/uninstall.pl [new file with mode: 0644]
webmin/CHANGELOG
webmin/change_advanced.cgi
webmin/edit_advanced.cgi
webmin/lang/en

index e1ab67a..af95a25 100644 (file)
@@ -5,3 +5,4 @@ by_view=0
 passwd_file=/etc/security/passwd
 passwd_uindex=0
 passwd_pindex=1
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index b6a94fc..5e7c0ae 100644 (file)
@@ -5,3 +5,4 @@ passwd_file=/etc/master.passwd
 passwd_uindex=0
 passwd_pindex=1
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index 3e1e7a6..70a142b 100644 (file)
@@ -5,3 +5,4 @@ passwd_file=/etc/passwd
 passwd_uindex=0
 passwd_pindex=1
 by_view=0
+tempdelete_days=7
index 038a997..296d471 100644 (file)
@@ -6,3 +6,4 @@ passwd_file=/etc/passwd
 passwd_uindex=0
 passwd_pindex=1
 by_view=0
+tempdelete_days=7
index dcf2125..4a78f8e 100644 (file)
@@ -351,7 +351,5 @@ foreach my $c (@$info_order) {
 return @new_order;
 }
 
-
-
 1;
 
index 4dde761..79ec4a6 100644 (file)
@@ -5,3 +5,4 @@ passwd_file=nidump passwd . |
 passwd_uindex=0
 passwd_pindex=1
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index e204bea..4e13a7a 100644 (file)
@@ -5,3 +5,4 @@ passwd_file=/etc/master.passwd
 passwd_uindex=0
 passwd_pindex=1
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index 0d8071a..8f4ca83 100644 (file)
@@ -6,3 +6,4 @@ passwd_uindex=0
 passwd_pindex=1
 
 by_view=0
+tempdelete_days=7
diff --git a/config-openmamba-linux b/config-openmamba-linux
new file mode 100644 (file)
index 0000000..962fac8
--- /dev/null
@@ -0,0 +1,10 @@
+find_pid_command=ps auwwwx | grep NAME | grep -v grep | awk '{ print $2 }'
+path=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
+ld_env=LD_LIBRARY_PATH
+passwd_file=/etc/shadow
+passwd_uindex=0
+passwd_pindex=1
+passwd_cindex=2
+passwd_mindex=4
+by_view=0
+tempdelete_days=7
index cc343f9..19e7183 100644 (file)
@@ -6,3 +6,4 @@ passwd_uindex=0
 passwd_pindex=1
 
 by_view=0
+tempdelete_days=7
index 50bf577..91f8910 100644 (file)
@@ -6,3 +6,4 @@ passwd_file=/etc/shadow
 passwd_uindex=0
 passwd_pindex=1
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index f3e8d42..ae796c6 100644 (file)
@@ -8,3 +8,4 @@ passwd_cindex=2
 passwd_mindex=4
 by_view=0
 no_hostname_f=1
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index d51513c..6821580 100644 (file)
@@ -8,3 +8,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index d919982..962fac8 100644 (file)
@@ -7,3 +7,4 @@ passwd_pindex=1
 passwd_cindex=2
 passwd_mindex=4
 by_view=0
+tempdelete_days=7
index 5dba408..c6fefad 100644 (file)
@@ -6,3 +6,4 @@ passwd_file=/etc/shadow
 passwd_uindex=0
 passwd_pindex=1
 by_view=0
+tempdelete_days=7
index e94c6da..b480179 100644 (file)
@@ -1,2 +1,3 @@
 path=c:/perl/bin;c:/windows/system32;c:/windows
 tempdir=c:/webmintemp
+tempdelete_days=7
index 5c4d0c7..f107139 100644 (file)
@@ -16,6 +16,7 @@ if ($module_info{'usermin'}) {
 else {
        $range_cmd = "$module_config_directory/range.pl";
        }
+$temp_delete_cmd = "$module_config_directory/tempdelete.pl";
 $cron_temp_file = &transname();
 use Time::Local;
 
diff --git a/cron/postinstall.pl b/cron/postinstall.pl
new file mode 100644 (file)
index 0000000..5728ba3
--- /dev/null
@@ -0,0 +1,30 @@
+
+require 'cron-lib.pl';
+
+sub module_install
+{
+# Create a cron job to delete old files in /tmp/.webmin
+eval {
+       $main::error_must_die = 1;
+       local @jobs = &cron::list_cron_jobs();
+       local ($job) = grep { $_->{'user'} eq 'root' &&
+                             $_->{'command'} eq $temp_delete_cmd } @jobs;
+       if (!$job) {
+               $job = { 'user' => 'root',
+                        'active' => 1,
+                        'command' => $temp_delete_cmd,
+                        'mins' => int(rand()*60),
+                        'hours' => int(rand()*24),
+                        'days' => '*',
+                        'months' => '*',
+                        'weekdays' => '*', };
+               &create_cron_job($job);
+               &create_wrapper($temp_delete_cmd, $module_name,"tempdelete.pl");
+               }
+       };
+if ($@) {
+       print STDERR "Failed to setup /tmp cleanup cron job : $@\n";
+       }
+}
+
+
diff --git a/cron/tempdelete.pl b/cron/tempdelete.pl
new file mode 100644 (file)
index 0000000..fe1f1b1
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/local/bin/perl
+# Delete any Webmin temp files older than 7 days
+
+$no_acl_check++;
+require './cron-lib.pl';
+
+if ($ARGV[0] eq "-debug" || $ARGV[0] eq "--debug") {
+       shift(@ARGV);
+       $debug = 1;
+       }
+
+# Don't run if disabled
+if (!$gconfig{'tempdelete_days'}) {
+       print "Temp file clearing is disabled\n";
+       exit(0);
+       }
+if ($gconfig{'tempdir'}) {
+       print "Temp file clearing is not done for the custom directory $gconfig{'tempdir'}\n";
+       exit(0);
+       }
+
+$tempdir = &transname();
+$tempdir =~ s/\/([^\/]+)$//;
+if ($debug) {
+       print "Checking temp directory $tempdir\n";
+       }
+
+$cutoff = time() - $gconfig{'tempdelete_days'}*24*60*60;
+opendir(DIR, $tempdir);
+foreach my $f (readdir(DIR)) {
+       next if ($f eq "." || $f eq "..");
+       local @st = lstat("$tempdir/$f");
+       if ($st[9] < $cutoff) {
+               if ($debug) {
+                       print "Deleting $tempdir/$f\n";
+                       }
+               &unlink_file("$tempdir/$f");
+               }
+       }
+closedir(DIR);
+
diff --git a/cron/uninstall.pl b/cron/uninstall.pl
new file mode 100644 (file)
index 0000000..325ad81
--- /dev/null
@@ -0,0 +1,21 @@
+
+require 'cron-lib.pl';
+
+sub module_uninstall
+{
+# Remove the cron job to delete old files in /tmp/.webmin
+eval {
+       $main::error_must_die = 1;
+       local @jobs = &cron::list_cron_jobs();
+       local ($job) = grep { $_->{'user'} eq 'root' &&
+                             $_->{'command'} eq $temp_delete_cmd } @jobs;
+       if ($job) {
+               &delete_cron_job($job);
+               }
+       };
+if ($@) {
+       print STDERR "Failed to remove /tmp cleanup cron job : $@\n";
+       }
+}
+
+
index 9fab0e2..8d787bd 100644 (file)
@@ -64,3 +64,5 @@ Added a tab showing details of the current cert, with a link to download in PEM
 Added an option to the Authentication page to block users with too many failed logins, as well as hosts.
 Created the new Blocked Hosts and Users page to show blocks currently in force, and allow them to be cleared.
 Added an option to the Ports and Addresses page to control if Webmin attempts to to reverse-resolve the connected-to IP address when issuing redirects, such as from non-SSL to SSL mode.
+---- Changes since 1.360 ----
+Added a field to the Advanced Options page to control the number of days that files in /tmp/.webmin are kept before automatic deletion.
index 9179fcb..38e970f 100755 (executable)
@@ -15,6 +15,17 @@ else {
        $gconfig{'tempdir'} = $in{'tempdir'};
        }
 
+# Save temp clearing options
+$gconfig{'tempdirdelete'} = $in{'tempdirdelete'};
+if ($in{'tempdelete_def'}) {
+       $gconfig{'tempdelete_days'} = '';
+       }
+else {
+       $in{'tempdelete'} =~ /^[0-9\.]+$/ ||
+               &error($text{'advanced_etempdelete'});
+       $gconfig{'tempdelete_days'} = $in{'tempdelete'};
+       }
+
 # Save per-module temp dirs
 for($i=0; defined($tmod = $in{'tmod_'.$i}); $i++) {
        next if (!$tmod);
index 19b0d36..26abe67 100755 (executable)
@@ -11,7 +11,15 @@ print &ui_table_start($text{'advanced_header'}, undef, 2);
 # Global temp directory
 print &ui_table_row($text{'advanced_temp'},
                    &ui_opt_textbox("tempdir", $gconfig{'tempdir'},
-                                   30, $text{'advanced_tempdef'}));
+                                   30, $text{'advanced_tempdef'})."<br>".
+                   &ui_checkbox("tempdirdelete", 1, $text{'advanced_tdd'},
+                                $gconfig{'tempdirdelete'}));
+
+# Temp files clearing period
+print &ui_table_row($text{'advanced_tempdelete'},
+                   &ui_opt_textbox("tempdelete", $gconfig{'tempdelete_days'},
+                                   5, $text{'advanced_nodelete'})." ".
+                   $text{'advanced_days'});
 
 # Per-module temp directories
 @mods = sort { $a->{'desc'} cmp $b->{'desc'} } &get_all_module_infos();
index c69724f..6c40fd5 100644 (file)
@@ -720,6 +720,10 @@ advanced_title=Advanced Options
 advanced_header=Advanced and experimental options
 advanced_temp=Temporary files directory
 advanced_tempdef=Default (<tt>/tmp/.webmin</tt>)
+advanced_tdd=Clear temp files in non-standard directory?
+advanced_tempdelete=Maximum age of temporary files
+advanced_nodelete=Unlimited
+advanced_days=days
 advanced_preload=Pre-load Webmin functions library?
 advanced_err=Failed to save advanced options
 advanced_etemp=Missing or non-existant temporary files directory
@@ -732,6 +736,7 @@ advanced_stack=Show stack trace for error messages?
 advanced_showstderr=Show Perl errors in browser?
 advanced_umask=Umask (unset permission bits) for created files
 advanced_eumask=Umask must be a 3-digit octal number
+advanced_etempdelete=Missing or invalid maximum age of temporary files
 
 syslog_errorlog=Webmin error log