Description: Fixes a bug using when using truecrypt >=5
Author: Nicolas Van Wambeke <nicolasvw@free.fr>
Last-Update: 2010-07-18
--- a/main.py
+++ b/main.py
@@ -30,12 +30,30 @@
 import gettext
 import createui
 
+import subprocess
+
 
 LOG_ANY = -1
 LOG_MOUNT = 0
 LOG_DISMOUNT = 1
 
 
+VERSION_R = re.compile('^truecrypt ([a-z0-9\.]+)$', re.IGNORECASE |
+		re.MULTILINE)
+
+def get_tc_version_from_path(path="/usr/bin/truecrypt"):
+	'returns the truecrypt version of the given path'
+
+	proc = subprocess.Popen([path,"--text","--version"], stdout=subprocess.PIPE,
+			stderr=subprocess.PIPE)
+	if proc.wait() == 0:
+		return VERSION_R.search(proc.stdout.read()).group(1)
+	else:
+		proc = Popen([path,"--version"], stdout=subprocess.PIPE)
+		return VERSION_R.search(proc.stdout.read()).group(1)
+
+
+
 class gdecrypt:
 	devices = {}
 	udis = {}
@@ -174,18 +192,24 @@
 		self.window.show_all()
 		
 		self.has_tc_support = False
+		tc_error_message = "not found"
 		self.has_luks_support = False
 		
 		for i in  os.environ['PATH'].split(":"):
 			if os.access(os.path.join(i,"truecrypt"),os.X_OK):
-				self.has_tc_support = True
+				tc_version = get_tc_version_from_path()
+				if tc_version == '4.3a':
+					self.has_tc_support = True
+				else:
+					tc_error_message = "unsupported version"
+
 
 		for i in  os.environ['PATH'].split(":"):
 			if os.access(os.path.join(i,"cryptsetup"),os.X_OK):
 				self.has_luks_support = True
 
 		if not self.has_tc_support:
-			self.log(_("No truecrypt support available (not found)!")+"\n", LOG_ANY)
+			self.log(_("No truecrypt support available (%s)!")%tc_error_message+"\n", LOG_ANY)
 
 
 		if not self.has_luks_support:
