From: David Mulder Date: Fri, 11 Dec 2020 17:38:32 +0000 (-0700) Subject: gpo: Ensure empty Security sections are removed X-Git-Tag: tevent-0.11.0~1767 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ff4279575f271fbbf04892c79e038d9fbaa96da3;p=thirdparty%2Fsamba.git 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 --- 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