In Cpanel, performing an EasyApache update to Apache 2.x & PHP 5.x breaks PEAR more often than not.  Cpanel admins and users are left with only the very basic PEAR modules, and are unable to use the Module Installer front-end due to error messages indicating that every package one attempts to install is invalid.
     Attempting to install Net_URL, for instance, results in the following:

downloading Net_URL-1.0.15.tgz …
Starting to download Net_URL-1.0.15.tgz (6,303 bytes)
…..done: 6,303 bytes
Could not get contents of package “/root/tmp/pear/cache/Net_URL-1.0.15.tgz”. Invalid tgz file.
Download of “pear/Net_URL” succeeded, but it is not a valid package archive
Error: cannot download “pear/Net_URL”
Download failed
install failed

     The problem is caused by differences in the way PHP 5.2.x parses code, and can be fixed by manually patching the listContent function in PEAR’s Archive_Tar package.  Open /usr/local/lib/php/Archive/Tar.php and look at the offending Line 220:

//            if (!$this->_extractList('', $v_list_detail, "list", '', '')) {
            $x = $this->_extractList('', $v_list_detail, "list", '', '');
            if (!$x) {

     We commented it out, and added two more lines.  Now, from both the command-line & WHM interface, everything magically works.

Note: In some instances (depending on your OS, Cpanel version & build options — multiple servers show no uniformity), you’ll have to make the same change to /usr/lib/php/Archive/Tar.php.

Tags : | add comments

/var/log/secure gets slammed with these errors every time anyone tries to connect to any service which requires authorization:

Deprecated pam_stack module called from service
     [servicename]
pam_env([servicename]:setcred):
     Unable to open env file: /etc/environment

The fix has been elusive, as Ensim continues to re-write the pam.d files, but running this script will take care of both issues posthaste.

Save this as /usr/local/sbin/fix_pam:

#!/bin/sh

# -----------------------------------------------------------------------------
#
# fix_pam ver 1.0a
#
# (c) Copyright 2007 Mark Steel / Catalyst IT. All rights reserved.
#
# This script may only be distributed unmodified.
#
# This script is intended to be used to fix the "depracated pam stack module"
# errors on servers and virtual hosts.
#
# NOTE: THIS SCRIPT IS NOT GPL
#
# -----------------------------------------------------------------------------

perl -i -p -e 's/required(.*)pam_stack.so service=system-auth/include\tsystem-auth/' /etc/pam.d/*
perl -i -p -e 's/pam_pwdb/pam_unix/' /etc/pam.d/*
perl -i -p -e 's/pam_env.so$/pam_env.so readenv=0/' /etc/pam.d/system-auth

perl -i -p -e 's/pam_env.so$/pam_env.so readenv=0/' /home/virtual/FILESYSTEMTEMPLATE/siteinfo/etc/pam.d/system-auth
VIRTUAL=`find /home/virtual/FILESYSTEMTEMPLATE -name pam.d`
for i in $VIRTUAL; do
perl -i -p -e 's/required(.*)pam_stack.so service=system-auth/include\tsystem-auth/' $i/*
perl -i -p -e 's/pam_pwdb/pam_unix/' $i/*
done

DOMAINS=`sitelookup -a site_root`
for i in $DOMAINS; do
perl -i -p -e 's/required(.*)pam_stack.so service=system-auth/include\tsystem-auth/' $i/etc/pam.d/*
perl -i -p -e 's/pam_pwdb/pam_unix/' $i/etc/pam.d/*
perl -i -p -e 's/pam_env.so$/pam_env.so readenv=0/' $i/etc/pam.d/system-auth
done

service saslauthd restart

Run once, and you’re golden.

Tags : | add comments