Saturday, January 10, 2009

Truecrypt 6/7 on CentOS 5

Truecrypt is available as a Red Hat/CentOS package on RPMForge, however I found that it's problematic and only supports FAT disks. I needed to use Truecrypt to encrypt a USB drive that is going to store files larger than 4GB so FAT isn't an option.
There's many conflicting accounts on various forums on how to compile Truecrypt on CentOS 5 however the most helpful was still the README provided in the source package which still required a bit of trial and error to get a working binary at the end.
Therefore here's my walkthrough on the quickest, simplest way to get Truecrypt 6.1 compiled and working on a vanilla CentOS 5 installation.
Switch user to root.
 su -  

** UPDATE - RPMForge was merged into RPMFusion which also requires the EPEL repo on RHEL/CentOS** 
Firstly setup access to the EPEL repositories, download the latest EL5 RPM from their repo. This package just installs the EL5 repo file and the required GPG keys, install it with;
 rpm -i /pathtoyour/epel-release-5??.noarch.rpm  

The RPMFusion repository provides decent packages for fuse and wxwidgets which are required by Truecrypt, this really simplifies the process as I found setting up wxwidgets & fuse from source to be a chore.
Upto date instructions for enabling this repo is at rpmfusion.org/Configuration, the correct command-line for downloading & installing free & nonfree RPMFusion repos at time of writing is;
 rpm -Uvh http://download1.rpmfusion.org/free/el/updates/5/i386/rpmfusion-free-release-5-1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/5/i386/rpmfusion-nonfree-release-5-1.noarch.rpm  

Once RPMFusion is setup then install the following packages and their dependencies;
 yum install gcc gcc-c++ gnome-keyring-devel kernel-devel kernel-headers wxGTK wxGTK-devel fuse fuse-devel fuse-ntfs-3g  

Next download the Mac OSX/Linux source package from the Truecrypt website at http://www.truecrypt.org/downloads2.php and save it somewhere. In this example I've saved it to /tmp.
Now in a terminal goto the location of the archive and unpack it.
 cd /tmp  
 tar xvfz “TrueCrypt 7.1a Source.tar.gz”  

... cd to the new directory containing the extracted source code
 cd truecrypt-7.1a-source  


Download the RSA Cryptoki 2.20 header files required by Truecrypt into the source directory.
 wget ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20/*.h   

Compile Truecrypt.
*UPDATE:  Include the NOASM flag to prevent assembly with nasm*
 make NOASM=1

The compilation process should now breeze through with no errors.
Now copy the compiled binary to /usr/bin
 cp -p Main/truecrypt /usr/bin/  
 chmod +x /usr/bin/truecrypt  

You can now start Truecypt from a root terminal.
 truecrypt  




Swapping encrypted disks between Linux & Windows systems
My requirement for Truecrypt on CentOS was for transporting sensitive data on an encrypted USB hard disk to one of our software suppliers. The guys receiving the data run Windows on their systems whereas we run HP-UX, RHEL & CentOS on our systems, Truecrypt was the only decent open-source cross-platform solution that would enable us to securely transport the encrypted data without it being too technical for the guys receiving it.
However I was a bit disappointed with how different the Windows version was to the Linux version and it became apparent that the project still needs some direction in terms of enhancing the cross-platform nature of Truecrypt.

One area where this was apparent was the filesystem options available in the GUI, the Windows version only had options to create or mount FAT32 & NTFS encrypted filesystems whereas the Linux version only had options for FAT32, Ext3 & Ext2 filesystems.
If you intend to swap an encypted disk with large file support between Linux & Windows platforms, it is not possible to do this by using the Truecrypt GUIs alone.
After some time testing the best solution for this was to use a NTFS filesystem on the USB disk and encrypt the whole filesystem on a Windows platform using the GUI.
When it comes to using the encrypted disk on the Linux platform you have to mount and dismount it with Truecrypt's command-line options as the GUI does not support this.

Examples
To mount the encrypted NTFS volume on Linux;
As root substituting the 'correctpassword', the device path & the mountpoint as appropriate...
 truecrypt -t --filesystem=ntfs-3g -k "" --protect-hidden=no --fs-options=user,users,gid-users,umask=0002 -p correctpassword /dev/sdx1 /pathto/mountpoint  

To unmount the encrypted volume;
As root...
 truecrypt -t -d /dev/sdx1  
or...
 truecrypt -d /pathto/mountpoint  

What doesn't work?
  • Truecrypt on Windows will not mount an encrypted Ext2 or Ext3 filesystem, even with an appropriate Ext filesystem driver installed.
  • Truecrypt on Linux will not mount an encrypted file container, mounting a file residing on an already mounted filesystem seems to be the problem.
  • The Linux Truecrypt GUI cannot gain elevated privileges after entering your sudo password, even if sudo/sudoers is setup correctly, therefore su to root before executing the GUI from a terminal.
  • The Truecrypt GUI on Linux cannot mount encrypted NTFS filesystems

Thursday, September 20, 2007

Running the QW:ET Demo on Fedora 7

Now one really cool thing that I gotta share has pretty much occupied my whole day today, and with damn good reason too.
The Quake Wars: Enemy Territory demo was released recently to much excitement and draining of bandwidth across file repository sites around the globe, I too downloaded the file and eagerly waited for the download to finish.

Now I only use Linux on my computers. I choose to not allow a certain very well known, bloated, overpriced, featureless trojan-horse of an operating system anywhere near them as I prefer my PCs to be fast, secure, stable and also include a lot of cool, leading edge stuff to play with.
There are many other reasons why I use open source software, I'm sure they'll ooze out in future posts but not today.

Therefore I had my fingers crossed hoping that this demo would work on my Fedora desktop.
I first tried Cedega as I pay for the thing (God knows why!) it didn't even install!
I installed Wine from the Fedora repositories, QW:ET installed OK and I sorted out a few other bits and bobs but the demo Didn't run :(
QW:ET came back with something along the lines of a 'Display must support 32bpp colours' message. Damn! X only supports 24bit. I walked away defeated.

Today I stumbled across an brill little how-to on the QW:ET forum which was a little collection of links & tips gathered by stoic_ails over at the forum. The original how-to can be found over at http://community.enemyterritory.com/forums/showthread.php?t=9115.
Therefore I do not take credit for this info, all I have done is correct & expand the odd bit here & there and stick it all in nice bloggy format for all to hail mightily so here goes.

Preparation
Firstly I got rid of my Yum installed Wine (0.9.42) installation as this did not have the patches required to get round the 32bit display message.

UPDATE
Wine 0.9.46 is now in many distro's repositories which works OK with the QW:ET demo without patching.

Therefore if you have Wine 0.9.46 or later from your package manager you don't have to compile Wine yourself anymore and you can skip steps 1-9c and kick off from step 10a.


I logged in as root, entered the root password and removed wine using yum;
su -
yum remove wine

If you are using a different distribution, maybe one of those crazy Debian based affairs, you may want to remove Wine as follows;
sudo apt-get remove wine

Then I was ready to go...
Do everything by the book and you'll be rocking the QW:ET with the rest of us. Until the native Linux version of the full game is released around the end of October.

I already had the Nvidia binary Linux drivers installed on my system and I assume that your system also has 3D acceleration enabled, the process of installing proprietory graphics drivers is not covered here.
If you're expecting to run QW:ET without any 3D acceleration then you are proper silly.


Oh yeah of course, download the QW:ET demo as well. I got it from Filefront.com as the downloads are fast with no queues and no registration required. Download link below.
Enemy Territory: QUAKE Wars PC Demo

The How-To
1. Get the latest wine source; in this case 0.9.44: http://prdownloads.sourceforge.net/w...0.9.44.tar.bz2

2a. In your home directory, make a directory called wine
mkdir ~/wine

2b. Copy the archive to the new directory ~/wine :
cp wine-0.9.44.tar.bz2 ~/wine/

3. Change to that directory:
cd ~/wine/

3. Unpack the archive:
tar xvfj wine-0.9.44.tar.bz2

4a. Open http://bugs.winehq.org/attachment.cg...39&action=view and copy it (ctrl+a & ctrl+c) into a file called patch1.

4b. Open http://bugs.winehq.org/attachment.cg...49&action=view and copy it (ctrl+a & ctrl+c) into a file called patch2.

4c. Change directory to where you've saved the patch1 & patch2 files too, maybe your desktop for example.
cd ~/Desktop

5a. Copy patch1 to the wine source directory:
cp patch1 ~/wine/wine-0.9.44/

5b. Copy patch2 to the wine source directory:
cp patch2 ~/wine/wine-0.9.44/

6. Change to the wine source directory:
cd ~/wine/wine-0.9.44/

6a. Patch the wine source:
patch -p1 < patch1

6b. Patch the wine source:
patch -p1 < patch2

7a. Run configure:
./configure

7b. If configure complains about missing packages, stop here and install the missing packages...
For those using Debian/Ubuntu/Linux Mint/etc. it'd go something like:
sudo apt-get install flex bison fontforge

For those very sensible lot running Fedora/Red Hat type distros:
su -
yum install
fontforge
exit

...and run ./configure again.


7c. Go ahead when configure finished successfully.

8a. Run the following command:
make depend && make

8b. Wait and hope that there's no errors.

8c. Go ahead when make finished successfully.

9a. Change to user root:

su

9b. Run:
make install

9c. When the install has finished, exit from root:
exit

10a. Run:
regedit

10b. Go to HKEY_CURRENT_USER/Software/Wine/

10c. Add the key X11 Driver

10d. Add the string ScreenDepth with the value 32 (Screenshot)

11. Download http://tacticalsites.com/~lorian/fil...stem32.tar.bz2

12. Copy the archive to your wine system32 directory:

cp system32.tar.bz2 ~/.wine/drive_c/windows/system32/

13. Change to that directory:
cd ~/.wine/drive_c/windows/system32/

14a. Unpack the archive:
tar xfvj system32.tar.bz2

15a. Run:
winecfg

15b. Set the windows version to Windows XP (Screenshot)

15c. Go to libraries and set wtsapi32 to Native (Windows) (Screenshot)


16a. Install the ET:QW Demo:
wine ETQuakeWarsDemoSetup.exe

16b. There might be some complaints, just click 'ok' :P

17. Download http://tacticalsites.com/~lorian/fil...st_x86.exe.bz2

18. Unpack it:
bunzip2 vcredist_x86.exe.bz2

19. Run:
wine vcredist_x86.exe

20. Check that msvcr80.dll, Microsoft.VC80.CRT.manifest and Microsoft.Windows.Common-Controls.manifest are neither in the system32, nor in the game directory. If they are, delete them.

21. Change to your ET:QW Demo installation, e.g.:

cd ~/.wine/drive_c/Program\ Files/id\ Software/Enemy\ Territory\ -\ QUAKE\ Wars\ Demo/
(notice any spaces in directory names have to be preceded with a backslash)

22. You can start ET:QW Demo like this:
nice -n19 wineserver && wine etqw.exe
(This way, wineserver won't use too much CPU time)
Or you can be all gung-ho like me and have a launcher icon that runs:
env WINEPREFIX="/home/vin/.wine" wine "C:\Program Files\id Software\Enemy Territory - QUAKE Wars Demo\etqw.exe"

23. Before joining a game, the mouse can behave weird in the menu. But after joining it's just fine, like the whole game.

24. You can now clean up and get rid of the ~/wine directory if you want:
rm -rf ~/wine



The Results
The guy who originally wrote this how-to also pointed out that he found that QW:ET running under Wine on Linux was actually performing better for him that under Windows XP & Windows Vista on a similar spec PC. I don't really find this surprising as I have seen similar comparisons with other games which had similar outcomes, especially against Vista as it's a dog.

When I got round to toying with the graphics settings I found that just sticking the detail on 'High' prevented the level from loading, so I chose the 'Custom' settings and set most of rendering details to "High", the Anti-Aliasing could not be enabled. I'd put that down possibly to the version of the DirectX API under Wine.

Anyway that's not really a problem as it looked fantastic at 1280x1024 resolution and I was seeing frame-rates between 30-40+ FPS on my system during online gameplay with 31 other players together with all the high-end weather, plants, 'soft particle' effects and all that fancy stuff which simply looks fantastic.
Punkbuster doesn't work so I just filtered out the punkbuster servers out of the server list, no biggy.


My system?
Fedora 7
Intel Core 2 Duo 2.33 GHz
1GB DDR2 PC8500+ RAM (1066Mhz)
Nvidia GeForce 7600GS PCIe 16x
Nvidia HD 7.1 sound


Kill ya later...