Restricted Notes by a Geek

Perl :: Installing CPAN modules the easy way

by Tinuva on May.22, 2009, under Linux

This is really simple, however someone might need to know just how to do it directly in the future.

Command: (to install lets say SNMP::Extension::PassPersist)

perl -MCPAN -e ‘install SNMP::Extension::PassPersist’

1 Comment more...

PHP Mail header patch

by Tinuva on Mar.19, 2009, under Plesk

Being in the hosting industry, you always have a few dirty clients, and those who just don’t care to keep their website secure, especially in the shared hosting environment.

On plesk for linux this wasn’t a big issue, as you could easily track down the domain as qmail log the user id in the headers that sent the mail. Still though it is always a mission going through the logs to figure out the script and the sender’s ip.

Since I found this patch, not anymore. Its a golden jewel in fact, it adds a header to the outgoing mail, with the complete url as well and the sender ip making these problems just a little annoyence you need to stop quick and then handle the issue with our client from there.

I present you the original link: http://www.lancs.ac.uk/~steveb/patches/php-mail-header-patch/
A newer patch available for for newer version of php at: http://choon.net/php-mail-header.php

Example of what the header will look like:

X-PHP-Script: www.example.com/~user/testapp/send-mail.php for 10.0.0.1

Leave a Comment : more...

Centos :: Installing php modules via pecl / pear without dependancies

by Tinuva on Feb.26, 2009, under Linux

You might find the following error when you install certain packages:

pecl/mailparse requires PHP extension “mbstring”
No valid packages found
install failed

There are 2 approaches around this.

Approach 1:
Tell the installer to ignore dependancies:

pecl install -n mailparse

Approach 2:
Install the RPM directly, granted you have it in the repos for your current PHP version.

yum install php-pecl-mailparse

Leave a Comment more...

Plesk :: Automatic shared SSL and temporary URL for domains

by Tinuva on Feb.25, 2009, under Plesk

Sometimes you move a domain to a plesk server, or set up a new domain and would like to test it before the domain registration is complete or share a SSL amongst multiple domains or even have problems testing the domain since the builtin plesk website preview doesnt work with php sessions.

Step1: Add * record dns entry.
Lets for example say your shared SSL will be servername.domain.com
You will need a record as follows:
Record type: A
Value: *.servername.domain.com

Step2: Have a Wildcard SSL certificate ready, order it so long and add it later on.

Step3: Create the main domain servername.domain.com on your server

Step4: Add the following event to the plesk control panel:
Event: Domain Created
Priority: Lowest (0)
User: root
Command: /usr/local/psa/admin/plib/api-cli/domalias.php –create .servername.domain.com -domain

This will automate the creation of the temporary url for you.

Step5: Create the domain example.co.za on your server and double check that the alias was created.

Step6: Add a custom button to your control panel
Create the file /usr/local/psa/admin/htdocs/domains/tempurl.php

With the contents from this file here: tempurl_php.txt

You will need to replace the $host variable with the server’s name.

Then add a custom button to the server as follows:

Plesk8 -> server -> custom buttons
Plesk9 -> home -> custom buttons (on admin account)

Button Label: Temporary URL
Location: Domain administrator’s Home page
Priority: 100
Background Image: Dont have one yet….
URL: /domains/tempurl.php
Context help tips contents: Preview domain on temporary url.
Tick: &dom_name=
Tick: Visible to all sub-logins

Now you will have a button to automate visiting the url for clients.

Leave a Comment more...

Plesk 9 :: Creating a domain results in a mysql error

by Tinuva on Feb.25, 2009, under Plesk

I started working on a Plesk 9 image with all the needed goodies that clients always want from PHP 5.2.8 with mailparse, zend, ionCube, xcache and some other goodies.

Creating a domain for some extra testing unfortunately started outright with problems in the control panel. Let’s just say installing Plesk 9 in the first place was disastrous. For one upgrades from 8.6 did not work, normal installer had problems and I had to end up doing a clean install via yum and rpms.

The error upon domain creation is lost, however with it was the following query which return 0 results.

select `id`,`subj`,`send2admin`,`send2reseller`,`send2client`,
`send2dlu`,`send2email`,`email`,`note_id` from Notifications where `id`=2

To fix this and the notes tables you can use the following:
First enter mysql:

mysql -u admin -p`cat /etc/psa/.psa.shadow` -D psa

Note you need to change the email address…


– Table structure for table `Notifications`

CREATE TABLE `Notifications` (
`id` int(10) unsigned NOT NULL auto_increment,
`status` varchar(1) character set ascii collate ascii_bin NOT NULL,
`send2admin` varchar(1) character set ascii collate ascii_bin NOT NULL,
`send2client` varchar(1) character set ascii collate ascii_bin NOT NULL,
`send2dlu` varchar(1) character set ascii collate ascii_bin NOT NULL,
`send2email` varchar(1) character set ascii collate ascii_bin NOT NULL,
`email` varchar(255) character set utf8 NOT NULL,
`subj` varchar(255) character set utf8 NOT NULL,
`note_id` int(10) unsigned default NULL,
`send2reseller` varchar(1) character set ascii collate ascii_bin NOT NULL,
PRIMARY KEY (`id`),
KEY `note_id` (`note_id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;


– Dumping data for table `Notifications`

INSERT INTO `Notifications` (`id`, `status`, `send2admin`, `send2client`, `send2dlu`, `send2email`, `email`, `subj`, `note_id`, `send2reseller`) VALUES (1, ”, 0×31, 0×31, ”, 0×31, ‘email@domain’, ”, 1, 0×30),
(2, ”, 0×31, 0×31, ”, 0×31, ‘email@domain’, ”, 2, 0×30),
(3, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 3, 0×30),
(4, ”, 0×31, 0×31, ”, 0×31, ‘email@domain’, ”, 4, 0×30),
(5, ”, 0×31, 0×31, ”, 0×31, ‘email@domain’, ”, 5, 0×30),
(6, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 6, 0×30),
(7, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 7, 0×30),
(8, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 8, 0×30),
(9, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 9, 0×30),
(10, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 10, 0×30),
(11, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 11, 0×30),
(12, ”, 0×31, 0×30, ”, ”, ”, ”, 12, ”),
(13, ”, 0×31, ”, ”, 0×31, ‘email@domain’, ”, 13, 0×31),
(14, ”, 0×31, ”, ”, 0×31, ‘email@domain’, ”, 14, 0×31),
(15, ”, 0×31, ”, ”, 0×31, ‘email@domain’, ”, 15, 0×31),
(16, ”, 0×31, ”, ”, 0×31, ‘email@domain’, ”, 16, 0×31),
(17, ”, 0×31, 0×31, 0×30, 0×31, ‘email@domain’, ”, 17, 0×30),
(18, ”, 0×31, 0×31, 0×31, 0×31, ‘email@domain’, ”, 19, 0×30),
(19, ”, 0×31, 0×31, 0×30, 0×31, ‘email@domain’, ”, 18, 0×30),
(20, ”, 0×31, 0×30, 0×30, 0×31, ‘email@domain’, ”, 20, 0×31),
(21, ”, 0×31, 0×31, 0×30, 0×31, ‘email@domain’, ”, 21, 0×30),
(22, ”, 0×31, 0×30, 0×30, 0×31, ‘email@domain’, ”, 22, 0×31);


– Table structure for table `Notes`

CREATE TABLE `Notes` (
`id` int(10) unsigned NOT NULL auto_increment,
`text` text character set utf8 NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;


– Dumping data for table `Notes`

INSERT INTO `Notes` (`id`, `text`) VALUES (1, ‘A new client account has been created in Plesk.\nClient’’s contact name: \nClient’’s login: \nClient’’s password: \nPlesk entry point: https://:8443′),
(2, ‘A new domain has been created in Plesk.\nDomain name: \nClient owner: \nDomain IP: ‘),
(3, ‘Limit has been exceeded on domain ”” owned by client ”” (Contact name ””):\nDisk space usage: \nDisk space limit: \nTraffic:
\nTraffic limit:
\n’),
(4, ‘The validity period of the client account ”” (Contact Name ””) has expired.\nThe client account and all related domains were deactivated on .’),
(5, ‘The validity period of the client account ”” (Contact Name ””) is about to expire.\nThe client account and all of related domains will be deactivated by unless the validity period is prolonged.’),
(6, ‘The validity period of the ”” domain owned by client ”” (Contact name ””) has expired.\nThe domain and all of its services were deactivated on .’),
(7, ‘The validity period of the ”” domain owned by client ”” (Contact name ””) is about to expire.\nThe domain and all of its services will be deactivated by unless the validity period is prolonged.’),
(8, ‘A new ticket with ID has been submitted to the Help Desk by from .\nPlease retain the ticket identification number for future references. Below is a copy of the ticket.\n—–\n\n—–’),
(9, ‘Ticket has been commented by from .\nBelow is the comment.\n—–\n\n—–’),
(10, ‘Ticket has been closed by from .\nBelow is the comment.\n—–\n\n—–’),
(11, ‘Ticket has been reopened by from .\nBelow is the comment.\n—–\n\n—–’),
(12, ‘The Application Manager reports error: .\nBelow is details of the error:\n—–\n\n—–’),
(13, ‘A new reseller account has been created in Plesk.\nReseller’’s contact name: \nReseller’’s login: \nReseller’’s password: \nPlesk entry point: https://:8443′),
(14, ‘The validity period of reseller account ”” (Contact Name ””) has expired.\nThe reseller account and all related client accounts and domains were deactivated on .’),
(15, ‘The validity period of reseller account ”” (Contact Name ””) is about to expire.\nThe reseller account and all of related client accounts and domains will be deactivated by unless the validity period is prolonged.’),
(16, ‘The ”” account is approaching or already exceeded the limits:\n\n’),
(17, ‘The ”” account is approaching or already exceeded the limits:\n\n’),
(18, ‘The following resource limits were exceeded by client :\n\nThe client account was suspended.\n’),
(19, ‘The following resource limits were exceeded on domain ””, owned by user account ””:\n\nThe domain was suspended.\n’),
(20, ‘The following resource limits were exceeded by reseller ””):\n\nThe reseller account was suspended.\n’),
(21, ‘User account under client ”” tried to use more ” ” resource than can be provided by the client account. The operation that tried to use more resources was blocked.\n’),
(22, ‘User account under reseller ”” tried to use more ” ” resource than can be provided by the reseller account. The operation that tried to use more resources was blocked.\n’);

Leave a Comment more...

RSS Feeds on wordpress

by Tinuva on Feb.11, 2009, under Uncategorized

For a few months now a co-worker asked me for RSS Feed for my blog. While it is not visible because of the theme I use it is still available to those who like to add it to whichever reader they use, my personal favourite is google reader.

The feeds that are available:
RSS: http://www.restricted.co.za/?feed=rss
RSS2: http://www.restricted.co.za/?feed=rss2
ATOM: http://www.restricted.co.za/?feed=atom
RDF: http://www.restricted.co.za/?feed=rdf

Leave a Comment more...

Archlinux: perl: warning: Setting locale failed.

by Tinuva on Feb.06, 2009, under Archlinux

I received the following whilst executing perl scripts on Archlinux and wanted to fix it.

# perl
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = “”,
LC_ALL = (unset),
LC_COLLATE = “C”,
LANG = “en_US.utf8″
are supported and installed on your system.
perl: warning: Falling back to the standard locale (”C”)

Step1: Check /etc/rc.conf
This is mine’s contents in the Localization section

LOCALE=”en_US.utf8″
HARDWARECLOCK=”localtime”
USEDIRECTISA=”no”
TIMEZONE=”Africa/Johannesburg”
KEYMAP=”us”
CONSOLEFONT=
CONSOLEMAP=
USECOLOR=”yes”

Step2: Update /etc/locale.gen
By adding the following lines:

en_US.UTF-8 UTF-8
en_US ISO-8859-1

Step3: Regenerate the locales

# locale-gen
Generating locales…
en_US.UTF-8… done
en_US.ISO-8859-1… done
Generation complete.

And now you won’t see those warnings anymore :)

2 Comments more...

-bash: /bin/rm: Argument list too long

by Tinuva on Feb.03, 2009, under Linux

Annoying limitation, but one has to work around it at times.

I wanted to delete all the files in a large folder today:

[root@server folder]# rm *
-bash: /bin/rm: Argument list too long

To work around it I did the following:

find /home/user/folder/ | xargs rm -v

I hope this helps someone out there with a similar problem.

Leave a Comment more...

How to add Baracuda RBL and Passive Spam Blocklist to Spamassassin

by Tinuva on Jan.30, 2009, under Mail

I recently added the BRBL and PSBL lists to our spamassassin configuration to help block more spam. As a test we first added it to only make a score difference of 1.0 so that we can see how effective it would be without having too many false positives.

Add the following code to /etc/mail/spamassassin/local.cf to activate the these:

### Custom RBL
# URL: http://psbl.surriel.com/
header RCVD_IN_PSBL eval:check_rbl(’psbl’, ‘psbl.surriel.com.’)
describe RCVD_IN_PSBL Received via a relay in PSBL (Passive Spam Block List)
tflags RCVD_IN_PSBL net
score RCVD_IN_PSBL 1.0

# URL: http://www.barracudacentral.org/rbl/
header __RCVD_IN_BRBL eval:check_rbl(’brbl’, ‘b.barracudacentral.org’)
describe __RCVD_IN_BRBL received via a relay in b.barracudacentral.org
header RCVD_IN_BRBL_RELAY eval:check_rbl_sub(’brbl’, ‘127.0.0.2′)
tflags RCVD_IN_BRBL_RELAY net
describe RCVD_IN_BRBL_RELAY received via a relay rated as poor by Barracuda
score RCVD_IN_BRBL_RELAY 1.0

You should see an example as follow:

X-Spam-Report:
* 1.0 RCVD_IN_BRBL_RELAY RBL: received via a relay rated as poor by * Barracuda * [83.35.208.195 listed in b.barracudacentral.org

3 Comments more...

Tomcat pain - java.lang.NoClassDefFoundError

by Tinuva on Jan.30, 2009, under Plesk

This is probably one of the few type of servers I hate the most. When it comes to java applications and the errors they throw, it almost never a hit as to what the real problem is.

I received the following error after trying to start up Tomcat:

java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:208)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:4

Now usually you end up replacing the files or checking the system variables/classpaths.

However in this case I ended up backing up the tomcat website structure and config files and re-installing tomcat completely.

In my case, I had to backup /var/cache/tomcat5/ and /etc/tomcat5/ before re-installing tomcat. Then you restore those folders and restart tomcat and usually it will work without a problem. Not the best way of doing this but after trying numereous other things as well this is what I ended up doing. *shrug*

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...