From 98e85fc611bc7ba64ef56b3cb03b60213af1b79b Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Mon, 22 Aug 2022 11:48:53 +1200 Subject: [PATCH] samba-tool domain provision: better message if tdbbackup missing BUG: https://bugzilla.samba.org/show_bug.cgi?id=12893 Reported-by: Jeff Sadowski Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- python/samba/netcmd/domain_backup.py | 6 ++++++ python/samba/tdb_util.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/python/samba/netcmd/domain_backup.py b/python/samba/netcmd/domain_backup.py index 6cb0e512595..9c2c9e421f8 100644 --- a/python/samba/netcmd/domain_backup.py +++ b/python/samba/netcmd/domain_backup.py @@ -983,10 +983,16 @@ class cmd_domain_backup_offline(samba.netcmd.Command): return raise e raise copy_err + + except FileNotFoundError as e: + # tdbbackup tool was not found. + raise CommandError(e.strerror, e) + if not os.path.exists(backup_path): s = "tdbbackup said backup succeeded but {0} not found" raise CommandError(s.format(backup_path)) + def offline_mdb_copy(self, path): mdb_copy(path, path + self.backup_ext) diff --git a/python/samba/tdb_util.py b/python/samba/tdb_util.py index badfbd66bba..99b6e02e03f 100644 --- a/python/samba/tdb_util.py +++ b/python/samba/tdb_util.py @@ -32,6 +32,10 @@ def tdb_copy(file1, file2, readonly=False): toolpath = os.path.join(d, "tdbbackup") if os.path.exists(toolpath): break + else: + # we did not find a path to tdbbackup + raise FileNotFoundError(2, "could not find tdbbackup tool: " + "is tdb-tools installed?") tdbbackup_cmd = [toolpath, "-s", ".copy.tdb", file1] if readonly: