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/fixmysqlpasswordopt
#!/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;
}