Branch: master

1ccfd00c 2016-09-21 18:35:58 Timothy Pearson
Create the PKCS#11 configuration directory if it does not exist before attempting to write the configuration file into it
M src/libtdeldap.cpp
diff --git a/src/libtdeldap.cpp b/src/libtdeldap.cpp
index 2ba3923..759b341 100644
--- a/src/libtdeldap.cpp
+++ b/src/libtdeldap.cpp
@@ -5136,6 +5136,14 @@
 	}
 
 	if (pamConfig.enable_pkcs11_login) {
+		TQDir pkcs11dir(PAMD_PKCS11_CONFIG_DIRECTORY);
+		if (!pkcs11dir.exists()) {
+			if (mkdir(PAMD_PKCS11_CONFIG_DIRECTORY, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) < 0) {
+				if (errstr) {
+					*errstr = i18n("Could not create directoy '%1'").arg(PAMD_PKCS11_CONFIG_DIRECTORY);
+				}
+			}
+		}
 		TQFile file4(PAMD_PKCS11_CONFIG_DIRECTORY PAMD_PKCS11_CONFIG_FILE);
 		if (file4.open(IO_WriteOnly)) {
 			TQTextStream stream( &file4 );