When the policy exists already, there is no exception and the code
tries to use the "data" variable, but it doesn't exist because it was
only defined in the exception handling.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15774
Signed-off-by: Andreas Hasenack <andreas.hasenack@canonical.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
(cherry picked from commit
e87e20c04d90292e3a5caac8ea3105b16f948ed3)
return
try:
- xml_data = ET.fromstring(conn.loadfile(vgp_xml))
+ xml_data = ET.ElementTree(ET.fromstring(conn.loadfile(vgp_xml)))
+ policysetting = xml_data.getroot().find('policysetting')
+ data = policysetting.find('data')
except NTSTATUSError as e:
if e.args[0] in [NT_STATUS_OBJECT_NAME_INVALID,
NT_STATUS_OBJECT_NAME_NOT_FOUND,
else:
raise
- text = ET.SubElement(data, 'text')
+ text = data.find('text')
+ if text is None:
+ text = ET.SubElement(data, 'text')
text.text = value
out = BytesIO()
+++ /dev/null
-^samba.tests.samba_tool.gpo.+GpoCmdTestCase.test_vgp_motd_set_thrice