Changeset

5838:a2659baf8332

mod_saslauth: Check whether LuaSec supports getpeerfinished() binding.
author Tobias Markmann <tm@ayena.de>
date Mon, 17 Jan 2011 16:50:21 +0100
parents 5837:574e91531994
children 5839:a65b56348034
files plugins/mod_saslauth.lua
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_saslauth.lua	Mon Jan 17 16:50:21 2011 +0100
+++ b/plugins/mod_saslauth.lua	Mon Jan 17 16:50:21 2011 +0100
@@ -247,10 +247,14 @@
 		end
 		origin.sasl_handler = usermanager_get_sasl_handler(module.host);
 		if origin.secure then
-			origin.sasl_handler:add_cb_handler("tls-unique", function(self)
-				return self.userdata:getpeerfinished();
-			end);
-			origin.sasl_handler["userdata"] = origin.conn:socket();
+			-- check wether LuaSec has the nifty binding to the function needed for tls-unique
+			-- FIXME: would be nice to have this check only once and not for every socket
+			if origin.conn:socket().getpeerfinished then
+				origin.sasl_handler:add_cb_handler("tls-unique", function(self)
+					return self.userdata:getpeerfinished();
+				end);
+				origin.sasl_handler["userdata"] = origin.conn:socket();
+			end
 		end
 		features:tag("mechanisms", mechanisms_attr);
 		for mechanism in pairs(origin.sasl_handler:mechanisms()) do