82e9c3
From 6302769b83af75f267c76fe6f854d5b42b6b80f5 Mon Sep 17 00:00:00 2001
82e9c3
From: Florence Blanc-Renaud <flo@redhat.com>
82e9c3
Date: Oct 21 2021 19:58:19 +0000
82e9c3
Subject: ipa-server-install uninstall: remove tdb files
82e9c3
82e9c3
82e9c3
ipa-server-install uninstaller must remove samba *.tdb files
82e9c3
in /var/lib/samba, /var/lib/samba/private and /var/lib/samba/lock.
82e9c3
The current code calls rm on the relative path filename
82e9c3
instead of building an absolute path filename,
82e9c3
resulting in failure to remove the tdb files.
82e9c3
82e9c3
Related: https://pagure.io/freeipa/issue/8687
82e9c3
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
82e9c3
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
82e9c3
82e9c3
---
82e9c3
82e9c3
diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
82e9c3
index 24e90f3..e034fab 100644
82e9c3
--- a/ipaserver/install/adtrustinstance.py
82e9c3
+++ b/ipaserver/install/adtrustinstance.py
82e9c3
@@ -918,11 +918,18 @@ class ADTRUSTInstance(service.Service):
82e9c3
         ipautil.remove_file(self.smb_conf)
82e9c3
 
82e9c3
         # Remove samba's persistent and temporary tdb files
82e9c3
-        if os.path.isdir(paths.SAMBA_DIR):
82e9c3
-            tdb_files = [tdb_file for tdb_file in os.listdir(paths.SAMBA_DIR)
82e9c3
-                         if tdb_file.endswith(".tdb")]
82e9c3
-            for tdb_file in tdb_files:
82e9c3
-                ipautil.remove_file(tdb_file)
82e9c3
+        # in /var/lib/samba and /var/lib/samba/private
82e9c3
+        for smbpath in (paths.SAMBA_DIR,
82e9c3
+                        os.path.join(paths.SAMBA_DIR, "private"),
82e9c3
+                        os.path.join(paths.SAMBA_DIR, "lock")):
82e9c3
+            if os.path.isdir(smbpath):
82e9c3
+                tdb_files = [
82e9c3
+                    os.path.join(smbpath, tdb_file)
82e9c3
+                    for tdb_file in os.listdir(smbpath)
82e9c3
+                    if tdb_file.endswith(".tdb")
82e9c3
+                ]
82e9c3
+                for tdb_file in tdb_files:
82e9c3
+                    ipautil.remove_file(tdb_file)
82e9c3
 
82e9c3
         # Remove our keys from samba's keytab
82e9c3
         self.clean_samba_keytab()
82e9c3
82e9c3
From 82eaa2eac454aed75a498d2c6ccd9e921f9c8a89 Mon Sep 17 00:00:00 2001
82e9c3
From: Florence Blanc-Renaud <flo@redhat.com>
82e9c3
Date: Oct 21 2021 19:58:19 +0000
82e9c3
Subject: ipa-client-samba uninstall: remove tdb files
82e9c3
82e9c3
82e9c3
ipa-client-samba uninstaller must remove samba *.tdb files
82e9c3
in /var/lib/samba, /var/lib/samba/private and /var/lib/samba/lock.
82e9c3
The current code calls rm on the relative path filename
82e9c3
instead of building an absolute path filename,
82e9c3
resulting in failure to remove the tdb files.
82e9c3
82e9c3
Fixes: https://pagure.io/freeipa/issue/8687
82e9c3
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
82e9c3
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
82e9c3
82e9c3
---
82e9c3
82e9c3
diff --git a/ipaclient/install/ipa_client_samba.py b/ipaclient/install/ipa_client_samba.py
82e9c3
index fd89e59..222ff31 100755
82e9c3
--- a/ipaclient/install/ipa_client_samba.py
82e9c3
+++ b/ipaclient/install/ipa_client_samba.py
82e9c3
@@ -446,13 +446,17 @@ def uninstall(fstore, statestore, options):
82e9c3
         fstore.restore_file(paths.SMB_CONF)
82e9c3
 
82e9c3
     # Remove samba's persistent and temporary tdb files
82e9c3
-    tdb_files = [
82e9c3
-        tdb_file
82e9c3
-        for tdb_file in os.listdir(paths.SAMBA_DIR)
82e9c3
-        if tdb_file.endswith(".tdb")
82e9c3
-    ]
82e9c3
-    for tdb_file in tdb_files:
82e9c3
-        ipautil.remove_file(tdb_file)
82e9c3
+    # in /var/lib/samba and /var/lib/samba/private
82e9c3
+    for smbpath in (paths.SAMBA_DIR,
82e9c3
+                    os.path.join(paths.SAMBA_DIR, "private"),
82e9c3
+                    os.path.join(paths.SAMBA_DIR, "lock")):
82e9c3
+        tdb_files = [
82e9c3
+            os.path.join(smbpath, tdb_file)
82e9c3
+            for tdb_file in os.listdir(smbpath)
82e9c3
+            if tdb_file.endswith(".tdb")
82e9c3
+        ]
82e9c3
+        for tdb_file in tdb_files:
82e9c3
+            ipautil.remove_file(tdb_file)
82e9c3
 
82e9c3
     # Remove our keys from samba's keytab
82e9c3
     if os.path.exists(paths.SAMBA_KEYTAB):
82e9c3