From bbe554acf4d164d8d3847f343395ba28abac0392 Mon Sep 17 00:00:00 2001 From: Florence Blanc-Renaud Date: Thu, 21 Oct 2021 16:09:20 +0200 Subject: [PATCH] ipa-server-install uninstall: remove tdb files ipa-server-install uninstaller must remove samba *.tdb files in /var/lib/samba, /var/lib/samba/private and /var/lib/samba/lock. The current code calls rm on the relative path filename instead of building an absolute path filename, resulting in failure to remove the tdb files. Related: https://pagure.io/freeipa/issue/8687 Signed-off-by: Florence Blanc-Renaud Reviewed-By: Alexander Bokovoy --- ipaserver/install/adtrustinstance.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py index 24e90f3ec..e034fabb3 100644 --- a/ipaserver/install/adtrustinstance.py +++ b/ipaserver/install/adtrustinstance.py @@ -918,11 +918,18 @@ class ADTRUSTInstance(service.Service): ipautil.remove_file(self.smb_conf) # Remove samba's persistent and temporary tdb files - if os.path.isdir(paths.SAMBA_DIR): - tdb_files = [tdb_file for tdb_file in os.listdir(paths.SAMBA_DIR) - if tdb_file.endswith(".tdb")] - for tdb_file in tdb_files: - ipautil.remove_file(tdb_file) + # in /var/lib/samba and /var/lib/samba/private + for smbpath in (paths.SAMBA_DIR, + os.path.join(paths.SAMBA_DIR, "private"), + os.path.join(paths.SAMBA_DIR, "lock")): + if os.path.isdir(smbpath): + tdb_files = [ + os.path.join(smbpath, tdb_file) + for tdb_file in os.listdir(smbpath) + if tdb_file.endswith(".tdb") + ] + for tdb_file in tdb_files: + ipautil.remove_file(tdb_file) # Remove our keys from samba's keytab self.clean_samba_keytab()