RVSiteBuilder / cPanel / PEAR / Pecl

Our customers recently started complaining that RV Site Builder stopped working. So I did the normal fix of running the following command as root over SSH:

# perl /usr/local/cpanel/whostmgr/docroot/cgi/rvsitebuilderinstaller/autoinstaller.cgi

After a while the installed quit with the error:

Cannot execute pear on path /usr/local/bin/pear

I thought this was a bit odd, as we have always compiled our PHP with PEAR and PECL support, but after searching for the Pecl and Pear binaries the script was correct – they didn’t exist.

I eventually found copies of the binaries in

/usr/local/cpanel/3rdparty/bin/

I copied these across to /usr/local/bin and re-ran the script – which worked correctly.

After a bit more research though, it turns out that PEAR is now included in the default PHP installation, and that by ticking the box inside Easy Apache inside cPanel you are in fact disabling PEAR rather than enabling – so if you un tick the box and re-run Easy Apache everything should be back to normal.

Posted in Uncategorized | Leave a comment

WHMCS .uk domains checkout

We are currently in the process of moving our billing software from AWBS to WHMCS.

One of the things that was annoying in AWBS was that when buying a UK Domain name (.co.uk etc) a client was given the option to enter a company number even when signing up as an Individual ( Individual registrations account for about 95%+ of uk domain registrations ). This confused clients, and probably made some people abandon the cart.

I was somewhat frustrated to see that WHMCS doesn’t seem to have addressed the situation any better, so I thought it was time to take things into my own hands. I’ve written some jQuery that removes the options for individual users. I’m sure there is a better way to do this – but for now this seems to work.

Your template (/templates/orderforms/web20cart/configuredomains.tpl) will have to look like this for this jQuery to work:

<div class="cartbox"> {if $domain.eppenabled}{$LANG.domaineppcode}
                    <p><input type="text" name="epp[{$num}]" size="20" value="{$domain.eppvalue}" />
                        {$LANG.domaineppcodedesc}</p>
                    {/if}
                    {if $domain.dnsmanagement}
                    <p><input type="checkbox" name="dnsmanagement[{$num}]"{if $domain.dnsmanagementselected} checked{/if} />
                    {$LANG.domaindnsmanagement} ({$domain.dnsmanagementprice})</p>
                    {/if}
                    {if $domain.emailforwarding}
                    <p><input type="checkbox" name="emailforwarding[{$num}]"{if $domain.emailforwardingselected} checked{/if} />
                    {$LANG.domainemailforwarding} ({$domain.emailforwardingprice})</p>
                    {/if}
                    {if $domain.idprotection}
                    <p><input type="checkbox" name="idprotection[{$num}]"{if $domain.idprotectionselected} checked{/if} />
                    {$LANG.domainidprotection} ({$domain.idprotectionprice})</p>
                    {/if}
                    {foreach key=domainfieldname item=domainfield from=$domain.fields}
                    <p><label>{$domainfieldname}:</label> {$domainfield}</p>
                    {/foreach} </div>

which generates this HTML:

<div class="cartbox">
  <p>
    <label>Legal Type:</label>
    <select name="domainfield[0][0]">
  </p>
  <p style="display: none;">
    <label>Company ID Number:</label>
    <input type="text" value="" name="domainfield[0][1]" size="30" disabled="">
  </p>
  <p>
    <label>Registrant Name:</label>
    <input type="text" value="" name="domainfield[0][2]" size="30">
    *
  </p>
  <p>
    <label>WHOIS Opt-out:</label>
    <input type="checkbox" name="domainfield[0][3]">
  </p>
</div>

And here is the jQuery. I included this at the bottom of the site, just before the close body tag.

// Disables Company Numbers for UK Domains on change
$(‘select[name^="domainfield"]‘).each(function(){
    $(this).parent().parent().find(‘select[name$="[0]"]’).change(function(){
                if ($(this).val() == "Individual" || $(this).val() == "Sole Trader"){
                        $(this).parent().parent().find(‘input[name$="[1]"]’).attr("disabled", true);
                        $(this).parent().parent().find(‘input[name$="[1]"]’).parent().hide();
                }
                else{
                        $(this).parent().parent().find(‘input[name$="[1]"]’).removeAttr("disabled");
                        $(this).parent().parent().find(‘input[name$="[1]"]’).parent().show();
                }
        })
});
// Disables Company Numbers for UK Domains on page load
$(‘select[name$="[0]"]’).each(function(){
                if ($(this).val() == "Individual" || $(this).val() == "Sole Trader"){
                        $(this).parent().parent().find(‘input[name$="[1]"]’).attr("disabled", true);
                        $(this).parent().parent().find(‘input[name$="[1]"]’).parent().hide();
                }
                else{
                        $(this).parent().parent().find(‘input[name$="[1]"]’).removeAttr("disabled");
                        $(this).parent().parent().find(‘input[name$="[1]"]’).parent().show();
                }
        });
Posted in Javascript, WHMCS | Leave a comment

Fix BIND Dynamic Update DoS Vulnerability , Cpanel WHM and CentOS / Redhat

Please see https://www.isc.org/node/474 for details!

CVE:
CVE-2009-0696
CERT:
VU#725188

Before you start!

Redhat users will find that bind is already updated via running up2date

These versions are big fixed – see http://rhn.redhat.com/errata/RHSA-2009-1180.html :

bind-utils-9.2.4-30.el4_8.4
bind-libs-9.2.4-30.el4_8.4
bind-devel-9.2.4-30.el4_8.4
ypbind-1.17.2-13
bind-9.2.4-30.el4_8.4

# rpm -qa | grep ‘bind’

will show you what versions you are running.

If you are running any other package management then running apt-get update or yum update should sort you out as these fixes have been push. Always make sure you have a backup of your named working directory though!

Step 1: Find out what version of bind you are running

# named -v

If you are running anything that isn’t one of these versions : 9.4.3-P3, 9.5.1-P3 or 9.6.1-P1 then you need to upgrade.  I found all my cpanel/WHM boxes were running BIND 9.2.4

Step 2: Make a backup of your working directories

# mkdir /backup/bind/

# cd /backup/bind

# cp -R /var/named zones

# cp /etc/named.conf named.conf

If all goes to plan then you won’t need this backup – but you can never be too careful!

Step3 : Download a new version of bind

# mkdir /backup/bind/bind-9.4.3-P3

# cd /backup/bind/bind-9.4.3-P3

# wget http://ftp.isc.org/isc/bind9/9.4.3-P3/bind-9.4.3-P3.tar.gz

# tar zxvf bind-9.4.3-P3.tar.gz

Step 4: Compile and install new Bind

# cd bind-9.4.3-P3

# ./configure

# make

# make install

Step5: Make sure your version is now updated

# named -v

Posted in Uncategorized | Tagged , , , , , , | Leave a comment

Changing default file permissions for SFTP

We primarily use SFTP for file transfers, and we encourage our customers to do the same.

One problem we’ve been having is that the default file permissions when files are uploaded in SFTP don’t match the umask set for that user, or the umask set on the server. This causes many php scripts to Internal Server Error. Files uploaded via normal FTP are fine, because the FTP service sets the permissions on the files with a umask configuration in the config file.

My basic solution to this, is to create a script that sits between SSH and SFTP and changes the umask as the user logs in:

> nano /opt/sftp-server.sh

#!/bin/bash
umask 022
/usr/libexec/openssh/sftp-server

Then edit the ssh_d config file (/etc/ssh/sshd_config) and edit the sftp SubSystem line to point to your script:

Subsystem       sftp    /opt/sftp-server.sh

Make sure you’ve set the permissions correctly on your new script:

> chmod 755 /opt/sftp-server.sh

Now files uploaded via SFTP should have the permissions 755!

Posted in Linux | Tagged , , , | Leave a comment

Installing the Ruby mysql-2.7 gem on OS X 10.4/ 10.5

Today I was updating a rails application, and editing some databases to convert them to mysql.

After changing my rails config file I started getting this error :

> db:test:prepare
(in /Users/tom/workspace/solitaire)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!

Strange, everything was working correctly on the other mysql databases and projects on my system. Anyway, I did as instructed :

> sudo gem install mysql
Password:
Building native extensions.  This could take a while…
ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

/opt/local/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… no
checking for mysql_query() in -lmysqlclient… no

Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

I did some searching and found a few older articles on the problem :

http://blog.wearesakuzaku.com/installing-the-mysql-ruby-gem-on-os-x/

I tried all of the suggested solutions on this page, and none of them seemed to make any difference, so I did some more searching, and I found that I had a 64bit version of mysql installed, and the rails gem didn’t seem to like this. So I downloaded and installed the latest 32bit version of mysql :

http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.81-osx10.5-x86.dmg/from/http://mirrors.dedipower.com/www.mysql.com/

and then ran:

sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config

That seemed to fix the problem.

Posted in Ruby on Rails | Tagged , , , , | Leave a comment

Error in option spec long|! mytop

mytop has started to break recently on our cPanel Redhat and CentOS machines.

When you run mytop:

#mytop
Error in option spec: "long|!"

The fix for this is to edit the mytop script and comment out the line containing long|!

# nano /usr/bin/mytop

Run a search (control+w) for “long|!” and change:

"long|!" => \$config{long_nums},

to

"long|long_nums|l!" => \$config{long_nums},

Now run mytop again, and away you go!

Posted in cPanel, Linux | Tagged , | 2 Comments

Fantastico – You cannot install more than one script in the root directory of a domain

Fantastico allows you to install scripts using cPanel very easily, however it occasionally glitches after you’ve installed/uninstalled scripts not using Fantastico.

This leads to a common error when you try to install another script in the root directory:

You cannot install more than one script in the root directory of a domain

This is usually an easy fix:

Find the folder : .fantasticodata in your folder, and edit the file installed_in_root.php

It should look like this :

<?
$installed_in_root["domain1.com"] = 1;$installed_in_root["domain2.com"] = 1;
?>

So you just need to delete “$installed_in_root["domain1.com"] = 1;” for the domain you want to install the new Fantastico script from.

You can then go back into Fantastico and install the new script!

Warning!

Fantastico is only designed to run 1 script from any folder, so it’s not advisable to use this to install multiple scripts in a root directory!

Posted in cPanel | Tagged , | Leave a comment