|
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64 User : jackjohn ( 502) PHP Version : 5.3.17 Disable Function : NONE Directory : /proc/self/root/scripts/ |
Upload File : |
#!/usr/local/cpanel/3rdparty/bin/perl
# cpanel - scripts/fixmysqlpasswordopt Copyright(c) 2013 cPanel, Inc.
# 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::AccessIds ();
use Cpanel::FileUtils::Write ();
use Cpanel::Logger ();
run(@ARGV) unless caller;
sub run {
my @args = @_;
die "This script does not take any arguments\n" if @args;
my $logger = Cpanel::Logger->new();
opendir( my $dh, '/var/cpanel/users' );
my @users = readdir $dh;
close $dh;
push @users, 'root';
my $fixed = 0;
for my $user (@users) {
my $userhome = ( getpwnam $user )[7] or next;
my $fixer = sub {
alarm 10 unless $user eq 'root';
my $file = "$userhome/.my.cnf";
# Do not edit in place due to over-quota concerns. Use writefile instead.
if ( -f $file and open my $cnf_fh, "<", $file ) {
my $my_cnf = do {
local $/;
readline $cnf_fh;
};
close $cnf_fh;
if ( $my_cnf =~ s/^pass=/password=/m ) {
my $original_perms = ( stat(_) )[2] & 0777;
Cpanel::FileUtils::Write::writefile( $file, $my_cnf, $original_perms );
return 1;
}
}
return 0;
};
if ( $user eq 'root' ) {
$fixed += $fixer->();
}
else {
$fixed += Cpanel::AccessIds::do_as_user( $user, $fixer );
}
}
$logger->info("Fixed $fixed .my.cnf files.");
return;
}