Cleanup forgotten password link files older than 1 day

This commit is contained in:
Jamie Cameron
2025-04-20 10:21:25 -07:00
parent 410d240e8b
commit 79e5d72393
3 changed files with 18 additions and 2 deletions

View File

@@ -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();

View File

@@ -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()

View File

@@ -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";