diff --git a/cron/cleanup.pl b/cron/cleanup.pl index 63b20b19b..28b8d9f05 100755 --- a/cron/cleanup.pl +++ b/cron/cleanup.pl @@ -1,5 +1,5 @@ -#!/usr/local/bin/perl -# Clean up leftover Webmin temp files and locks, if configured +#!/usr/bin/perl +# Manually run the temp files cleanup function require './cron-lib.pl'; &cleanup_temp_files(); diff --git a/cron/cron-lib.pl b/cron/cron-lib.pl index 6e78bb1af..864ceb125 100755 --- a/cron/cron-lib.pl +++ b/cron/cron-lib.pl @@ -1608,6 +1608,20 @@ closedir(DIR); foreach (&get_miniserv_websockets_modules()) { &cleanup_miniserv_websockets(undef, $_); } + +# Delete forgot-password files older than 1 day +if (opendir(DIR, $main::forgot_password_link_dir)) { + my $cutoff = time() - 24*60*60; + foreach my $f (readdir(DIR)) { + next if ($f eq "." || $f eq ".."); + my $path = $main::forgot_password_link_dir."/".$f; + my @st = stat($path); + if ($st[9] < $cutoff) { + &unlink_file($path); + } + } + closedir(DIR); + } } =head2 list_cron_files() diff --git a/cron/postinstall.pl b/cron/postinstall.pl index bf98d8515..a4159196e 100755 --- a/cron/postinstall.pl +++ b/cron/postinstall.pl @@ -11,6 +11,8 @@ eval { 'func' => 'cleanup_temp_files', 'interval' => 3600 }; &webmincron::create_webmin_cron($cron, $temp_delete_cmd); + &create_wrapper($module_config_directory."/cleanup.pl", + $module_name, "cleanup.pl"); }; if ($@) { print STDERR "Failed to setup /tmp cleanup cron job : $@\n";