]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool: Fix for gpo restore not working without --tmpdir
authorKacper <kacper@kacper.se>
Wed, 30 Aug 2023 12:33:49 +0000 (14:33 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 29 Sep 2023 03:15:18 +0000 (03:15 +0000)
cmd_restore depends on cmd_create but the later cleans up
required temp files for cmd_restore to function.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15462

RN: Fix for gpo restore not working without --tmpdir

Signed-off-by: Kacper Boström <kacper@kacper.se>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Sep 29 03:15:18 UTC 2023 on atb-devel-224

python/samba/netcmd/gpo.py

index 7c2df29bdc5de059b88ea6b011d68117d4d1491c..e32837a0f0c345d6e85728d040a346dac909ea93 100644 (file)
@@ -1664,6 +1664,11 @@ class cmd_restore(cmd_create):
                                      credopts, versionopts)
 
         try:
+            if tmpdir is None:
+                # Create GPT
+                self.tmpdir, gpodir = self.construct_tmpdir(tmpdir, self.gpo_name)
+                self.gpodir = gpodir
+
             # Iterate over backup files and restore with DTD
             self.restore_from_backup_to_local_dir(backup, self.gpodir,
                                                   dtd_header)
@@ -1692,6 +1697,10 @@ class cmd_restore(cmd_create):
 
                     self.samdb.modify(m)
 
+            if tmpdir is None:
+                # Without --tmpdir, we created one in /tmp/. It must go.
+                shutil.rmtree(self.tmpdir)
+
         except Exception as e:
             import traceback
             traceback.print_exc()