URL: https://github.com/freeipa/freeipa/pull/505
Author: HonzaCholasta
 Title: #505: dns: fix `dnsrecord_add` interactive mode
Action: opened

PR body:
"""
`dnsrecord_add` interactive mode might prompt for value of non-existent
arguments `a_part_create_reverse` and `aaaa_part_create_reverse`. This
happens because `dnsrecord_add` extra flags are incorrectly defined as
parts of the respective DNS records.

Remove extra flags from DNS record parts to fix the interactive mode on old
clients talking to new servers. Skip non-existent arguments in the
interactive mode to fix new clients talking to old servers.

https://fedorahosted.org/freeipa/ticket/6457
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/505/head:pr505
git checkout pr505
From 3e5ed07888cb523b89b5007b5017fdfbd91c47c0 Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jchol...@redhat.com>
Date: Thu, 23 Feb 2017 13:21:59 +0000
Subject: [PATCH] dns: fix `dnsrecord_add` interactive mode

`dnsrecord_add` interactive mode might prompt for value of non-existent
arguments `a_part_create_reverse` and `aaaa_part_create_reverse`. This
happens because `dnsrecord_add` extra flags are incorrectly defined as
parts of the respective DNS records.

Remove extra flags from DNS record parts to fix the interactive mode on old
clients talking to new servers. Skip non-existent arguments in the
interactive mode to fix new clients talking to old servers.

https://fedorahosted.org/freeipa/ticket/6457
---
 ipaclient/plugins/dns.py | 6 ++++++
 ipaserver/plugins/dns.py | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ipaclient/plugins/dns.py b/ipaclient/plugins/dns.py
index 2d3c5e2..f671897 100644
--- a/ipaclient/plugins/dns.py
+++ b/ipaclient/plugins/dns.py
@@ -73,6 +73,10 @@ def prompt_parts(rrtype, cmd, mod_dnsvalue=None):
         return user_options
 
     for part_id, part in enumerate(rrobj.params()):
+        name = part_name_format % (rrtype.lower(), part.name)
+        if name not in cmd.params:
+            continue
+
         if mod_parts:
             default = mod_parts[part_id]
         else:
@@ -92,6 +96,8 @@ def prompt_missing_parts(rrtype, cmd, kw, prompt_optional=False):
 
     for part in rrobj.params():
         name = part_name_format % (rrtype.lower(), part.name)
+        if name not in cmd.params:
+            continue
 
         if name in kw:
             continue
diff --git a/ipaserver/plugins/dns.py b/ipaserver/plugins/dns.py
index 40c9b51..7007928 100644
--- a/ipaserver/plugins/dns.py
+++ b/ipaserver/plugins/dns.py
@@ -3531,7 +3531,7 @@ def warning_suspicious_relative_name(self, result, *keys, **options):
             'dns{}record'.format(param.rrtype.lower()),
             (Object,),
             dict(
-                takes_params=(param.parts or ()) + (param.extra or ()),
+                takes_params=param.parts or (),
             )
         )
     )
-- 
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

Reply via email to