← Back to team overview

enterprise-support team mailing list archive

[Bug 2092308] [NEW] Backtrace when running "gpo manage motd set" to update an existing motd policy

 

Public bug reported:

When an motd policy already exists, the "set" command fails:

root@n-ad:~# samba-tool gpo manage motd set $gpo "Welcome" -U Administrator%Passw0rd
WARNING: Using passwords on command line is insecure. Installing the setproctitle python module will hide these from shortly after program start.
ERROR(<class 'UnboundLocalError'>): uncaught exception - cannot access local variable 'data' where it is not associated with a value
  File "/usr/lib/python3/dist-packages/samba/netcmd/__init__.py", line 279, in _run
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/samba/netcmd/gpo.py", line 3829, in run
    text = ET.SubElement(data, 'text')
                         ^^^^


Filed upstream as https://bugzilla.samba.org/show_bug.cgi?id=15774

This might be a fix (untested):
diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py
index 96fce917f0f..fe9b7caacb2 100644
--- a/python/samba/netcmd/gpo.py
+++ b/python/samba/netcmd/gpo.py
@@ -3808,7 +3808,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,

** Affects: samba (Ubuntu)
     Importance: Undecided
     Assignee: Andreas Hasenack (ahasenack)
         Status: In Progress


** Tags: server-todo

** Tags added: server-todo

** Changed in: samba (Ubuntu)
     Assignee: (unassigned) => Andreas Hasenack (ahasenack)

** Changed in: samba (Ubuntu)
       Status: New => In Progress

** Summary changed:

- Backtrace when running gpo manage motd set" to update an existing motd policy
+ Backtrace when running "gpo manage motd set" to update an existing motd policy

-- 
You received this bug notification because you are a member of Ubuntu
Server/Client Support Team, which is subscribed to samba in Ubuntu.
Matching subscriptions: Ubuntu Server/Client Support Team
https://bugs.launchpad.net/bugs/2092308

Title:
  Backtrace when running "gpo manage motd set" to update an existing
  motd policy

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/samba/+bug/2092308/+subscriptions



Follow ups