Merge with Rob

Sun, 03 Jan 2010 15:17:51 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 03 Jan 2010 15:17:51 +0000
changeset 2413
feb46e05d498
parent 2410
ce912b648741 (diff)
parent 2412
e243b7c81de6 (current diff)
child 2416
89be536aae25

Merge with Rob

--- a/plugins/mod_httpserver.lua	Wed Dec 30 13:26:11 2009 -0600
+++ b/plugins/mod_httpserver.lua	Sun Jan 03 15:17:51 2010 +0000
@@ -15,6 +15,7 @@
 local http_base = config.get("*", "core", "http_path") or "www_files";
 
 local response_400 = { status = "400 Bad Request", body = "<h1>Bad Request</h1>Sorry, we didn't understand your request :(" };
+local response_403 = { status = "403 Forbidden", body = "<h1>Forbidden</h1>You don't have permission to view the contents of this directory :(" };
 local response_404 = { status = "404 Not Found", body = "<h1>Page Not Found</h1>Sorry, we couldn't find what you were looking for :(" };
 
 -- TODO: Should we read this from /etc/mime.types if it exists? (startup time...?)
@@ -51,6 +52,9 @@
 	if not f then return response_404; end
 	local data = f:read("*a");
 	f:close();
+	if not data then
+		return response_403;
+	end
 	local ext = path:match("%.([^.]*)$");
 	local mime = mime_map[ext]; -- Content-Type should be nil when not known
 	return {
--- a/prosody.cfg.lua.dist	Wed Dec 30 13:26:11 2009 -0600
+++ b/prosody.cfg.lua.dist	Sun Jan 03 15:17:51 2010 +0000
@@ -1,38 +1,38 @@
--- Prosody Example Configuration File 
+-- Prosody Example Configuration File
 -- 
--- If it wasn't already obvious, -- starts a comment, and all 
+-- If it wasn't already obvious, -- starts a comment, and all
 -- text after it on a line is ignored by Prosody.
 --
--- The config is split into sections, a global section, and one 
--- for each defined host that we serve. You can add as many host 
+-- The config is split into sections, a global section, and one
+-- for each defined host that we serve. You can add as many host
 -- sections as you like.
 --
--- Lists are written { "like", "this", "one" } 
--- Lists can also be of { 1, 2, 3 } numbers, and other things. 
+-- Lists are written { "like", "this", "one" }
+-- Lists can also be of { 1, 2, 3 } numbers, and other things.
 -- Either commas, or semi-colons; may be used
 -- as seperators.
 --
--- A table is a list of values, except each value has a name. An 
+-- A table is a list of values, except each value has a name. An
 -- example table would be:
 --
 -- ssl = { key = "keyfile.key", certificate = "certificate.cert" }
 --
--- Whitespace (that is tabs, spaces, line breaks) is mostly insignificant, so 
--- can 
+-- Whitespace (that is tabs, spaces, line breaks) is mostly insignificant, so
+-- can
 -- be placed anywhere that 	you deem fitting.
 --
 -- Tip: You can check that the syntax of this file is correct when you have finished
 -- by running: luac -p prosody.cfg.lua
--- If there are any errors, it will let you know what and where they are, otherwise it 
+-- If there are any errors, it will let you know what and where they are, otherwise it
 -- will keep quiet.
 --
--- The only thing left to do is rename this file to remove the .dist ending, and fill in the 
+-- The only thing left to do is rename this file to remove the .dist ending, and fill in the
 -- blanks. Good luck, and happy Jabbering!
 
 -- Server-wide settings go in this section
 Host "*"
 	
-	-- This is a (by default, empty) list of accounts that are admins 
+	-- This is a (by default, empty) list of accounts that are admins
 	-- for the server. Note that you must create the accounts separately
 	-- (see http://prosody.im/doc/creating_accounts for info)
 	-- Example: admins = { "user1@example.com", "user2@example.net" }
@@ -63,7 +63,7 @@
 
 			-- Other specific functionality
 				--"posix"; -- POSIX functionality, sends server to background, enables syslog, etc.
-			  	--"console"; -- telnet to port 5582 (needs console_enabled = true)
+			  	--"console"; -- Opens admin telnet interface on localhost port 5582
 				--"bosh"; -- Enable BOSH clients, aka "Jabber over HTTP"
 				--"httpserver"; -- Serve static files from a directory over HTTP
 			  };
@@ -83,7 +83,7 @@
 	
 	-- These are the SSL/TLS-related settings. If you don't want
 	-- to use SSL/TLS, you may comment or remove this
-	ssl = { 
+	ssl = {
 		key = "certs/localhost.key";
 		certificate = "certs/localhost.cert";
 		}
@@ -101,7 +101,7 @@
 	-- set in the global section (if any).
 	-- Note that old-style SSL on port 5223 only supports one certificate, and will always
 	-- use the global one.
-	ssl = { 
+	ssl = {
 		key = "certs/example.com.key";
 		certificate = "certs/example.com.crt";
 		}
--- a/prosodyctl	Wed Dec 30 13:26:11 2009 -0600
+++ b/prosodyctl	Sun Jan 03 15:17:51 2010 +0000
@@ -137,18 +137,33 @@
 end
 
 local function getchar(n)
-	os.execute("stty raw -echo");
-	local ok, char = pcall(io.read, n or 1);
-	os.execute("stty sane");
+	local stty_ret = os.execute("stty raw -echo 2>/dev/null");
+	local ok, char;
+	if stty_ret == 0 then
+		ok, char = pcall(io.read, n or 1);
+		os.execute("stty sane");
+	else
+		ok, char = pcall(io.read, "*l");
+		if ok then
+			char = char:sub(1, n or 1);
+		end
+	end
 	if ok then
 		return char;
 	end
 end
 	
 local function getpass()
-	os.execute("stty -echo");
+	local stty_ret = os.execute("stty -echo 2>/dev/null");
+	if stty_ret ~= 0 then
+		io.write("\027[08m"); -- ANSI 'hidden' text attribute
+	end
 	local ok, pass = pcall(io.read, "*l");
-	os.execute("stty sane");
+	if stty_ret == 0 then
+		os.execute("stty sane");
+	else
+		io.write("\027[00m");
+	end
 	io.write("\n");
 	if ok then
 		return pass;
--- a/util-src/signal.c	Wed Dec 30 13:26:11 2009 -0600
+++ b/util-src/signal.c	Sun Jan 03 15:17:51 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * lsignal.h -- Signal Handler Library for Lua
+ * signal.c -- Signal Handler Library for Lua
  *
  * Version: 1.000
  *
--- a/util/events.lua	Wed Dec 30 13:26:11 2009 -0600
+++ b/util/events.lua	Sun Jan 03 15:17:51 2010 +0000
@@ -47,13 +47,13 @@
 			_rebuild_index(event);
 		end
 	end;
-	local function add_plugin(plugin)
-		for event, handler in pairs(plugin) do
+	local function add_handlers(handlers)
+		for event, handler in pairs(handlers) do
 			add_handler(event, handler);
 		end
 	end;
-	local function remove_plugin(plugin)
-		for event, handler in pairs(plugin) do
+	local function remove_handlers(handlers)
+		for event, handler in pairs(handlers) do
 			remove_handler(event, handler);
 		end
 	end;
--- a/util/sasl_cyrus.lua	Wed Dec 30 13:26:11 2009 -0600
+++ b/util/sasl_cyrus.lua	Sun Jan 03 15:17:51 2010 +0000
@@ -31,12 +31,25 @@
 
 local method = {};
 method.__index = method;
+local initialized = false;
 
-pcall(cyrussasl.server_init, "prosody")
+local function init(service_name)
+	if not initialized then
+		local st, errmsg = pcall(cyrussasl.server_init, service_name);
+		if st then
+			initialized = true;
+		else
+			log("error", "Failed to initialize CyrusSASL: %s", errmsg);
+		end
+	end
+end
 
 -- create a new SASL object which can be used to authenticate clients
 function new(realm, service_name)
 	local sasl_i = {};
+
+	init(service_name);
+
 	sasl_i.realm = realm;
 	sasl_i.service_name = service_name;
 	sasl_i.cyrus = cyrussasl.server_new(service_name, nil, nil, nil, nil)
@@ -64,17 +77,17 @@
 function method:mechanisms()
 	local mechanisms = {}
 	local cyrus_mechs = cyrussasl.listmech(self.cyrus, nil, "", " ", "")
-	for w in s_gmatch(cyrus_mechs, "%a+") do
+	for w in s_gmatch(cyrus_mechs, "[^ ]+") do
 		mechanisms[w] = true;
 	end
-	self.mechanisms = mechanisms
+	self.mechs = mechanisms
 	return array.collect(keys(mechanisms));
 end
 
 -- select a mechanism to use
 function method:select(mechanism)
 	self.mechanism = mechanism;
-	return self.mechanisms[mechanism];
+	return self.mechs[mechanism];
 end
 
 -- feed new messages to process into the library

mercurial