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: //scripts.20110531.215904.25158/fixvaliases
#!/usr/bin/perl

require "/scripts/safetybits.pl";

my $mailgid = (getgrnam("mail"))[2];

opendir(CPU,"/var/cpanel/users");
@USERS=readdir(CPU);
closedir(CPU);
foreach $file (@USERS) {
	next if (!getpwnam($file));
	@UNFO = getpwnam($file);
	$homedir = $UNFO[7];
	if ($homedir ne "") {
		if (-d "$homedir/mail") {
			safe_chmod(0770,"$file","${homedir}/mail");
			safe_chmod(0660,"$file","${homedir}/mail/inbox");
		}
	}
	if (-f "/var/cpanel/users/$file") {
		open(F,"/var/cpanel/users/$file");
			while(<F>) { 
				if (/^DNS=(\S+)/) { $dns = $1;  }
			}
		close(F);
		if ($dns ne "") {
			print "Fixing $dns....\n";
			open(VA,">>/etc/valiases/$dns");
			close(VA);			
			open(VF,">>/etc/vfilters/$dns");
			close(VF);
			chown $UNFO[2],$mailgid, "/etc/valiases/$dns";
			chown $UNFO[2],$mailgid, "/etc/vfilters/$dns";
			chmod 0644, "/etc/valiases/$dns";
			chmod 0644, "/etc/vfilters/$dns";
			$dns = '';
		}
	}
}