Saturday, 20 February 2010

Getting QPID running on Ubuntu

After reading Joshua Kramers article in the November 2009 issue of Linux Journal, I decided to try out AMQP and see how easy it was to set up and get going.

Firstly, the article doesn't mention:

* You need dependencies, namely valgrind, libboost-dev, uuid-dev
* the version of g++ that comes with Ubuntu 9.04 (g++-4.3) doesn't work with qpid-0.5, so you need to change the symlink to point to the older g++4.2 version
* the python tests fail due to an obscure line which goes something like:
if isinstance(sock, socket.SSLType):
AttributeError: 'module' object has no attribute 'SSLType'
* When trying to install the python modules I had a probem with the setup.py script and ended up commenting out the 'scripts=["amqp-doc"]' argument to the setup method due to the fact that it complained about not being able to find the script.
* Trying to run the 'Listing1.py' code resulted in it not being able to find the AMPQ spec, even after I had set the environment variable $AMPQ_SPEC to point to the correct file. Eventually I just hardcoded the value by editing the '/usr/local/lib/python2.6/dist-packages/qpid/spec.py' file and setting 'amqp_spec = "/usr/local/share/qpid/specs/amqp.0-10-qpid-errata.xml"' instead of the previous version which was ' amqp_spec = os.environ["AMQP_SPEC"]'

I haven't been able to find anything else on this error, with the exception of other frustrated qpid users.

Tuesday, 12 January 2010

Processes as trees

Just found this nice little command which displays all running processes as a tree structure. Actually, the command is just good ol' ps, but with the axf arguments. i.e.
# ps axf
...
...
8923 ? Ss 0:00 /bin/sh /command/svscanboot
8925 ? S 0:00 \_ svscan /service
10888 ? S 0:00 | \_ supervise qmail-send
13089 ? S 0:00 | | \_ qmail-send
13097 ? S 0:00 | | \_ qmail-lspawn ./Maildir/
13099 ? S 0:00 | | \_ qmail-rspawn
13100 ? S 0:00 | | \_ qmail-clean
10889 ? S 0:00 | \_ supervise log
13088 ? S 0:00 | | \_ /usr/local/bin/multilog t /var/log/qmail
10890 ? S 0:00 | \_ supervise qmail-smtpd
21951 ? S 0:00 | | \_ /usr/local/bin/tcpserver -v -R -l smtp1.smartmailpro.co.nz -x /etc/tcp.smtp.cdb -c 20 -u 502 -g 501 0 25 /var/qmail/bin
10891 ? S 0:00 | \_ supervise log
13091 ? S 0:00 | \_ /usr/local/bin/multilog t /var/log/qmail/smtpd
8926 ? S 0:00 \_ readproctitle service errors: .................................................................................................

Wednesday, 30 December 2009

nVIDIA CUDA

Started a new project in my spare time. Trying to add CUDA functionality to rarcrack, a password recovery program for rar files after finding an old encrypted rar file which I forgot the password to. RAR uses 128-bit AES as far as I know, should be interesting to see what this CUDA technology is all about and how easy it is to use.

Tuesday, 17 November 2009

CentOS, Nagios and SELinux

I've just finished installing Nagios on our CentOS box. I kept on running into errors when trying to get Nagios to start. The errors weren't very specific, merely stating

Starting nagios:CONFIG ERROR! Start aborted. Check your Nagios configuration.

This confused the crap out of me, mostly because of the lack of information in the error messages. So after a few hours of googling, I found that the problem was with SELinux. This is the fourth or fifth time that this piece of software has gotten in the way of installs. It's no wonder then that the first piece of advice when telling someone on a forum/mailing list is to give the advice to set 'SELINUX=disabled'.

This ofcourse ends up voiding any security advantage that SELinux may have had, but apparently everyone seems to think that Linux is secure enough.

Friday, 6 November 2009

Linux and Remote Desktop

Recently we've installed a remote server in North America. In order to set up some Windows boxes, we figured it would be easier to download the DVD images from the servers themselves. This posed a problem however, for several reasons:

1. XenServer requires that any Linux installs be specially compiled for Xen. This is due to the way that the Xen guys wrote the code for the HyperVisor. From my understanding (and without going through the lkml) the code was not very 'clean' and/or did not conform to the kernel coding guidelines. This resulted in the Xen code not being available in the standard kernel that comes with most distributions.

2. Figuring out how to add an ISO repository and actually have its contents come up when installing a new VM is harder than it probably should be on Xen. When trying to figure this out, I found plenty of examples of how to add a new iSCSI/CIFS repository to the XenServer, but nothing on how to set up an ISO repository on the local storage.

3. Apparently there's also a way of uploading a Windows XP VM, but this was more complicated to get going than adding the local ISO repository.

Due to these problems it was decided to take one of the existing distributions (Debian Lenny) and install a desktop environment and enable Remote Desktop functionality through the use of one of the below listed technologies. After pissing about for two/three days with these protocols I can honestly say that the NX protocol and the binaries available off the NoMachine site are the easiest to configure and the best working solutions. This is kind of disappointing for me, since I would have loved to see a FLOSS solution out do a propriatary one, but as a programmer you have to give credit where credit is due.

When it comes to Remote Desktop functionality for Linux, there are a few options regarding protocols:

* XDMCP - Basically the original X idea of remote displays hooked up to a mainframe. Couldn't get it to work for the life of me. Also, found a known, unfixed bug whereby enabling remote login makes the gdm listen only to IPv6 addresses
* VNC - Hard to set up and slow
* RDP - See VNC
* NX (FreeNX) - Awesome. Although FreeNX is a real bastard to set up

UPDATE: Found out that Google released their own NX Server called Neatx.

Monday, 2 November 2009

Zend CE Server on CentOS

I just finished installing Zend Server Community Edition on CentOS. One of the problems encountered along the way was that starting Apache would give an error saying that it did not have the necessary permissions to access '/usr/local/zend/lib/apache2/libphp5.so'. This is due to SELinux not allowing the httpd process access to this file. After searching around for a solution, I found that most of the forum posts gave the advice to either switch SELinux to permissive mode or to disable it altogether. To me, this was a bit like throwing the baby out with the bathwater, so after reading up a bit on SELinux, I figured an easier (and more secure) solution was to just add this file to the 'httpd_modules' context. So, here your are:

chcon -t httpd_modules_t /usr/local/zend/lib/apache2/libphp5.so

This command adds the Zend php binary to the 'httpd_modules' context, allowing Apache to load it and start up normally.

Thursday, 10 September 2009

MySQL Bug #11918

In the software industry, every now and then you come accross some indescribably dense acts of stupidity that cost you hours of debugging time. When it's not your own code that's the problem, you get to rant about it on your blog ;)

Today I spent the last four hours trying to create a MySQL stored procedure to do something which I thought was quite basic. It just had to take an integer as input and return that number of rows from a specific table and at the end delete the rows. Kind of like a stack data structure (the rows 'pop' out), but with a database. So I sat down and wrote this code:

DELIMITER $$

DROP PROCEDURE IF EXISTS `test`.`testGet`$$
CREATE PROCEDURE `test`.`testGet` (IN numRecords INT)
BEGIN
CREATE TEMPORARY TABLE tmpTable
SELECT * FROM test LIMIT numRecords;

DELETE FROM test WHERE idTest IN (SELECT idTest FROM tmpTable);

SELECT * FROM tmpTable;

DROP TABLE tmpTable;
END$$

DELIMITER ;

So after saving this code and trying to run it I get this cryptic error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'numRecords;

DELETE FROM test WHERE idTest IN (SELECT idTest FROM tmpTable);

' at line 4 (errno: 1064)

I spent the next two hours trying to figure out what MySQL was complaining about, pulling my hair out, trying to see which part of the code was screwing up.... finally after much googling, I came across this bug report on the MySQL bug tracker, the title of which simply reads "SP does not accept variables in LIMIT clause". The bug's been sitting in the bug tracker since the 13th of July 2005, FOUR YEARS this last July. The bug report is full of comments with detailed workarounds, most of which end up being versions of the 'EXECUTE STMT USING' statement. There's a big discussion in the comments as to whether this is a bug fix or a feature request, meanwhile Oracle and SQL Server continue to dominate the marketplace. Nice going guys. I'm stupified that this bug has been hanging around for four years and is still not fixed. I'm tempted to download the source and have a look at how difficult it would be to patch.