|
|
8394b4 |
From f05d6e7bfc4e829118e53f69f247d345a90e7796 Mon Sep 17 00:00:00 2001
|
|
|
8394b4 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
8394b4 |
Date: Mon, 13 Jan 2020 19:17:04 -0500
|
|
|
8394b4 |
Subject: [PATCH] Issue 50818 - dsconf pwdpolicy get error
|
|
|
8394b4 |
|
|
|
8394b4 |
Description: When trying to retrieve a global or local policy we now see:
|
|
|
8394b4 |
|
|
|
8394b4 |
policyError: 'PwPolicyManager' object has no attribute 'get_attr_list'
|
|
|
8394b4 |
|
|
|
8394b4 |
Someone removed the function get_attr_list() along the way.
|
|
|
8394b4 |
Added the same logic back, and improved it to only report attributes
|
|
|
8394b4 |
that are set.
|
|
|
8394b4 |
|
|
|
8394b4 |
relates: https://pagure.io/389-ds-base/issue/50818
|
|
|
8394b4 |
|
|
|
8394b4 |
Reviewed by: spichugi(Thanks!)
|
|
|
8394b4 |
---
|
|
|
8394b4 |
src/lib389/lib389/cli_conf/pwpolicy.py | 9 +++++----
|
|
|
8394b4 |
1 file changed, 5 insertions(+), 4 deletions(-)
|
|
|
8394b4 |
|
|
|
8394b4 |
diff --git a/src/lib389/lib389/cli_conf/pwpolicy.py b/src/lib389/lib389/cli_conf/pwpolicy.py
|
|
|
8394b4 |
index f911997bf..67bfd8767 100644
|
|
|
8394b4 |
--- a/src/lib389/lib389/cli_conf/pwpolicy.py
|
|
|
8394b4 |
+++ b/src/lib389/lib389/cli_conf/pwpolicy.py
|
|
|
8394b4 |
@@ -35,16 +35,17 @@ def _get_policy_type(inst, dn=None):
|
|
|
8394b4 |
def _get_pw_policy(inst, targetdn, log, use_json=None):
|
|
|
8394b4 |
pwp_manager = PwPolicyManager(inst)
|
|
|
8394b4 |
policy_type = _get_policy_type(inst, targetdn)
|
|
|
8394b4 |
- attr_list = pwp_manager.get_attr_list()
|
|
|
8394b4 |
+ attr_list = list(pwp_manager.arg_to_attr.values())
|
|
|
8394b4 |
if "global" in policy_type.lower():
|
|
|
8394b4 |
targetdn = 'cn=config'
|
|
|
8394b4 |
attr_list.extend(['passwordIsGlobalPolicy', 'nsslapd-pwpolicy_local'])
|
|
|
8394b4 |
- attrs = inst.config.get_attrs_vals_utf8(attr_list)
|
|
|
8394b4 |
+ all_attrs = inst.config.get_attrs_vals_utf8(attr_list)
|
|
|
8394b4 |
+ attrs = {k: v for k, v in all_attrs.items() if len(v) > 0}
|
|
|
8394b4 |
else:
|
|
|
8394b4 |
policy = pwp_manager.get_pwpolicy_entry(targetdn)
|
|
|
8394b4 |
targetdn = policy.dn
|
|
|
8394b4 |
- attrs = policy.get_attrs_vals_utf8(attr_list)
|
|
|
8394b4 |
-
|
|
|
8394b4 |
+ all_attrs = policy.get_attrs_vals_utf8(attr_list)
|
|
|
8394b4 |
+ attrs = {k: v for k, v in all_attrs.items() if len(v) > 0}
|
|
|
8394b4 |
if use_json:
|
|
|
8394b4 |
print(json.dumps({"type": "entry", "pwp_type": policy_type, "dn": ensure_str(targetdn), "attrs": attrs}))
|
|
|
8394b4 |
else:
|
|
|
8394b4 |
--
|
|
|
8394b4 |
2.21.1
|
|
|
8394b4 |
|