URL: https://github.com/freeipa/freeipa/pull/617 Author: stlaz Title: #617: Allow renaming of sudo rules Action: opened
PR body: """ This simple hack adds a rename option to client side sudorule-mod command. https://pagure.io/freeipa/issue/2466 """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/617/head:pr617 git checkout pr617
From b3a69f71a7e6edef7792be6efa51dfd62edff820 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka <slazn...@redhat.com> Date: Thu, 16 Mar 2017 16:22:52 +0100 Subject: [PATCH] Allow renaming of sudo rules This simple hack adds a rename option to client side sudorule-mod command. https://pagure.io/freeipa/issue/2466 --- ipaclient/plugins/sudorule.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ipaclient/plugins/sudorule.py b/ipaclient/plugins/sudorule.py index a876280..679ffe9 100644 --- a/ipaclient/plugins/sudorule.py +++ b/ipaclient/plugins/sudorule.py @@ -20,6 +20,7 @@ from ipaclient.frontend import MethodOverride from ipalib.plugable import Registry from ipalib import _ +from ipalib.parameters import Str register = Registry() @@ -55,3 +56,24 @@ def output_for_cli(self, textui, result, cn, **options): % dict(option=options['ipasudoopt'], rule=cn)) super(sudorule_remove_option, self).output_for_cli(textui, result, cn, **options) + + +@register(override=True, no_fail=True) +class sudorule_mod(MethodOverride): + takes_options = ( + Str('rename', + cli_name='rename', + required=False, + label=_('Rename'), + doc=_('Rename the sudorule object') + ) + ) + + def forward(self, *options, **args): + if 'rename' in args: + rename_str = u'cn={newname}'.format(newname=args['rename']) + set_opt = args.get('setattr', []) + set_opt.append(rename_str) + args['setattr'] = set_opt + del args['rename'] + return super(sudorule_mod, self).forward(*options, **args)
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code