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/fixbinpath
#!/usr/bin/perl
# cpanel - fixbinpath                             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::Path ();

my @NOEXECOK  = qw( /usr/lib/php.ini );
my @MISSINGOK = qw( setfacl );
my %GOODBINS  = (
    'setfacl'      => '/usr/bin/setfacl',
    'sum'          => '/bin/sum',
    'su'           => '/bin/su',
    'chown'        => '/bin/chown',
    'passwd'       => '/bin/passwd',
    'mkdir'        => '/bin/mkdir',
    'cp'           => '/bin/cp',
    'rm'           => '/bin/rm',
    'mv'           => '/bin/mv',
    'chmod'        => '/bin/chmod',
    'pwd'          => '/bin/pwd',
    'tar'          => '/bin/tar',
    'gzip'         => '/bin/gzip',
    'sed'          => '/bin/sed',
    'sh'           => '/bin/sh',
    'date'         => '/bin/date',
    'ls'           => '/bin/ls',
    'rdate'        => '/usr/bin/rdate',
    'ifconfig'     => '/sbin/ifconfig',
    'expect'       => '/usr/bin/expect',
    'spamd'        => '/usr/bin/spamd',
    'spamc'        => '/usr/bin/spamc',
    'wget'         => '/usr/bin/wget',
    'spamassassin' => '/usr/bin/spamassassin',
    'php.ini'      => '/usr/lib/php.ini',
    'python'       => '/usr/bin/python',
);

my @path = qw(
  /bin
  /usr/bin
  /usr/local/bin
  /sbin
  /usr/sbin
  /usr/local/sbin
  /usr/lib
  /usr/local/lib
);

# Remove bad symlink created by installer
if ( -l '/usr/local/apache/conf/etc' ) {
    my $link = readlink '/usr/local/apache/conf/etc';
    if ( $link eq 'etc' ) {
        unlink '/usr/local/apache/conf/etc';
    }
}

foreach my $bin ( keys %GOODBINS ) {
    if ( -e $GOODBINS{$bin} ) {
        if ( !grep( /^$GOODBINS{$bin}$/, @NOEXECOK ) && !-x $GOODBINS{$bin} ) {
            print "$GOODBINS{$bin} is not executable! Please check your installation.\n";
        }
    }
    else {
        my $foundbin = 0;
        foreach my $dir (@path) {
            next if ($foundbin);
            if ( -e $dir . '/' . $bin && !-l $dir . '/' . $bin ) {
                print "Linking ${dir}/${bin} to $GOODBINS{$bin}\n";
                Cpanel::Path::relativesymlink( $dir . '/' . $bin, $GOODBINS{$bin} );
                $foundbin = 1;
            }
            elsif ( -e $dir . '/' . $bin && -l $dir . '/' . $bin ) {
                my $realbin = Cpanel::Path::relative2abspath( readlink( $dir . '/' . $bin ), $dir . '/' . $bin );
                if ( -x $realbin || grep( /^$GOODBINS{$bin}$/, @NOEXECOK ) ) {
                    print "Linking $realbin to $GOODBINS{$bin}\n";
                    Cpanel::Path::relativesymlink( $realbin, $GOODBINS{$bin} );
                    $foundbin = 1;
                }
                else {
                    print "Symlink target [${dir}/${bin} -> $realbin] is not executable! Please check your installation.\n";
                }
            }
        }
        if ( !$foundbin && !grep( /^${bin}$/, @MISSINGOK ) ) {
            print "Unable to locate working ${bin}! Please check your installation.\n";
        }
    }
}