From 2beb72ffa4bea5e22c2ba4685a524df36d1f800c Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Thu, 30 Jun 2016 09:32:00 +0200 Subject: server: exclude Local commands from RPC Local API commands are not supposed to be executed over RPC but only locally on the server. They are already excluded from API schema, exclude them also from RPC and `batch` and `json_metadata` commands. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka --- ipaserver/plugins/batch.py | 4 +++- ipaserver/plugins/internal.py | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'ipaserver/plugins') diff --git a/ipaserver/plugins/batch.py b/ipaserver/plugins/batch.py index aa4ace918..b0c89ec46 100644 --- a/ipaserver/plugins/batch.py +++ b/ipaserver/plugins/batch.py @@ -49,6 +49,7 @@ import six from ipalib import api, errors from ipalib import Command +from ipalib.frontend import Local from ipalib.parameters import Str, Dict from ipalib.output import Output from ipalib.text import _ @@ -98,7 +99,8 @@ class batch(Command): if 'params' not in arg: raise errors.RequirementError(name='params') name = arg['method'] - if name not in self.Command: + if (name not in self.api.Command or + isinstance(self.api.Command[name], Local)): raise errors.CommandError(name=name) # If params are not formated as a tuple(list, dict) diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py index 5c1cfb885..5eee7572e 100644 --- a/ipaserver/plugins/internal.py +++ b/ipaserver/plugins/internal.py @@ -24,6 +24,7 @@ Plugins not accessible directly through the CLI, commands used internally """ from ipalib import Command from ipalib import Str +from ipalib.frontend import Local from ipalib.output import Output from ipalib.text import _ from ipalib.util import json_serialize @@ -91,13 +92,15 @@ class json_metadata(Command): try: if not methodname: methodname = options['method'] - if methodname in self.api.Method: + if (methodname in self.api.Method and + not isinstance(self.api.Method[methodname], Local)): m = self.api.Method[methodname] methods = dict([(m.name, json_serialize(m))]) elif methodname == "all": methods = dict( (m.name, json_serialize(m)) for m in self.api.Method() - if m is self.api.Method[m.name] + if (m is self.api.Method[m.name] and + not isinstance(m, Local)) ) empty = False except KeyError: @@ -105,13 +108,15 @@ class json_metadata(Command): try: cmdname = options['command'] - if cmdname in self.api.Command: + if (cmdname in self.api.Command and + not isinstance(self.api.Command[cmdname], Local)): c = self.api.Command[cmdname] commands = dict([(c.name, json_serialize(c))]) elif cmdname == "all": commands = dict( (c.name, json_serialize(c)) for c in self.api.Command() - if c is self.api.Command[c.name] + if (c is self.api.Command[c.name] and + not isinstance(c, Local)) ) empty = False except KeyError: @@ -124,11 +129,13 @@ class json_metadata(Command): ) methods = dict( (m.name, json_serialize(m)) for m in self.api.Method() - if m is self.api.Method[m.name] + if (m is self.api.Method[m.name] and + not isinstance(m, Local)) ) commands = dict( (c.name, json_serialize(c)) for c in self.api.Command() - if c is self.api.Command[c.name] + if (c is self.api.Command[c.name] and + not isinstance(c, Local)) ) retval = dict([ -- cgit