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/scripts.20110531.215904.25158/delpop
#!/usr/bin/perl
# cpanel - delpop                                 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::AcctUtils  ();
use Cpanel::PwCache    ();
use Cpanel::SafetyBits ();
use Cpanel::SafeFile   ();

my ( $email ) = @ARGV;

if ( !$email ) {
    print 'Please enter the pop account to be removed (ex. bob@sally.com)? ';
    chomp( $email = <STDIN> );
}

my ( $user, $domain ) = split( /\@/, $email );
my $owner = Cpanel::AcctUtils::getdomainowner( $domain, { 'default' => '' } );

if ( !$owner ) {
    die "Cannot find the owner of $domain, try rebuilding /etc/userdomains first with /scripts/updateuserdomains";
}

my ( $uid, $gid ) = ( getpwnam($owner) )[ 2, 3 ];
Cpanel::SafetyBits::setuids( $uid, $gid );

# This is very similar to the code in Cpanel::Email::_pop_exists
# but it would be a chore to make that module available just for
# this script.
my $ownerhomedir = ( Cpanel::PwCache::getpwnam( $owner ) )[7];
my $file = join '/', $ownerhomedir, 'etc', $domain, 'passwd';
$file =~ s/\.\.//g;
# Untaint
if ( -e $file ) {
    $file =~ m/^(.*)$/;
    $file = $1;
}
else {
    die "Unable to determine domain owner's passwd file.\n";
}
my $sflock = Cpanel::SafeFile::safeopen( \*PASSWD, '<', $file );
if ( !$sflock ) {
    die "Unable to read from domain owner's passwd file.\n";
}
my $result;
my $match_regex = qr/^\Q$user\E:/;
while ( my $line = <PASSWD> ) {
    chomp $line;
    if ( $line =~ $match_regex ) {
        $result = 1;
        last;
    }
}
Cpanel::SafeFile::safeclose( \*PASSWD, $sflock );
die "Account does not exist.\n" if !$result;

$ENV{'REMOTE_USER'} = $owner;
system '/usr/local/cpanel/cpanel-email', 'delpop', $user;
if ( $? != 0 ) {
   die "\nEmail account deletion failed ($?)\n";
}

print "Deleted $email for user $owner\n";