File: //proc/self/root/proc/self/root/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";
}
}
}