diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-11-14 21:58:39 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-11-14 21:58:39 -0700 |
commit | 9de56d43f054bc5e509e38bda1a048e5af6d73d7 (patch) | |
tree | 3f746c0f72f939d32c68f847b2d11020e9ff75c4 /ipalib/plugins | |
parent | 36737c2d913716eb99aece5cc1f6a21234abe46a (diff) | |
download | freeipa-9de56d43f054bc5e509e38bda1a048e5af6d73d7.tar.gz freeipa-9de56d43f054bc5e509e38bda1a048e5af6d73d7.tar.xz freeipa-9de56d43f054bc5e509e38bda1a048e5af6d73d7.zip |
env plugin now subclasses from RemoteOrLocal
Diffstat (limited to 'ipalib/plugins')
-rw-r--r-- | ipalib/plugins/f_misc.py | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/ipalib/plugins/f_misc.py b/ipalib/plugins/f_misc.py index 05fd6d525..6988d6f87 100644 --- a/ipalib/plugins/f_misc.py +++ b/ipalib/plugins/f_misc.py @@ -21,44 +21,36 @@ Misc frontend plugins. """ -from ipalib import api, Command, Param, Bool +from ipalib import api, LocalOrRemote # FIXME: We should not let env return anything in_server # when mode == 'production'. This would allow an attacker to see the # configuration of the server, potentially revealing compromising # information. However, it's damn handy for testing/debugging. -class env(Command): +class env(LocalOrRemote): """Show environment variables""" takes_args = ('variables*',) - takes_options = ( - Param('server?', type=Bool(), default=False, - doc='Show environment variables of server', - ), - ) - - def run(self, variables, **options): - if options['server'] and not self.env.in_server: - return self.forward(variables) - return self.execute(variables) - - def find_keys(self, variables): + def __find_keys(self, variables): for key in variables: if key in self.env: yield (key, self.env[key]) - def execute(self, variables): + def execute(self, variables, **options): if variables is None: return tuple( (key, self.env[key]) for key in self.env ) - return tuple(self.find_keys(variables)) + return tuple(self.__find_keys(variables)) def output_for_cli(self, textui, result, variables, **options): if len(result) == 0: return + if len(result) == 1: + textui.print_keyval(result) + return textui.print_name(self.name) textui.print_keyval(result) textui.print_count(result, '%d variable', '%d variables') |