summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorTim Beale <timbeale@catalyst.net.nz>2019-07-24 14:17:06 +1200
committerAndrew Bartlett <abartlet@samba.org>2019-07-24 07:07:01 +0000
commit9d2fd08249881702a4b4b881688d91576cc71ede (patch)
treea47a760a95cd5bdf70373b5f112d43df6eabbc64 /python
parent6c691bf84e41b1edd3228c219f7a94e108795d28 (diff)
downloadsamba-9d2fd08249881702a4b4b881688d91576cc71ede.tar.gz
netcmd: Better error message for backup with no RID pool
Add a better error message (and what to do about it) if the user tries to back up a DC that hasn't initialized its RID pool yet. Seems to be a fairly common problem hit by users. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14048 RN: Added more informative error message if the 'samba-tool domain backup' command fails due to no RID pool being present on the DC. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Jul 24 07:07:01 UTC 2019 on sn-devel-184
Diffstat (limited to 'python')
-rw-r--r--python/samba/netcmd/domain_backup.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/python/samba/netcmd/domain_backup.py b/python/samba/netcmd/domain_backup.py
index 4e32b4b9b1c..cca6db49b43 100644
--- a/python/samba/netcmd/domain_backup.py
+++ b/python/samba/netcmd/domain_backup.py
@@ -59,7 +59,7 @@ from samba.ndr import ndr_pack
# work out a SID (based on a free RID) to use when the domain gets restored.
# This ensures that the restored DC's SID won't clash with any other RIDs
# already in use in the domain
-def get_sid_for_restore(samdb):
+def get_sid_for_restore(samdb, logger):
# Find the DN of the RID set of the server
res = samdb.search(base=ldb.Dn(samdb, samdb.get_serverName()),
scope=ldb.SCOPE_BASE, attrs=["serverReference"])
@@ -78,7 +78,15 @@ def get_sid_for_restore(samdb):
'rIDNextRID'])
# Decode the bounds of the RID allocation pools
- rid = int(res[0].get('rIDNextRID')[0])
+ try:
+ rid = int(res[0].get('rIDNextRID')[0])
+ except IndexError:
+ logger.info("The RID pool for this DC is not initalized "
+ "(e.g. it may be a fairly new DC).")
+ logger.info("To initialize it, create a temporary user on this DC "
+ "(you can delete it later).")
+ raise CommandError("Cannot create backup - "
+ "please initialize this DC's RID pool first.")
def split_val(num):
high = (0xFFFFFFFF00000000 & int(num)) >> 32
@@ -255,7 +263,7 @@ class cmd_domain_backup_online(samba.netcmd.Command):
# Get a free RID to use as the new DC's SID (when it gets restored)
remote_sam = SamDB(url='ldap://' + server, credentials=creds,
session_info=system_session(), lp=lp)
- new_sid = get_sid_for_restore(remote_sam)
+ new_sid = get_sid_for_restore(remote_sam, logger)
realm = remote_sam.domain_dns_name()
# Grab the remote DC's sysvol files and bundle them into a tar file
@@ -838,7 +846,7 @@ class cmd_domain_backup_rename(samba.netcmd.Command):
# get a free RID to use as the new DC's SID (when it gets restored)
remote_sam = SamDB(url='ldap://' + server, credentials=creds,
session_info=system_session(), lp=lp)
- new_sid = get_sid_for_restore(remote_sam)
+ new_sid = get_sid_for_restore(remote_sam, logger)
# Grab the remote DC's sysvol files and bundle them into a tar file.
# Note we end up with 2 sysvol dirs - the original domain's files (that
@@ -1016,7 +1024,7 @@ class cmd_domain_backup_offline(samba.netcmd.Command):
check_targetdir(logger, targetdir)
samdb = SamDB(url=paths.samdb, session_info=system_session(), lp=lp)
- sid = get_sid_for_restore(samdb)
+ sid = get_sid_for_restore(samdb, logger)
backup_dirs = [paths.private_dir, paths.state_dir,
os.path.dirname(paths.smbconf)] # etc dir