Archive for the ‘Software’ Category.

exiqgrep – searching the eixm queue

I’ve just had to delete a bunch of messages from an Exim queue and I found this to be useful:

# exiqgrep -f billg@microsoft.com

Will print out details for any messages from that address.

To delete any messages from a person use the f as well as the i flags to print out just the message id, this can neatly be piped to xargs:

# exiqgrep -i billg@microsoft.com | xargs exim -Mrm

Mysql OLD_PASSWORD authentication fix

If you are using a older version of php connecting to a recent mysql (like os X Server 10.4 has) you will probably need to use the OLD_PASSWORD function in your SQL when creating the user or setting the password.

Normally you might do something like this to set a users password:

mysql> SET PASSWORD FOR root@localhost = PASSWORD('mypassword');

Whereas if you see this message from php:

"Client does not support authentication protocol requested by server; consider upgrading MySQL client"

You will almost certainly need to use the OLD_PASSWORD function to encrypt the password, like this:
mysql>

SET PASSWORD FOR root@localhost = OLD_PASSWORD('mypassword');

This is documented more in the MySQL Reference Manual.

protocol violation: synchronization error

If you receive a “synchronization error” it would likely mean that your smtp client/script is sending the data before exim has sent it’s welcome message. This is used to prevent script spammers from spamming you, as their scripts dont’ usually wait for the welcome message.

For more information look here

Possible workaround for your exim.conf, top section:

smtp_enforce_sync = false

vim modelines

So that Robin and I never again forget what the little bastards are called.. The syntactic sugar in source files requried for vim to be ‘just the way you like it’ isn’t called “magic comments” or “vim source configure” or any other search combination that leads to repeated head-meeting-brick incidents when trying to remember what they are. They’re called modelines (:help modeline)

An example modeline that works for Python would be:

#!/usr/bin/python
# vim: ai sm tw=0 sw=4 ts=4

Procinfo

Just found this useful little tool for summerising machine information read from /proc. I can’t find a home page for it but it can be downloaded from ftp://ftp.cistron.nl/pub/people/svm/. It seems to ship by default with at least SUSE 9.3 and Fedora Core 4.

Example output below

[root@eddie ~]# procinfo
Linux 2.6.11-1.1369_FC4 (bhcompile@decompose.build.redhat.com) \
(gcc 4.0.0 20050525 ) #1 Thu Jun 2 22:55:56 EDT 2005 1CPU [eddie]

Memory:      Total        Used        Free      Shared     Buffers
Mem:        515372      446196       69176           0      113048
Swap:      1048568         912     1047656

Bootup: Sun Jul 17 08:47:22 2005    Load average: 0.43 0.22 0.08 1/138 11716

user  :       3:36:41.09   1.7%  page in :        0
nice  :       1:20:51.42   0.6%  page out:        0
system:       3:40:27.39   1.7%  swap in :        0
idle  :   8d 17:08:50.87  96.0%  swap out:        0
uptime:   9d  1:46:23.08         context : 98642479

irq  0: 784129991 timer                 irq  8:         1 rtc
irq  1:         9 i8042                 irq  9:         0 acpi
irq  2:         0 cascade [4]           irq 10:   6170092 CMI8738-MC6, ehci_hc
irq  3:         5                       irq 11:         0 uhci_hcd:usb2, uhci_
irq  4:         5                       irq 12:      2114 i8042
irq  5:         0 uhci_hcd:usb1, yenta  irq 14:   2132585 ide0
irq  6:         5                       irq 15:   2955294 ide1

[root@eddie ~]#

DHCP search path

I fyou need to send a DNS search path to DHCP clients along with all the other details it seems you do it like this (in /etc/dhcpd.conf):

option domain-name "internal.usefulthings.org.uk usefulthings.org.uk";
option domain-name-servers 192.168.8.1, 192.168.8.2;

Took me a while to find that one!

Apache Directory permissions

I just got caught out with apache directory permissions while installing gallery for a virtual host. I previously had all the virtual hosts using the same strict directory permissions shown below:

        <Directory /sites/<domain>/www/htdocs>
                AllowOverride AuthConfig
        </Directory>

This will generate 2 errors in the virtual host error log, the first of which is a php error:

[alert]  /sites/<domain>/www/htdocs/gallery/setup/.htaccess: php_value not allowed here

This can be fixed by adding the Options option to the AllowOverride statement, the second error:

[alert]  /sites/<domain>/www/htdocs/gallery/setup/.htaccess: RewriteEngine not allowed here

can be fixed by adding the FileInfo option. So the final directory block should look like this:

        <Directory /sites/<domain>/www/htdocs>
                AllowOverride AuthConfig Options FileInfo
        </Directory>

Linux PPTP server

This week I will be mainly fooling with VPN’s. First off is a PPTP server so the Windows 2k and XP laptops can connect. I’ve found this little daemon which seems to work perfectly well for XP, 2K machines and my Mac OS X (10.1.3) Powerbook and Imac.

The only fiddly bits with installing poptop is that you need a patched up version of pppd so that you can support all the of Microsoft extensions and force the link to be encrypted.

The first step in creating my pptp server was to install a recent patched up version of pppd, which I found here. Installing this is as easy as installing any other RPM and required no post installation fiddling.

Next up was to install the MPEE (Microsoft Point-to-Point Encryption) support, this comes as a set of kernel modules from the pptpclient project. Their documentation, and download page is here. I used this rpm, because our RedHat 9 machine had been patched up to the 2.4.20-20.9 kernel and is a SMP box.

The final bit of software needed to make all this work was the actually poptop binaries, I could not find a RPM for these so I had to install them from source. Rather than using their current (1.1.4-b4) beta I prefered to use the current stable release (1.1.3) which can be downloaded from here. When I install an application from source I always install the application in accordance to the OFA (Optimal Flexible Architecture) standard, more details of which can be found on Dannys site. Rather than just unpack the source and run ./configure && make && make install as root I use a couple of simple scripts, so that the compile is repeatable and at a later date I can tell exactly what options were used. Below is my Build script

gunzip -c pptpd-1.1.3-20030409.tar.gz | tar xvf -
cd poptop
./configure --prefix=/usr/local/app/poptop-1.1.3
make

and the Install script:

cd poptop
make install

Once poptop was installed I needed to write a couple of simple config files, the options and how all this fits together is documented very well on the poptop home page in their Documentation section, so I will not explain all the options here, but I will include my config files for reference:

/etc/pptpd.conf

speed 115200
option /etc/ppp/pptp-options
debug
localip 10.1.1.100-199
remoteip 10.1.2.100-199
listen 213.52.209.13
pidfile /var/run/pptpd.pid

/etc/ppp/pptp-options

debug
name pptp
domain install.mydomain
auth
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe
ms-dns 172.16.2.11

/etc/ppp/chap-secrets

myusername   pptp    mypassword   10.1.2.100

The final bit of the puzzle was to sort out a nice redhat style start stop script, I couldnt find an existing one so I’ve written one, which you can grab here.

After the daemon has been started its a simple matter of configuring your 2k/XP clients to connect. A nice tutorial of how to configure 2K can be found here.

One last note, if you are connecting to a machine which runs iptables or some similar firewall you will need to allow PPTP into the machine, we run a iptables firewall on our PPTP server, the following rules will allow it through:

iptables -A INPUT -p tcp --destination-port 1723 -j ACCEPT
iptables -A INPUT -p 47 -j ACCEPT

That is all I needed to do to get my clients connecting. It should be noted that the clients were all behind adsl routers (Dlink DSL 504, with forward PPTP turned on), More work needs to be done if your clients are behind a linux NAT box.

Addressbook export

I just needed to export a load of contacts from addressbook into some app which doesnt understand vcards. Found this ute:

http://gwenhiver.net/applications/addressbookexporter/index.php

OS X ftp and sftp client

Found this cool ftp/sftp client for OS X, tis GPL too.