Archive for January, 2009

pg_config and Slony

January 31, 2009 Leave a comment

A few weeks back when I was at a client site, got an error while installing Slony which was reported as:

“pg_config binary not found”

I never had seen this problem before during Slony installation because most of the time when I built Slony on my laptop I had the PostgreSQL installation through source and the whole debug and developer environment was setup, but in that specific case PostgreSQL was installed through a Redhat RPM that was missing developer binaries.

After a little bit of RPM search I found out that it was just the “postgresql-devel-8.3.5-1PGDG.rhel5.i386.rpm” (ver 8.3.5 on RHEL5 for 32bit) rpm not installed and I was all set to get with Slony installation after that.


Categories: PostgreSQL Tags: ,

VirtualBox issues with USB on Ubuntu 8.1

January 14, 2009 Leave a comment

I just installed a WinXP instance on VirtualBox for some client specific testing and once I got everything configured and all softwares installed, I found out that USB devices were not at all accessible due to some change Ubuntu folks did for Intrepid.

So as a result you get an error while accessing USB setting in VBox Manager that “It can not be mounted”. A simple fix to that is:

sudo vim /etc/fstab

adding the following line at the end:

none /proc/bus/usb usbfs devgid=xxx,devmode=664 0 0

Where ‘xxx’ can be found by doing getting the group id of vboxusers or by:

grep vbox /etc/group‘  and getting the integer value in there which in my case turned out to be 119.

Save the ‘fstab’ file, reboot the host OS and it should be all good.


Categories: Operating Systems Tags: , ,

child process and setsid()

January 8, 2009 6 comments

I was trying to run a new process within the child process after the fork was successful and when ever I tried to run the process using execlp, as soon as the parent exited the child also did quit as well. This was getting very annoying and so I started googling the problem out and “setsid()” function was my friend in this case. With my final code looking like this:

pid_t pid;
pid = fork ();

if (pid == 0)
/* Child process. */
execlp (“/bin/sh”, “sh”, “-c”, program, NULL);
exit (1);

-Shoaib Mir

Categories: C/C++ Tags: , ,

xmlrpc over https implementation

January 8, 2009 Leave a comment

On a project we were using SSH2 module of PHP, but it was turning out to be a total mess due to compatibility issues on different operating and for the reason that it cant be built on all the operating systems easily. This made us to think about other alternatives but there are not many option in PHP where you can get much more control when using SSH.

The solution was to write our own Agent that could perform all kinds of functions we were using from the SSH library of PHP. The two functions we were using the most were:

– SSH function to run a program or service on a remote machine
– SSH function to copy a file to a remote

When writing our own agent we made a choice to go with xmlrpc as it is a pretty simple library and it will not be months of work using xmlrpc to implement our own server.

Now when looking for xmlrpc libararies for C/C++ you do not have a lot of choices available when you want to go for a HTTPS standalone server (because we can not install web server on an Agent machine). So in the end we went with “libiqxmlrpc” which is a C++ based library and very easy to use.

While implementing the server functionality the only problem that I didnt like was when ever you run a new process through libiqxmlrpc based server the process basically attaches it self to the sane port the server was running so even if the server quits, the server port is still blocked. For that we had to modify the library code in way to get the file descriptor for server socket and then close that socket using the file descriptor ID in the Server code when forking a child to run the process.

Other then this libiqxmlrpc library has been flawless for me and it integrated very nicely with PHP side as well using cURL that supports HTTPS server through its OpenSSL support.

Anyone doing xmlrpc over HTTPS, I will highly recommend libiqxmlrpc.

-Shoaib Mir

Categories: C/C++, PHP Tags: ,

Compiling Slony on Opensolaris

January 8, 2009 4 comments

A few days back I was trying to compile Slony on Opensolaris and it was giving an error:

“can not find slonik.h”

After a little bit of searching here and there it nailed down to be a compiler specific problem.

I was using CC like this:

./configure CC=/opt/SUNWspro/bin/cc

but as soon as I moved to ‘gcc’ everything was good.

Hope that might help someone who gets stuck at this!

Shoaib Mir

Categories: PostgreSQL Tags: ,

Finally the blog is back…

January 5, 2009 2 comments

After the went down a few months back all my blog posts were lost as well and then I never was able to get time out to setup a new blog and get it all going again.

But finally with 2009 just started, I was able to take time out during the holidays season and setup a blog 🙂

Stayed tuned for new posts in the coming weeks…

Shoaib Mir

Categories: PostgreSQL Tags: