MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //proc/self/root/proc/self/root/scripts.20110531.215904.25158/spamassassindisable
#!/usr/bin/perl
# cpanel - spamassassindisable                    Copyright(c) 2010 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

BEGIN { unshift @INC, '/usr/local/cpanel'; }

use strict;
use Cpanel::Usage              ();
use Cpanel::SafeFile           ();
use Cpanel::Config             ();
use Cpanel::Config::LoadCpConf ();

$| = 1;

my $quiet = 0;
my $force = 0;
my %opts  = ( 'q' => \$quiet, 'quiet' => \$quiet, 'f' => \$force, 'force' => \$force );

Cpanel::Usage::wrap_options( \@ARGV, \&usage, \%opts );

unless ($quiet) {
    print "??????????????????????????????????????????????????????????????????\n";
    print "This will disable SpamAssassin filtering for all accounts\n";
    print "on the server. If you do not wish to do this, then hit Ctrl-C now.\n";
    print "??????????????????????????????????????????????????????????????????\n\n";
}
unless ($force) {
    print "Sleeping for 5 seconds ... (Ctrl-C to abort)\n";
    sleep 5;
}

if ( !-e '/etc/passwd' ) {
    die "/etc/passwd does not exist!";
}

my @homedirs;

my $passwdlock = Cpanel::SafeFile::safeopen( \*PASS, '<', '/etc/passwd' )
  || die "Unable to open /etc/passwd: $!";
while (<PASS>) {
    my ( $uid, $homedir ) = ( split( /:/, $_ ) )[ 2, 5 ];
    next if ( int($uid) < 500 );
    if ( -d $homedir ) {
        push( @homedirs, $homedir );
    }
}
Cpanel::SafeFile::safeclose( \*PASS, $passwdlock );

my $removed = 0;
foreach my $homedir (@homedirs) {
    if ( -e $homedir . '/.spamassassinboxenable' ) {
        unless ($quiet) {
            print "Unlinking $homedir/.spamassassinboxenable\n";
        }
        unlink( $homedir . '/.spamassassinboxenable' );
        $removed = 1;
    }
    if ( -e $homedir . '/.spamassassinenable' ) {
        unless ($quiet) {
            print "Unlinking $homedir/.spamassassinenable\n";
        }
        unlink( $homedir . '/.spamassassinenable' );
        $removed = 1;
    }
}

unless ($quiet) {
    print "Updating /var/cpanel/cpanel.config\n";
}

my $cpconf_ref = Cpanel::Config::LoadCpConf::loadcpconf();
$cpconf_ref->{'skipspamassassin'} = 1;
$cpconf_ref->{'skipspambox'}      = 1;
if ( !Cpanel::Config::savecpconf($cpconf_ref) ) {
    warn "Unable to write new cpanel.config: $!";
}

unless ($quiet) {
    if ($removed) {
        print "Done\n";
    }
    else {
        print "No accounts currently have spamassassin enabled.\n";
    }
}

sub usage {
    print <<EOM;
spamassassindisable - disable spamassassin for all accounts

    Options:
        --force     bypass 5 second sleep
        --quiet     do not provide any ouput on STDOUT
        --help      display this message and exit

The force and quiet are useful when running this
script as a part of an automated process (e.g. cron).

EOM
    exit;
}