Software /
code /
prosody
Changeset
10565:421b2f8369fd
mod_adhoc: Improve permission setting (fix #1482) BC
Rename 'user' permission mode to 'any' for clarity, too easily mistaken
for what the 'local_user' setting does.
It is also removed as a default and made a required argument.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 20 Dec 2019 22:47:34 +0100 |
parents | 10564:3098eac31139 |
children | 10568:b6f93babebe8 |
files | plugins/adhoc/adhoc.lib.lua plugins/adhoc/mod_adhoc.lua plugins/mod_uptime.lua |
diffstat | 3 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/adhoc/adhoc.lib.lua Tue Dec 24 00:49:43 2019 +0100 +++ b/plugins/adhoc/adhoc.lib.lua Fri Dec 20 22:47:34 2019 +0100 @@ -21,7 +21,13 @@ end function _M.new(name, node, handler, permission) - return { name = name, node = node, handler = handler, cmdtag = _cmdtag, permission = (permission or "user") }; + if not permission then + error "adhoc.new() expects a permission argument, none given" + end + if permission == "user" then + error "the permission mode 'user' has been renamed 'any', please update your code" + end + return { name = name, node = node, handler = handler, cmdtag = _cmdtag, permission = permission }; end function _M.handle_cmd(command, origin, stanza)
--- a/plugins/adhoc/mod_adhoc.lua Tue Dec 24 00:49:43 2019 +0100 +++ b/plugins/adhoc/mod_adhoc.lua Fri Dec 20 22:47:34 2019 +0100 @@ -26,7 +26,7 @@ if (command.permission == "admin" and privileged) or (command.permission == "global_admin" and global_admin) or (command.permission == "local_user" and hostname == module.host) - or (command.permission == "user") then + or (command.permission == "any") then reply:tag("identity", { name = command.name, category = "automation", type = "command-node" }):up(); reply:tag("feature", { var = xmlns_cmd }):up(); @@ -57,7 +57,7 @@ if (command.permission == "admin" and admin) or (command.permission == "global_admin" and global_admin) or (command.permission == "local_user" and hostname == module.host) - or (command.permission == "user") then + or (command.permission == "any") then reply:tag("item", { name = command.name, node = node, jid = module:get_host() }); reply:up();
--- a/plugins/mod_uptime.lua Tue Dec 24 00:49:43 2019 +0100 +++ b/plugins/mod_uptime.lua Fri Dec 20 22:47:34 2019 +0100 @@ -42,6 +42,6 @@ return { info = uptime_text(), status = "completed" }; end -local descriptor = adhoc_new("Get uptime", "uptime", uptime_command_handler); +local descriptor = adhoc_new("Get uptime", "uptime", uptime_command_handler, "any"); module:provides("adhoc", descriptor);