From 261865134b4ca6a26dd7557ab11d8dfef1673693 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antonio=20Torres=20Mor=C3=AD=C3=B1igo?=
 <atorresm@protonmail.com>
Date: Thu, 26 Nov 2020 21:42:03 +0100
Subject: [PATCH] Allow leading/trailing whitespaces in passwords
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

kwargs is redefined to Data.kwargs, which doesn't contain
the restriction of no leading/trailing whitespaces from
the Str class.

Fixes: https://pagure.io/freeipa/issue/7599

Signed-off-by: Antonio Torres Moríñigo <atorresm@protonmail.com>
---
 ipalib/parameters.py      | 2 ++
 ipaserver/plugins/host.py | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index f06e1afeeca..7f37ffd6373 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -1646,6 +1646,8 @@ class Password(Str):
     A parameter for passwords (stored in the ``unicode`` type).
     """
 
+    kwargs = Data.kwargs
+
     password = True
 
     def _convert_scalar(self, value, index=None):
diff --git a/ipaserver/plugins/host.py b/ipaserver/plugins/host.py
index 766d232db58..99d24f4b0c8 100644
--- a/ipaserver/plugins/host.py
+++ b/ipaserver/plugins/host.py
@@ -27,7 +27,7 @@
 from ipalib import api, errors, util
 from ipalib import messages
 from ipalib import Str, StrEnum, Flag
-from ipalib.parameters import Principal, Certificate
+from ipalib.parameters import Data, Principal, Certificate
 from ipalib.plugable import Registry
 from .baseldap import (LDAPQuery, LDAPObject, LDAPCreate,
                                      LDAPDelete, LDAPUpdate, LDAPSearch,
@@ -260,6 +260,9 @@ class HostPassword(Str):
     setting a password on the command-line which would break
     backwards compatibility.
     """
+
+    kwargs = Data.kwargs
+
     def safe_value(self, value):
         return u'********'
 
