3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

networks: support more specific 'remote' permissions by target network, service, and command

Closes #457.
This commit is contained in:
James Lu 2017-08-07 00:46:53 -07:00
parent 6e0145c3b7
commit f3acb3c21d

View File

@ -64,11 +64,22 @@ def remote(irc, source, args):
Runs <command> on the remote network <network>. Plugin responses sent using irc.reply() are Runs <command> on the remote network <network>. Plugin responses sent using irc.reply() are
supported and returned here, but others are dropped due to protocol limitations.""" supported and returned here, but others are dropped due to protocol limitations."""
permissions.check_permissions(irc, source, ['networks.remote'])
args = remote_parser.parse_args(args) args = remote_parser.parse_args(args)
netname = args.network netname = args.network
permissions.check_permissions(irc, source, [
# Quite a few permissions are allowed. 'networks.remote' is the global permission,
'networks.remote',
# networks.remote.<network> allows running any command on a specific network,
'networks.remote.%s' % netname,
# networks.remote.<network>.<service> allows running any command on the given service on a
# specific network,
'networks.remote.%s.%s' % (netname, args.service),
# and networks.remote.<network>.<service>.<command> narrows this further into which command
# can be used.
'networks.remote.%s.%s.%s' % (netname, args.service, args.command[0])
])
# XXX: things like 'remote network1 remote network2 echo hi' will crash PyLink if the source network is network1... # XXX: things like 'remote network1 remote network2 echo hi' will crash PyLink if the source network is network1...
global REMOTE_IN_USE global REMOTE_IN_USE
if REMOTE_IN_USE.is_set(): if REMOTE_IN_USE.is_set():