aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/datamanager.lua18
-rw-r--r--util/sasl/scram.lua2
2 files changed, 14 insertions, 6 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index 01c7aab2..57cd2594 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -21,12 +21,13 @@ local next = next;
local t_insert = table.insert;
local append = require "util.serialization".append;
local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end
+local lfs = require "lfs";
local raw_mkdir;
if prosody.platform == "posix" then
raw_mkdir = require "util.pposix".mkdir; -- Doesn't trample on umask
else
- raw_mkdir = require "lfs".mkdir;
+ raw_mkdir = lfs.mkdir;
end
module "datamanager"
@@ -111,14 +112,21 @@ end
function load(username, host, datastore)
local data, ret = loadfile(getpath(username, host, datastore));
if not data then
- log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
- return nil;
+ local mode = lfs.attributes(getpath(username, host, datastore), "mode");
+ if not mode then
+ log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+ return nil;
+ else -- file exists, but can't be read
+ -- TODO more detailed error checking and logging?
+ log("error", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+ return nil, "Error reading storage";
+ end
end
setfenv(data, {});
local success, ret = pcall(data);
if not success then
log("error", "Unable to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
- return nil;
+ return nil, "Error reading storage";
end
return ret;
end
@@ -137,7 +145,7 @@ function store(username, host, datastore, data)
local f, msg = io_open(getpath(username, host, datastore, nil, true), "w+");
if not f then
log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..(username or "nil").."@"..(host or "nil"));
- return;
+ return nil, "Error saving to storage";
end
f:write("return ");
append(f, data);
diff --git a/util/sasl/scram.lua b/util/sasl/scram.lua
index 47e8e7b3..6040c402 100644
--- a/util/sasl/scram.lua
+++ b/util/sasl/scram.lua
@@ -212,4 +212,4 @@ function init(registerMechanism)
registerSCRAMMechanism("SHA-1", sha1, hmac_sha1);
end
-return _M; \ No newline at end of file
+return _M;