Sunday, April 17, 2011

OpenVPN on Sony Ericsson Xperia X10 Mini Pro (Android 2.1 Eclair)

The following procedure will kill your dog and void your warranty. Keep reading at your own risk, blah blah blah...

Spent the whole Sunday on this. I did not take a note of every step, so I hope my /dev/brain will not fail ;-P

First, this phone has got wonderful hardware in a small size. But Sony-Ericsson is having an horrible policy on software updates. The device came with Android 1.6 (very old). It's been upgraded to 2.1, and that's it. No Froyo nor Gingerbread available.

I'm on 2.1 and was confused by a lot of HOWTOs referring to 1.6, so be careful on this.

You will need Windows (or Mac OSX, maybe) 'cause there's no ADB driver for Linux.

(A VirtualBox Windows guest inside your Linux box WILL NOT WORK, even with USB device properly redirected).

You will need root access, on that purpose I used the (modified) SuperOneClik which is found here:

You also need the TUN/TAP kernel module. There's a binary download at:

You need BusyBox (which provides standard ifconfig and route commands): search on the Market...

Now it's time to make the OpenVPN Installer happy.  And it's time to use the shell. You can use the adb.exe provided by SuperOneClick. Open a Command Prompt and cd into the SuperOneClick directory, then:

adb shell
mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system
mkdir /system/xbin/bb
cd /system/xbin/bb
ln -s ../ifconfig ifconfig
ln -s ../route route
ln -s ../ip ip 

I'm not sure the last command is necessary, it won't be evil anyhow. Maybe this whole thing is already done, depending on which BusyBox packaged distribution you installed. So use your common sense.

Now grab the OpenVPN installer here (no longer available on the Market, apparently):

It will ask in which path you want to install the OpenVPN binary: choose /system/xbin.

It will ask in which path OpenVPN should find ifconfig and route: choose /system/xbin/bb. (For some strange reasons it WILL NOT work with /system/xbin even if ifconfig and route are correctly there, and that's why you had the need to create the symlinks above).

Now, there's a strongly suggested location to keep the OpenVPN config files and certificates: it's /sdcard/openvpn . In other words, in the openvpn directory just in your microSD card. That's where the OpenVPN Settings app will expect to find your config files and certs.

Yes, you need to install yet another application: the OpenVPN Settings app is easily found on the Market, and will simplify the procedure of starting and stopping the OpenVPN daemon (and loading the tun.ko kernel module).

Of course, feel free to manage the openvpn daemon within the (adb rooted) shell, especially for debugging purposes.

That should be all.