Revision
107
Author
ludovic.rousseau@gmail.com
Date
2010-02-02 02:05:56 -0800 (Tue, 02 Feb 2010)

Log Message

GemaltoToken::probe(): only use libraries that ends in ".dylib"
It is then easy to disable a PKCS#11 lib by changing its file name extension

Modified Paths

Diff

Modified: trunk/Tokend/PKCS11/GemaltoToken.cpp (106 => 107)


--- trunk/Tokend/PKCS11/GemaltoToken.cpp	2010-02-02 07:21:29 UTC (rev 106)
+++ trunk/Tokend/PKCS11/GemaltoToken.cpp	2010-02-02 10:05:56 UTC (rev 107)
@@ -310,6 +310,14 @@
 				if ((strcmp(dir_entry->d_name, ".") == 0) || (strcmp(dir_entry->d_name, "..") == 0))
 					continue;
 				
+				/* only use files ending with ".dylib" */
+#define VALID_FILE_EXTENSION ".dylib"
+				char *ext = dir_entry->d_name + strlen(dir_entry->d_name) - sizeof(VALID_FILE_EXTENSION)+1;
+				if (/* file name is at least as long as the extention */
+					ext > dir_entry->d_name
+					&& strcasecmp(ext, VALID_FILE_EXTENSION) != 0)
+					continue;
+
 				lib_name.append(dir_entry->d_name);
 				dlPath = lib_name.c_str();
 				log( "GemaltoToken::probe - Using %s PKCS#11 library\n", dlPath );