Archive for March, 2009

WordPress blog posting with local POP3 mail

Sunday, March 15th, 2009

This article describes how to set up popa3d (a POP3 mail server daemon process) and create a user account (in Debian Lenny) solely for the purposes of blog posting.

0 – A preliminary note about popa3d

popa3d is a more or less zero-configuration *nix POP3 daemon process that will serve up any mail found in the spool file belonging to any user account (apart from the root account) if the correct user account password is provided.

If you don’t want all your user accounts’ mail spool files to be POP3 enabled, then popa3d is not for you.

1 – Install popa3d

# apt-get install popa3d

Answer ‘yes’ when asked whether you would like to run popa3d in standalone mode.

You can now start, restart and stop popa3d using the init script provided:

# /etc/init.d/popa3d {start|restart|stop}

If you want to disable popa3d permanently (so that it isn’t started at boot time) it is sufficient to simply edit /etc/default/popa3d to read:

RUN_STANDALONE=no

Important tip:  popa3d’s other mode of operation is as an internet ’service’.  For popa3d to work in this mode you must also edit /etc/inetd.conf.

2 – Create a user account for your WordPress blog posts

We now need to create a user account, with a name that should be very hard to guess because WordPress will retrieve (and treat as blog posts ‘pending’) any and all mail it finds in the specified mailbox (when instructed to do so ).  Ideally you should create an account called something like jhuwe7KJ23h but for the purposes of this article we will call the account obscure.

We know that popa3d won’t serve mail that has been delivered to the root account, nor will it serve mail delivered to an ordinary user account unless the correct user account password is provided, but there also happens to be a third security measure which isn’t documented – it won’t serve mail delivered to a user account if the user doesn’t have write access to their home directory.

So, we have to create a user account (with an obscure name) that provides write access to its home directory, but we don’t want to allow logins, we don’t want it intermingling with ordinary user login accounts and we don’t want an unused sub-directory of /home lying around either, especially not if we’re going to provide a number of these accounts for a number of WordPress blogs we may be hosting.

Now, when popa3d is installed (on a Debian system) a number of things happen behind the scenes…

  • a system user popa3d is created
  • a system group popa3d is created
  • user popa3d’s home directory /var/lib/popa3d is created (with owner root and group root)

…so we’re going to give user obscure a UID which keeps her well out of the way of ordinary login accounts, make her a member of the popa3d group, make /var/lib/popa3d her home directory and deny her a shell (thus preventing logins), like so:

# useradd -c "POP3 mail account" -u 65501 -g popa3d \
          -d /var/lib/popa3d -s /bin/false obscure

And we now have to give her a password:

# passwd obscure
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

One final thing remains for us to do – make user popa3d the owner and group owner of directory /var/lib/popa3d and give members of group popa3d write access to it:

# chown popa3d:popa3d /var/lib/popa3d
# chmod g+w /var/lib/popa3d
3 – Check everything is working with telnet

Fire up your command line telnet client:

telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK

If you get the ‘OK’ popa3d is up and running and waiting for client requests.

Build the PostgreSQL manual in Info format

Sunday, March 15th, 2009

Here’s a step-by-step guide to building the PostgreSQL manual in Info format on a Debian Lenny box:

1 – Install a few extra packages

The PostgreSQL manual is in Docbook format, so…

$ sudo apt-get install bzip2 docbook-dsssl docbook2x opensp
2 – Grab the PostgreSQL source, unpack and configure it

Change ~/workspace/src to suit your needs.

$ cd ~/workspace/src
$ apt-get source postgresql
$ cd postgresql-8.3-8.3.5
$ bunzip2 postgresql-8.3-8.3.5.tar.bz2
$ tar -xf postgresql-8.3-8.3.5.tar
## this next operation is not strictly necessary but...
$ sudo chown -R sebyte:sebyte postgresql-8.3.5  # change user/group name to suit
$ cd postgresql-8.3.5
$ ./configure
[...]
3 – Edit one of the Makefiles included in the source

We need to tell a program called osx to ignore any errors by editing the relevant Makefile using your favourite text editor.

$ cd doc/src/sgml
$ emacs -Q Makefile

## change line 227 to read:
##
##  $(OSX) -E0 -x lower $< | \
##          ^
##          |___ add this switch

While you are about it, you may also decide to edit the Makefile so that the resulting Info manual utilises the full width of your screen. (This greatly improves the look of tables within the manual, of which there are many).

## change line 263 to read:
##
## $(MAEKINFO) --fill-column 184 --enable-encoding --no-split --no-validate $< -o $@
##                            ^
## specify number of columns _|
4 – That’s it. You’re ready to roll.

Complete the process by running make:

# make postgres.info
[...]
# ls -l postgres.info
-rw-rw-r-- 1 sebyte sebyte 4939332 Jan 24 15:33 postgres.info

Job done :)

When I did it, ‘osx’ generated 108,484 errors, all of which were ignored, and there were 14 other warnings in the output, but the resulting Info manual is fine.