Added cron job to cleanup /tmp/.webmin
This commit is contained in:
parent
ae98dd0927
commit
14c86dfab0
@ -5,3 +5,4 @@ by_view=0
|
||||
passwd_file=/etc/security/passwd
|
||||
passwd_uindex=0
|
||||
passwd_pindex=1
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -5,3 +5,4 @@ passwd_file=/etc/master.passwd
|
||||
passwd_uindex=0
|
||||
passwd_pindex=1
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -5,3 +5,4 @@ passwd_file=/etc/passwd
|
||||
passwd_uindex=0
|
||||
passwd_pindex=1
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -6,3 +6,4 @@ passwd_file=/etc/passwd
|
||||
passwd_uindex=0
|
||||
passwd_pindex=1
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -351,7 +351,5 @@ foreach my $c (@$info_order) {
|
||||
return @new_order;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
@ -5,3 +5,4 @@ passwd_file=nidump passwd . |
|
||||
passwd_uindex=0
|
||||
passwd_pindex=1
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -5,3 +5,4 @@ passwd_file=/etc/master.passwd
|
||||
passwd_uindex=0
|
||||
passwd_pindex=1
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -6,3 +6,4 @@ passwd_uindex=0
|
||||
passwd_pindex=1
|
||||
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
10
config-openmamba-linux
Normal file
10
config-openmamba-linux
Normal file
@ -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
|
@ -6,3 +6,4 @@ passwd_uindex=0
|
||||
passwd_pindex=1
|
||||
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -6,3 +6,4 @@ passwd_file=/etc/shadow
|
||||
passwd_uindex=0
|
||||
passwd_pindex=1
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -8,3 +8,4 @@ passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
no_hostname_f=1
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -8,3 +8,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -7,3 +7,4 @@ passwd_pindex=1
|
||||
passwd_cindex=2
|
||||
passwd_mindex=4
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -6,3 +6,4 @@ passwd_file=/etc/shadow
|
||||
passwd_uindex=0
|
||||
passwd_pindex=1
|
||||
by_view=0
|
||||
tempdelete_days=7
|
||||
|
@ -1,2 +1,3 @@
|
||||
path=c:/perl/bin;c:/windows/system32;c:/windows
|
||||
tempdir=c:/webmintemp
|
||||
tempdelete_days=7
|
||||
|
@ -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;
|
||||
|
||||
|
30
cron/postinstall.pl
Normal file
30
cron/postinstall.pl
Normal file
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
41
cron/tempdelete.pl
Normal file
41
cron/tempdelete.pl
Normal file
@ -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);
|
||||
|
21
cron/uninstall.pl
Normal file
21
cron/uninstall.pl
Normal file
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user