From ff4279575f271fbbf04892c79e038d9fbaa96da3 Mon Sep 17 00:00:00 2001 From: David Mulder Date: Fri, 11 Dec 2020 10:38:32 -0700 Subject: [PATCH] gpo: Ensure empty Security sections are removed Failing to remove the empty section causes tests to fail, and is also just bad practice. Signed-off-by: David Mulder Reviewed-by: Jeremy Allison --- python/samba/netcmd/gpo.py | 2 ++ selftest/knownfail.d/gpo | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 selftest/knownfail.d/gpo diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index a0629feb4cd..33069200a44 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -1986,6 +1986,8 @@ PasswordComplexity Password must meet complexity requirements inf_data.set(section, policy, value) else: inf_data.remove_option(section, policy) + if len(inf_data.options(section)) == 0: + inf_data.remove_section(section) out = StringIO() inf_data.write(out) diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo deleted file mode 100644 index f01f38d75a2..00000000000 --- a/selftest/knownfail.d/gpo +++ /dev/null @@ -1 +0,0 @@ -^samba.tests.samba_tool.gpo.samba.tests.samba_tool.gpo.GpoCmdTestCase.test_security_nonempty_sections -- 2.47.3