晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /proc/thread-self/root/scripts/ |
Upload File : |
#!/usr/local/cpanel/3rdparty/bin/perl
# cpanel - scripts/remove_dovecot_index_files Copyright 2022 cPanel, L.L.C.
# All rights reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
package scripts::remove_dovecot_index_files;
use strict;
use File::Find ();
use File::Spec ();
use Getopt::Long ();
use Cpanel::Config::LoadCpConf ();
use Cpanel::PwCache ();
use Cpanel::Reseller ();
use Cpanel::Config::Users ();
use Cpanel::Config::LoadUserOwners ();
use Cpanel::AccessIds::ReducedPrivileges ();
exit run(@ARGV) unless caller();
my $verbose = 0;
sub run {
my @cmdline_args = @_;
return usage(1) if !@cmdline_args;
unless ( $> == 0 && $< == 0 ) {
return usage( 1, "[!] This program can only be run by root!\n" );
}
my $opts = {};
Getopt::Long::GetOptionsFromArray(
\@cmdline_args,
'all' => \$opts->{'all'},
'reseller=s@' => \$opts->{'reseller'},
'user=s@' => \$opts->{'user'},
'verbose' => \$verbose,
'help|h' => \$opts->{'help'},
);
return usage(0) if $opts->{'help'};
my $cpconf_ref = Cpanel::Config::LoadCpConf::loadcpconf();
if ( $cpconf_ref->{'mailserver'} ne 'dovecot' ) {
return usage( 1, "[!] The configured mailserver is not Dovecot. Action aborted.\n" );
}
return process_all_users_on_server() if $opts->{'all'};
process_reseller( $opts->{'reseller'} ) if $opts->{'reseller'} && scalar @{ $opts->{'reseller'} };
process_cpanel_user( $opts->{'user'} ) if $opts->{'user'} && scalar @{ $opts->{'user'} };
return 0;
}
sub process_cpanel_user {
my $cpusers_to_process = shift;
my ( $index, $total ) = ( 1, scalar @{$cpusers_to_process} );
foreach my $cpuser ( @{$cpusers_to_process} ) {
print "[*] ($index/$total) Processing cPanel user: '$cpuser' …\n";
$index++;
my $homedir = Cpanel::PwCache::gethomedir($cpuser);
my $maildir = File::Spec->catfile( $homedir, 'mail' );
if ( !-d $maildir ) {
print "[!] User's maildir was not found: $maildir - $!\n";
next;
}
my $maxdepth = File::Spec->splitdir($maildir) + 4;
my $purge_index_files_codref = sub {
File::Find::find(
{
'wanted' => sub {
# Dovecot index files are in "$homedir/mail/domain.tld/emailuser/<dirname>".
# So we limit the depth here to what was determined above.
return if File::Spec->splitdir($File::Find::name) > $maxdepth;
# Remove files that match:
# dovecot.index
# dovecot.index.cache
# dovecot.index.log
# dovecot.index.log.\d+ (rotated log files)
return if $_ !~ m/^dovecot\.index(\.cache|\.log(\.\d+)?)?$/;
print "Unlinking '$File::Find::name' …\n" if $verbose;
if ( -e $File::Find::name && -f $File::Find::name ) {
unlink $File::Find::name or print "Failed to unlink '$File::Find::name': $!\n";
}
},
'no_chdir' => 0, # default, but setting to be explicit about the usage.
'follow_skip' => 2, # ignore any duplicate files and directories
},
$maildir
);
};
eval { Cpanel::AccessIds::ReducedPrivileges::call_as_user( $purge_index_files_codref, $cpuser ) };
print "[+] '$cpuser' processed.\n";
}
return;
}
sub process_reseller {
my $resellers_to_process = shift;
foreach my $reseller ( @{$resellers_to_process} ) {
print "[*] Processing Reseller: '$reseller' …\n";
if ( !Cpanel::Reseller::isreseller($reseller) ) {
print "[!] '$reseller' is not reseller.\n\n";
next;
}
my $owners_hr = Cpanel::Config::LoadUserOwners::loadtrueuserowners( {} );
if ( !( $owners_hr->{$reseller} && 'ARRAY' eq ref $owners_hr->{$reseller} ) ) {
print "[!] Failed to fetch list of accounts owned by reseller, '$reseller'.\n\n";
return;
}
print "\n";
process_cpanel_user( $owners_hr->{$reseller} );
print "\n";
}
return;
}
sub process_all_users_on_server {
my $cpusers = Cpanel::Config::Users::getcpusers();
if ( !( $cpusers && 'ARRAY' eq ref $cpusers ) ) {
print "[!] Failed to fetch list of cPanel accounts on server.\n";
return;
}
print "[*] Processing all cPanel users on the server …\n\n";
process_cpanel_user($cpusers);
print "\n[+] Finished processing all cPanel users on the server.\n";
return 0;
}
sub usage {
my ( $retval, $msg ) = @_;
my $fh = $retval ? \*STDERR : \*STDOUT;
if ( !defined $msg ) {
$msg = <<USAGE;
$0
Utility to remove Dovecot index files. Available options:
--user [cPanel username]
Remove Dovecot index files from all email accounts setup under the specified cPanel user.
Can be specified more than once, to process multiple users at once.
--reseller [reseller username]
Remove Dovecot index files from all email accounts setup under all the cPanel accounts owned by the specified Reseller.
Can be specified more than once, to process multiple resellers at once.
--all
Remove Dovecot index files from all email accounts setup on the server.
--verbose
Prints the full paths of the files being removed.
--help
Prints this help text.
USAGE
}
print {$fh} $msg;
return $retval;
}
1;