diff options
author | Kim Alvefur <zash@zash.se> | 2015-09-27 00:37:18 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2015-09-27 00:37:18 +0200 |
commit | 3fc78cf2154d9a870763a06801bd167ddabf1c61 (patch) | |
tree | 2e6a296aac1eb2dbf8f40a56235d32870b270b99 /plugins | |
parent | a8ff283e3d24ebdd007050e37106ac786af2eaee (diff) | |
parent | 23fa3312e7d966a9205274189eb6b5d0d793c3be (diff) | |
download | prosody-3fc78cf2154d9a870763a06801bd167ddabf1c61.tar.gz prosody-3fc78cf2154d9a870763a06801bd167ddabf1c61.zip |
Merge 0.10->trunk
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_http_files.lua | 4 | ||||
-rw-r--r-- | plugins/mod_posix.lua | 44 |
2 files changed, 24 insertions, 24 deletions
diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 2e9f4182..7c503c82 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -61,8 +61,8 @@ function serve(opts) local function serve_file(event, path) local request, response = event.request, event.response; local orig_path = request.path; - local full_path = base_path .. (path and "/"..path or ""); - local attr = stat((full_path:gsub('%'..path_sep..'+$',''))); + local full_path = base_path .. (path and "/"..path or ""):gsub("/", path_sep); + local attr = stat(full_path:match("^.*[^\\/]")); -- Strip trailing path separator because Windows if not attr then return 404; end diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua index c9b9f3aa..7e6d8799 100644 --- a/plugins/mod_posix.lua +++ b/plugins/mod_posix.lua @@ -14,8 +14,8 @@ if pposix._VERSION ~= want_pposix_version then module:log("warn", "Unknown version (%s) of binary pposix module, expected %s. Perhaps you need to recompile?", tostring(pposix._VERSION), want_pposix_version); end -local signal = select(2, pcall(require, "util.signal")); -if type(signal) == "string" then +local have_signal, signal = pcall(require, "util.signal"); +if not have_signal then module:log("warn", "Couldn't load signal library, won't respond to SIGTERM"); end @@ -31,27 +31,27 @@ pposix.umask(umask); -- Allow switching away from root, some people like strange ports. module:hook("server-started", function () - local uid = module:get_option("setuid"); - local gid = module:get_option("setgid"); - if gid then - local success, msg = pposix.setgid(gid); - if success then - module:log("debug", "Changed group to %s successfully.", gid); - else - module:log("error", "Failed to change group to %s. Error: %s", gid, msg); - prosody.shutdown("Failed to change group to %s", gid); - end + local uid = module:get_option("setuid"); + local gid = module:get_option("setgid"); + if gid then + local success, msg = pposix.setgid(gid); + if success then + module:log("debug", "Changed group to %s successfully.", gid); + else + module:log("error", "Failed to change group to %s. Error: %s", gid, msg); + prosody.shutdown("Failed to change group to %s", gid); end - if uid then - local success, msg = pposix.setuid(uid); - if success then - module:log("debug", "Changed user to %s successfully.", uid); - else - module:log("error", "Failed to change user to %s. Error: %s", uid, msg); - prosody.shutdown("Failed to change user to %s", uid); - end + end + if uid then + local success, msg = pposix.setuid(uid); + if success then + module:log("debug", "Changed user to %s successfully.", uid); + else + module:log("error", "Failed to change user to %s. Error: %s", uid, msg); + prosody.shutdown("Failed to change user to %s", uid); end - end); + end +end); -- Don't even think about it! if not prosody.start_time then -- server-starting @@ -162,7 +162,7 @@ end module:hook("server-stopped", remove_pidfile); -- Set signal handlers -if signal.signal then +if have_signal then signal.signal("SIGTERM", function () module:log("warn", "Received SIGTERM"); prosody.unlock_globals(); |