mirror of
https://github.com/samba-team/samba.git
synced 2025-12-21 20:23:50 +03:00
python:netcmd:gpo: fix crash when updating an MOTD GPO
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>
This commit is contained in:
committed by
Douglas Bagnall
parent
969cb41e06
commit
e87e20c04d
@@ -3811,7 +3811,9 @@ samba-tool gpo manage motd set {31B2F340-016D-11D2-945F-00C04FB984F9} "Message f
|
||||
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,
|
||||
@@ -3837,7 +3839,9 @@ samba-tool gpo manage motd set {31B2F340-016D-11D2-945F-00C04FB984F9} "Message f
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user