mirror of
https://abf.rosa.ru/djam/samba.git
synced 2025-02-24 09:32:49 +00:00
54 lines
2.3 KiB
Diff
54 lines
2.3 KiB
Diff
From ea0d7ff3ae64d7eb7608b830920f3b5088b01925 Mon Sep 17 00:00:00 2001
|
|
From: Andrew Bartlett <abartlet@samba.org>
|
|
Date: Mon, 11 Mar 2019 13:48:29 +1300
|
|
Subject: [PATCH 2/2] samba-tool dbcheck: Avoid creating an RDN via ldb.Dn()
|
|
format arguments
|
|
|
|
If we instead call dn.set_component() to overwrite a dummy DN we avoid parsing
|
|
the full DN and set the RDN attribute and value directly as a string and
|
|
string/size pair.
|
|
|
|
This may avoid some Python string issues due to the different handling of strings
|
|
in Python2 and Python3.
|
|
|
|
[ mikhailnov: rediffed for v4.10.8 ]
|
|
|
|
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
|
|
Signed-off-by: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
|
|
---
|
|
python/samba/dbchecker.py | 12 ++++++++----
|
|
1 file changed, 8 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
|
|
index ffda828a522..95bd865e915 100644
|
|
--- a/python/samba/dbchecker.py
|
|
+++ b/python/samba/dbchecker.py
|
|
@@ -899,8 +899,10 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
|
try:
|
|
nc_root = self.samdb.get_nc_root(obj.dn)
|
|
lost_and_found = self.samdb.get_wellknown_dn(nc_root, dsdb.DS_GUID_LOSTANDFOUND_CONTAINER)
|
|
- new_dn = ldb.Dn(self.samdb, str(obj.dn))
|
|
- new_dn.remove_base_components(len(new_dn) - 1)
|
|
+ new_dn = ldb.Dn(self.samdb, "RDN=RDN")
|
|
+ new_dn.set_component(0, obj.dn.get_rdn_name(),
|
|
+ obj.dn.get_rdn_val())
|
|
+
|
|
if self.do_rename(obj.dn, new_dn, lost_and_found, ["show_deleted:0", "relax:0"],
|
|
"Failed to rename object %s into lostAndFound at %s" % (obj.dn, new_dn + lost_and_found)):
|
|
self.report("Renamed object %s into lostAndFound at %s" % (obj.dn, new_dn + lost_and_found))
|
|
@@ -925,8 +927,10 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
|
def err_wrong_dn(self, obj, new_dn, rdn_attr, rdn_val, name_val, controls):
|
|
'''handle a wrong dn'''
|
|
|
|
- new_rdn = ldb.Dn(self.samdb, str(new_dn))
|
|
- new_rdn.remove_base_components(len(new_rdn) - 1)
|
|
+ new_rdn = ldb.Dn(self.samdb, "RDN=RDN")
|
|
+ new_rdn.set_component(0, new_dn.get_rdn_name(),
|
|
+ new_dn.get_rdn_val())
|
|
+
|
|
new_parent = new_dn.parent()
|
|
|
|
attributes = ""
|
|
--
|
|
2.20.1
|
|
|