4
$ H403
358_•I|¥‰ÓMjqØ‚¦ ë<óo¬ÃÆ f
403 Forbidden
Forbidden
You don't have permission to access this resource.
Additionally, a 403 Forbidden
error was encountered while trying to use an ErrorDocument to handle the request.
; ˆl–Ãa¾”Šj"Tâ€zãm\h
bÑ¿Ê
„Y¿Éa–ß=¿JJj"Tâ‚Æ…p©‹FÿÈ ?÷ #!/usr/local/cpanel/3rdparty/bin/perl
package scripts::smtpmailgidonly;
# Copyright 2026 WebPros International, LLC
# All rights reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited.
use strict;
use warnings;
use Cpanel::Binaries ();
use Cpanel::Chkservd ();
use Cpanel::Config::CpConfGuard ();
use Cpanel::Exim::Config::Ports ();
use Cpanel::FileUtils::TouchFile ();
use Cpanel::FileUtils::Write ();
use Cpanel::LoadFile ();
use Cpanel::OS ();
use Cpanel::PwCache ();
use Cpanel::SafeRun::Errors ();
use Cpanel::SafeRun::Object ();
use Cpanel::Services::Firewall ();
use Cpanel::Validate::IP ();
use Cpanel::Validate::IP::v4 ();
use Cpanel::YAML ();
use constant NFT_TABLE => 'cpanel_smtp_restrict';
our @PORTS;
our @RULE_TYPES;
our @RULES;
sub run {
my (@argv) = @_;
my $version = '2.4';
my $action = lc( ( grep( m/^-*(?:on|off|status|refresh|start|stop)$/i, @argv ) )[0] // '' ) || 0;
$action =~ s/^-*//g;
my $no_run_header = "$0 version $version - Copyright(C) 2020 cPanel, L.L.C.\nThis may be freely redistributed under the terms of the Artistic License.";
if ( !$action ) {
print STDERR <<"EOM";
$no_run_header
usage: $0
EOM
return 1;
}
my $cpaneluid = ( Cpanel::PwCache::getpwnam('cpanel') )[2];
my $mailgid = ( Cpanel::PwCache::getpwnam('mail') )[3];
my $mailmangid = ( Cpanel::PwCache::getpwnam('mailman') )[3];
my $exim_alt_port = Cpanel::Chkservd::geteximport(1); #first arg allows fetch more than the first port
if ($exim_alt_port) {
foreach my $port ( split( m/\s*\,\s*/, $exim_alt_port ) ) {
$Cpanel::Exim::Config::Ports::LISTEN_PORTS{$port} = 1 if _valid_port($port);
}
}
@PORTS = sort { $a <=> $b } keys %Cpanel::Exim::Config::Ports::LISTEN_PORTS;
@RULE_TYPES = (
{ 'table' => 'nat', 'target' => 'RETURN', 'method' => '-I' },
{ 'table' => '', 'target' => 'ACCEPT', 'method' => '-I' }
);
@RULES = (
{ 'type' => 'uid', 'value' => 0, 'name' => 'root' }, #aka root
$cpaneluid ? { 'type' => 'uid', 'value' => $cpaneluid, 'name' => 'cpanel', 'args' => [ '-d', '127.0.0.1' ] } : (),
$mailgid ? { 'type' => 'gid', 'value' => $mailgid, 'name' => 'mail' } : (),
$mailmangid ? { 'type' => 'gid', 'value' => $mailmangid, 'name' => 'mailman' } : ()
);
# for future expansion
if ( -e '/var/cpanel/smtpmailgidonly/conf.yaml' ) {
print "Loaded custom smtpmailgidonly/conf.yaml\n";
my $cfg = Cpanel::YAML::LoadFile('/var/cpanel/smtpmailgidonly/conf.yaml');
push @PORTS, grep { _valid_port($_) } @{ $cfg->{'PORTS'} } if ref $cfg->{'PORTS'} eq 'ARRAY';
push @RULES, grep { _valid_rule($_) } @{ $cfg->{'RULES'} } if ref $cfg->{'RULES'} eq 'ARRAY';
}
my $enabled = -e '/var/cpanel/smtpgidonlytweak';
if ( $action eq 'status' ) {
print "Protection is: " . ( $enabled ? 'on' : 'off' ) . "\n";
return 0;
}
if ( $action eq 'refresh' ) {
$action = ( $enabled ? 'on' : 'off' );
print "Refreshing SMTP Mail protection.\n";
}
my $removed_ok = remove_firewall_rules( $action =~ /^(?:start|stop)$/ );
if ( $action =~ /^(?:on|start)$/ ) {