aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/datamanager.lua19
-rw-r--r--util/prosodyctl.lua4
-rw-r--r--util/stanza.lua2
3 files changed, 18 insertions, 7 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index 9f7600ee..17c614ed 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -309,18 +309,29 @@ function list_stores(username, host)
return list;
end
+local function do_remove(path)
+ local ok, err = os_remove(path);
+ if not ok and lfs.attributes(path, "mode") then
+ return ok, err;
+ end
+ return true
+end
+
function purge(username, host)
local host_dir = format("%s/%s/", data_path, encode(host));
local deleted = 0;
+ local errs = {};
for file in lfs.dir(host_dir) do
if lfs.attributes(host_dir..file, "mode") == "directory" then
local store = decode(file);
- deleted = deleted + (os_remove(getpath(username, host, store)) and 1 or 0);
- deleted = deleted + (os_remove(getpath(username, host, store, "list")) and 1 or 0);
- -- We this will generate loads of "No such file or directory", but do we care?
+ local ok, err = do_remove(getpath(username, host, store));
+ if not ok then errs[#errs+1] = err; end
+
+ local ok, err = do_remove(getpath(username, host, store, "list"));
+ if not ok then errs[#errs+1] = err; end
end
end
- return deleted > 0, deleted;
+ return #errs == 0, t_concat(errs, ", ");
end
return _M;
diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua
index a598a44a..e38f85d4 100644
--- a/util/prosodyctl.lua
+++ b/util/prosodyctl.lua
@@ -176,9 +176,9 @@ function deluser(params)
if not _M.user_exists(params) then
return false, "no-such-user";
end
- params.password = nil;
+ local user, host = nodeprep(params.user), nameprep(params.host);
- return _M.adduser(params);
+ return usermanager.delete_user(user, host);
end
function getpid()
diff --git a/util/stanza.lua b/util/stanza.lua
index 5c430f1d..a0ab2a5a 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -237,7 +237,7 @@ function stanza_mt.get_error(stanza)
end
type = error_tag.attr.type;
- for child in error_tag:childtags() do
+ for _, child in ipairs(error_tag.tags) do
if child.attr.xmlns == xmlns_stanzas then
if not text and child.name == "text" then
text = child:get_text();