# HG changeset patch # User Kim Alvefur # Date 1576878454 -3600 # Node ID 421b2f8369fd32fffef2e54d2243e6b2e36a98ab # Parent 3098eac31139c2f4326b7ffd4931d13afe76580b 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. diff -r 3098eac31139 -r 421b2f8369fd plugins/adhoc/adhoc.lib.lua --- 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) diff -r 3098eac31139 -r 421b2f8369fd plugins/adhoc/mod_adhoc.lua --- 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(); diff -r 3098eac31139 -r 421b2f8369fd plugins/mod_uptime.lua --- 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);