[SCM] Samba Shared Repository - branch v4-3-stable updated
Karolin Seeger
kseeger at samba.org
Tue Sep 8 16:08:08 UTC 2015
The branch, v4-3-stable has been updated
via b85f601 VERSION: Release Samba 4.3.0
via 73511d8 WHATSNEW: Add release notes for Samba 4.3.0.
via c581152 s4:torture:vfs_fruit: created empty resourceforks
via 2c67478 s4:torture:vfs_fruit: add a resource fork truncation test
via d282460 vfs_fruit: delete ._ file when deleting the basefile
via 05e8017 vfs_fruit: split and simplify fruit_ftruncate
via 6c10925 vfs_fruit: handling of empty resource fork
via 0befbeb samr4: Use <SID=%s> in GetGroupsForUser
via c7d8aca python/tests: Add more assertions that we get back the value we expect
via cbb9a2a python/tests: Add tests for 64 bit signed integers
via 215c284 pidl/python: also add a ndr_PyLong_FromLongLong() for symnetric reasons
via 14930fe pidl/python: Provide static inline helper function ndr_PyLong_FromUnsignedLongLong
via bd44d03 pidl/python: Calculate maximum integer values using a lookup table
via d2f2df6 selftest: Add assertion that we actually fix the replPropertyMetaData sort order
via 47af9ce selftest: Add in steps to re-create this database
via 74043c5 Update release-4-1-0rc3 to include data using schema modifications
via b5c196a ldb: create a cache of known wellknown objects instead of continously searching in the db
via e120381 dbcheck: Use set() operations to make dbcheck more efficient
via 9a8165b dbcheck: Try to avoid duplicate searches
via 3c29480 dbcheck: Add additional tests for the attributeID list
via df141f7 dbcheck: Add explict tests for unknown and unsorted attributeID values
via 429db95 pidl: Assert that python arrays will not overflow the C array
via 1e432b9 pydsdb: Allow the full range of uint32_t values for attributeID
via 43c6f8c python/tests: Add tests for integer overflow handling
via c9b80d7 pidl: Change PIDL to correctly use and validate python integer types
via a779039 python: Use an unsigned integer for buf_size, not -1
via c9ed862 WHATSNEW: Prepare release notes for Samba 4.3.0rc5
via df1bc8b VERSION: Bump version up to 4.3.0rc5...
from a05925b VERSION: Release Samba 4.3.0rc4
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-3-stable
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
VERSION | 2 +-
WHATSNEW.txt | 39 +-
pidl/lib/Parse/Pidl/Samba4/Python.pm | 215 +-
python/samba/dbchecker.py | 116 +-
python/samba/samdb.py | 15 +-
python/samba/tests/dcerpc/integer.py | 235 +
python/samba/tests/dcerpc/sam.py | 2 +-
python/samba/tests/dsdb.py | 24 +
selftest/knownfail | 5 +
selftest/tests.py | 1 +
source3/modules/vfs_fruit.c | 186 +-
source4/dsdb/pydsdb.c | 4 +-
source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 31 +-
source4/dsdb/samdb/samdb.h | 6 +
source4/rpc_server/samr/dcesrv_samr.c | 10 +-
...xpected-replpropertymetadata-after-dbcheck.ldif | 122 +
...pected-replpropertymetadata-before-dbcheck.ldif | 122 +
.../provisions/release-4-1-0rc3/private/dns.keytab | Bin 1037 -> 1037 bytes
...DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb.dump | 16082 ++++++-------
...DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb.dump | 22532 +++++++++---------
...DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb.dump | 364 +-
...DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb.dump | 198 +-
...DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb.dump | 4 +-
.../private/dns/sam.ldb.d/metadata.tdb.dump | 4 +-
.../release-4-1-0rc3/private/dns/sam.ldb.dump | 4 +-
.../release-4-1-0rc3/private/hklm.ldb.dump | 2 +-
.../release-4-1-0rc3/private/idmap.ldb.dump | 36 +-
.../provisions/release-4-1-0rc3/private/named.conf | 6 +-
.../provisions/release-4-1-0rc3/private/named.txt | 8 +-
.../release-4-1-0rc3/private/privilege.ldb.dump | 2 +-
...DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb.dump | 16154 ++++++-------
...DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb.dump | 22932 +++++++++----------
...DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb.dump | 364 +-
...DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb.dump | 198 +-
...DRELEASE-4-1-0RC3,DC%3DSAMBA,DC%3DCORP.ldb.dump | 2798 +--
.../private/sam.ldb.d/metadata.tdb.dump | 4 +-
.../release-4-1-0rc3/private/sam.ldb.dump | 8 +-
.../release-4-1-0rc3/private/secrets.keytab | Bin 1482 -> 1482 bytes
.../release-4-1-0rc3/private/secrets.ldb.dump | 10 +-
.../release-4-1-0rc3/private/secrets.tdb.dump | 4 +-
.../release-4-1-0rc3/private/share.ldb.dump | 2 +-
.../private/smbd.tmp/msg/names.tdb.dump | 24 +-
.../release-4-1-0rc3/steps-to-reproduce.txt | 30 +
.../provisions/release-4-1-0rc3/sudo.schema.2.ldif | 52 +
.../provisions/release-4-1-0rc3/sudo.schema.ldif | 235 +
.../provisions/release-4-1-0rc3/sudoers-mod.ldif | 4 +
.../provisions/release-4-1-0rc3/sudoers.ldif | 13 +
source4/setup/schema_samba4.ldif | 1 +
source4/torture/vfs/fruit.c | 247 +
testprogs/blackbox/dbcheck-oldrelease.sh | 47 +-
50 files changed, 42188 insertions(+), 41316 deletions(-)
create mode 100644 python/samba/tests/dcerpc/integer.py
create mode 100644 source4/selftest/provisions/release-4-1-0rc3/expected-replpropertymetadata-after-dbcheck.ldif
create mode 100644 source4/selftest/provisions/release-4-1-0rc3/expected-replpropertymetadata-before-dbcheck.ldif
create mode 100644 source4/selftest/provisions/release-4-1-0rc3/steps-to-reproduce.txt
create mode 100644 source4/selftest/provisions/release-4-1-0rc3/sudo.schema.2.ldif
create mode 100644 source4/selftest/provisions/release-4-1-0rc3/sudo.schema.ldif
create mode 100644 source4/selftest/provisions/release-4-1-0rc3/sudoers-mod.ldif
create mode 100644 source4/selftest/provisions/release-4-1-0rc3/sudoers.ldif
Changeset truncated at 500 lines:
diff --git a/VERSION b/VERSION
index 041639a..2be8ba8 100644
--- a/VERSION
+++ b/VERSION
@@ -87,7 +87,7 @@ SAMBA_VERSION_PRE_RELEASE=
# e.g. SAMBA_VERSION_RC_RELEASE=1 #
# -> "3.0.0rc1" #
########################################################
-SAMBA_VERSION_RC_RELEASE=4
+SAMBA_VERSION_RC_RELEASE=
########################################################
# To mark SVN snapshots this should be set to 'yes' #
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 2a8e09a..c5859b8 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,18 +1,17 @@
-Release Announcements
-=====================
+ =============================
+ Release Notes for Samba 4.3.0
+ September 8, 2015
+ =============================
-This is the fourth release candidate of Samba 4.3. This is *not*
-intended for production environments and is designed for testing
-purposes only. Please report any defects via the Samba bug reporting
-system at https://bugzilla.samba.org/.
-Samba 4.3 will be the next version of the Samba suite.
+This is the first stable release of Samba 4.3.
UPGRADING
=========
-Nothing special.
+Read the "New FileChangeNotify subsystem" and "smb.conf changes" sections
+(below).
NEW FEATURES
@@ -297,6 +296,30 @@ KNOWN ISSUES
Currently none.
+CHANGES SINCE 4.2.0rc4
+======================
+
+o Andrew Bartlett <abartlet at samba.org>
+ * Bug 10973: No objectClass found in replPropertyMetaData on ordinary
+ objects (non-deleted)
+ * Bug 11429: Python bindings don't check integer types
+ * Bug 11430: Python bindings don't check array sizes
+
+o Ralph Boehme <slow at samba.org>
+ * Bug 11467: Handling of 0 byte resource fork stream
+
+o Volker Lendecke <vl at samba.org>
+ * Bug 11488: AD samr GetGroupsForUser fails for users with "()" in
+ their name
+
+o Stefan Metzmacher <metze at samba.org>
+ * Bug 11429: Python bindings don't check integer types
+
+o Matthieu Patou <mat at matws.net>
+ * Bug 10973: No objectClass found in replPropertyMetaData on ordinary
+ objects (non-deleted)
+
+
CHANGES SINCE 4.2.0rc3
======================
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index ff68e7a..180b6b2 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -10,7 +10,7 @@ use Exporter;
use strict;
use Parse::Pidl qw(warning fatal error);
-use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias);
+use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias bitmap_type_fn enum_type_fn);
use Parse::Pidl::Util qw(has_property ParseExpr unmake_str);
use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe is_charset_array);
use Parse::Pidl::CUtil qw(get_value_of get_pointer_to);
@@ -953,14 +953,58 @@ sub ConvertObjectFromPythonData($$$$$$;$)
$actual_ctype = $actual_ctype->{DATA};
}
- if ($actual_ctype->{TYPE} eq "ENUM" or $actual_ctype->{TYPE} eq "BITMAP") {
+ # We need to cover ENUMs, BITMAPS and SCALAR values here, as
+ # all could otherwise be assigned invalid integer values
+ my $ctype_alias = "";
+ my $uint_max = "";
+ if ($actual_ctype->{TYPE} eq "ENUM") {
+ # Importantly, ENUM values are unsigned in pidl, and
+ # typically map to uint32
+ $ctype_alias = enum_type_fn($actual_ctype);
+ } elsif ($actual_ctype->{TYPE} eq "BITMAP") {
+ $ctype_alias = bitmap_type_fn($actual_ctype);
+ } elsif ($actual_ctype->{TYPE} eq "SCALAR") {
+ $ctype_alias = expandAlias($actual_ctype->{NAME});
+ }
+
+ # This is the unsigned Python Integer -> C integer validation
+ # case. The signed case is below.
+ if ($ctype_alias =~ /^(uint[0-9]*|hyper|udlong|udlongr
+ |NTTIME_hyper|NTTIME|NTTIME_1sec
+ |uid_t|gid_t)$/x) {
+ $self->pidl("{");
+ $self->indent;
+ $self->pidl("const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof($target));");
$self->pidl("if (PyLong_Check($cvar)) {");
$self->indent;
- $self->pidl("$target = PyLong_AsLongLong($cvar);");
+ $self->pidl("unsigned long long test_var;");
+ $self->pidl("test_var = PyLong_AsUnsignedLongLong($cvar);");
+ $self->pidl("if (PyErr_Occurred() != NULL) {");
+ $self->indent;
+ $self->pidl($fail);
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("if (test_var > uint_max) {");
+ $self->indent;
+ $self->pidl("PyErr_Format(PyExc_OverflowError, \"Expected type %s or %s within range 0 - %llu, got %llu\",\\");
+ $self->pidl(" PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);");
+ $self->pidl($fail);
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("$target = test_var;");
$self->deindent;
$self->pidl("} else if (PyInt_Check($cvar)) {");
$self->indent;
- $self->pidl("$target = PyInt_AsLong($cvar);");
+ $self->pidl("long test_var;");
+ $self->pidl("test_var = PyInt_AsLong($cvar);");
+ $self->pidl("if (test_var < 0 || test_var > uint_max) {");
+ $self->indent;
+ $self->pidl("PyErr_Format(PyExc_OverflowError, \"Expected type %s or %s within range 0 - %llu, got %ld\",\\");
+ $self->pidl(" PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);");
+ $self->pidl($fail);
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("$target = test_var;");
$self->deindent;
$self->pidl("} else {");
$self->indent;
@@ -969,34 +1013,61 @@ sub ConvertObjectFromPythonData($$$$$$;$)
$self->pidl($fail);
$self->deindent;
$self->pidl("}");
+ $self->deindent;
+ $self->pidl("}");
return;
}
- if ($actual_ctype->{TYPE} eq "SCALAR" ) {
- if (expandAlias($actual_ctype->{NAME}) =~ /^(u?int64|hyper|dlong|udlong|udlongr
- |NTTIME_hyper|NTTIME|NTTIME_1sec
- |uid_t|gid_t)$/x) {
- $self->pidl("if (PyLong_Check($cvar)) {");
- $self->indent;
- $self->pidl("$target = PyLong_AsLongLong($cvar);");
- $self->deindent;
- $self->pidl("} else if (PyInt_Check($cvar)) {");
- $self->indent;
- $self->pidl("$target = PyInt_AsLong($cvar);");
- $self->deindent;
- $self->pidl("} else {");
- $self->indent;
- $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected type %s or %s\",\\");
- $self->pidl(" PyInt_Type.tp_name, PyLong_Type.tp_name);");
- $self->pidl($fail);
- $self->deindent;
- $self->pidl("}");
- return;
- }
- if (expandAlias($actual_ctype->{NAME}) =~ /^(char|u?int[0-9]*|time_t)$/) {
- $self->pidl("PY_CHECK_TYPE(&PyInt_Type, $cvar, $fail);");
- $self->pidl("$target = PyInt_AsLong($cvar);");
- return;
- }
+
+ # Confirm the signed python integer fits in the C type
+ # correctly. It is subtly different from the unsigned case
+ # above, so while it looks like a duplicate, it is not
+ # actually a duplicate.
+ if ($ctype_alias =~ /^(dlong|char|int[0-9]*|time_t)$/x) {
+ $self->pidl("{");
+ $self->indent;
+ $self->pidl("const long long int_max = ndr_sizeof2intmax(sizeof($target));");
+ $self->pidl("const long long int_min = -int_max - 1;");
+ $self->pidl("if (PyLong_Check($cvar)) {");
+ $self->indent;
+ $self->pidl("long long test_var;");
+ $self->pidl("test_var = PyLong_AsLongLong($cvar);");
+ $self->pidl("if (PyErr_Occurred() != NULL) {");
+ $self->indent;
+ $self->pidl($fail);
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("if (test_var < int_min || test_var > int_max) {");
+ $self->indent;
+ $self->pidl("PyErr_Format(PyExc_OverflowError, \"Expected type %s or %s within range %lld - %lld, got %lld\",\\");
+ $self->pidl(" PyInt_Type.tp_name, PyLong_Type.tp_name, int_min, int_max, test_var);");
+ $self->pidl($fail);
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("$target = test_var;");
+ $self->deindent;
+ $self->pidl("} else if (PyInt_Check($cvar)) {");
+ $self->indent;
+ $self->pidl("long test_var;");
+ $self->pidl("test_var = PyInt_AsLong($cvar);");
+ $self->pidl("if (test_var < int_min || test_var > int_max) {");
+ $self->indent;
+ $self->pidl("PyErr_Format(PyExc_OverflowError, \"Expected type %s or %s within range %lld - %lld, got %ld\",\\");
+ $self->pidl(" PyInt_Type.tp_name, PyLong_Type.tp_name, int_min, int_max, test_var);");
+ $self->pidl($fail);
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("$target = test_var;");
+ $self->deindent;
+ $self->pidl("} else {");
+ $self->indent;
+ $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected type %s or %s\",\\");
+ $self->pidl(" PyInt_Type.tp_name, PyLong_Type.tp_name);");
+ $self->pidl($fail);
+ $self->deindent;
+ $self->pidl("}");
+ $self->deindent;
+ $self->pidl("}");
+ return;
}
if ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") {
@@ -1152,6 +1223,13 @@ sub ConvertObjectFromPythonLevel($$$$$$$$)
$self->pidl("$var_name = talloc_array_ptrtype($mem_ctx, $var_name, PyList_GET_SIZE($py_var));");
$self->pidl("if (!$var_name) { $fail; }");
$self->pidl("talloc_set_name_const($var_name, \"ARRAY: $var_name\");");
+ } else {
+ $self->pidl("if (ARRAY_SIZE($var_name) != PyList_GET_SIZE($py_var)) {");
+ $self->indent;
+ $self->pidl("PyErr_Format(PyExc_TypeError, \"Expected list of type %s, length %zu, got %zd\", Py_TYPE($py_var)->tp_name, ARRAY_SIZE($var_name), PyList_GET_SIZE($py_var));");
+ $self->pidl("$fail");
+ $self->deindent;
+ $self->pidl("}");
}
$self->pidl("for ($counter = 0; $counter < PyList_GET_SIZE($py_var); $counter++) {");
$self->indent;
@@ -1202,17 +1280,29 @@ sub ConvertScalarToPython($$$)
$ctypename = expandAlias($ctypename);
if ($ctypename =~ /^(int64|dlong)$/) {
- return "PyLong_FromLongLong($cvar)";
+ return "ndr_PyLong_FromLongLong($cvar)";
}
- if ($ctypename =~ /^(uint64|hyper|udlong|udlongr|NTTIME_hyper|NTTIME|NTTIME_1sec|uid_t|gid_t)$/) {
- return "PyLong_FromUnsignedLongLong($cvar)";
+ if ($ctypename =~ /^(uint64|hyper|NTTIME_hyper|NTTIME|NTTIME_1sec|udlong|udlongr|uid_t|gid_t)$/) {
+ return "ndr_PyLong_FromUnsignedLongLong($cvar)";
}
- if ($ctypename =~ /^(char|u?int[0-9]*|time_t)$/) {
+ if ($ctypename =~ /^(char|int|int8|int16|int32|time_t)$/) {
return "PyInt_FromLong($cvar)";
}
+ # Needed to ensure unsigned values in a 32 or 16 bit enum is
+ # cast correctly to a uint32_t, not sign extended to a a
+ # possibly 64 bit unsigned long. (enums are signed in C,
+ # unsigned in NDR)
+ if ($ctypename =~ /^(uint32|uint3264)$/) {
+ return "ndr_PyLong_FromUnsignedLongLong((uint32_t)$cvar)";
+ }
+
+ if ($ctypename =~ /^(uint|uint8|uint16|uint1632)$/) {
+ return "PyInt_FromLong((uint16_t)$cvar)";
+ }
+
if ($ctypename eq "DATA_BLOB") {
return "PyString_FromStringAndSize((char *)($cvar).data, ($cvar).length)";
}
@@ -1408,6 +1498,61 @@ sub Parse($$$$$)
#include \"$hdr\"
#include \"$ndr_hdr\"
+/*
+ * These functions are here to ensure they can be optomised out by
+ * the compiler based on the constant input values
+ */
+
+static inline unsigned long long ndr_sizeof2uintmax(size_t var_size)
+{
+ switch (var_size) {
+ case 8:
+ return UINT64_MAX;
+ case 4:
+ return UINT32_MAX;
+ case 2:
+ return UINT16_MAX;
+ case 1:
+ return UINT8_MAX;
+ }
+
+ return 0;
+}
+
+static inline long long ndr_sizeof2intmax(size_t var_size)
+{
+ switch (var_size) {
+ case 8:
+ return INT64_MAX;
+ case 4:
+ return INT32_MAX;
+ case 2:
+ return INT16_MAX;
+ case 1:
+ return INT8_MAX;
+ }
+
+ return 0;
+}
+
+static inline PyObject *ndr_PyLong_FromLongLong(long long v)
+{
+ if (v > LONG_MAX || v < LONG_MIN) {
+ return PyLong_FromLongLong(v);
+ } else {
+ return PyInt_FromLong(v);
+ }
+}
+
+static inline PyObject *ndr_PyLong_FromUnsignedLongLong(unsigned long long v)
+{
+ if (v > LONG_MAX) {
+ return PyLong_FromUnsignedLongLong(v);
+ } else {
+ return PyInt_FromLong(v);
+ }
+}
+
");
foreach my $x (@$ndr) {
@@ -1487,7 +1632,7 @@ sub Parse($$$$$)
my $py_obj;
my ($ctype, $cvar) = @{$h->{'val'}};
if ($cvar =~ /^[0-9]+$/ or $cvar =~ /^0x[0-9a-fA-F]+$/) {
- $py_obj = "PyInt_FromLong($cvar)";
+ $py_obj = "ndr_PyLong_FromUnsignedLongLong($cvar)";
} elsif ($cvar =~ /^".*"$/) {
$py_obj = "PyString_FromString($cvar)";
} else {
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
index 74e9678..4fb9d12 100644
--- a/python/samba/dbchecker.py
+++ b/python/samba/dbchecker.py
@@ -24,6 +24,7 @@ from base64 import b64decode
from samba import dsdb
from samba import common
from samba.dcerpc import misc
+from samba.dcerpc import drsuapi
from samba.ndr import ndr_unpack, ndr_pack
from samba.dcerpc import drsblobs
from samba.common import dsdb_Dn
@@ -63,6 +64,7 @@ class dbcheck(object):
self.move_to_lost_and_found = False
self.fix_instancetype = False
self.fix_replmetadata_zero_invocationid = False
+ self.fix_replmetadata_unsorted_attid = False
self.fix_deleted_deleted_objects = False
self.fix_dn = False
self.fix_base64_userparameters = False
@@ -80,6 +82,8 @@ class dbcheck(object):
self.wellknown_sds = get_wellknown_sds(self.samdb)
self.fix_all_missing_objectclass = False
+ self.dn_set = set()
+
self.name_map = {}
try:
res = samdb.search(base="CN=DnsAdmins,CN=Users,%s" % samdb.domain_dn(), scope=ldb.SCOPE_BASE,
@@ -125,12 +129,12 @@ class dbcheck(object):
def check_database(self, DN=None, scope=ldb.SCOPE_SUBTREE, controls=[], attrs=['*']):
'''perform a database check, returning the number of errors found'''
-
res = self.samdb.search(base=DN, scope=scope, attrs=['dn'], controls=controls)
self.report('Checking %u objects' % len(res))
error_count = 0
for object in res:
+ self.dn_set.add(str(object.dn))
error_count += self.check_object(object.dn, attrs=attrs)
if DN is None:
@@ -698,18 +702,21 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
return 0
def process_metadata(self, val):
- '''Read metadata properties and list attributes in it'''
+ '''Read metadata properties and list attributes in it.
+ raises KeyError if the attid is unknown.'''
- list_att = []
+ set_att = set()
+ list_attid = []
repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob, str(val))
obj = repl.ctr
for o in repl.ctr.array:
att = self.samdb_schema.get_lDAPDisplayName_by_attid(o.attid)
- list_att.append(att.lower())
+ set_att.add(att.lower())
+ list_attid.append(o.attid)
- return list_att
+ return (set_att, list_attid)
def fix_metadata(self, dn, attr):
@@ -989,11 +996,52 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
nmsg = ldb.Message()
nmsg.dn = dn
nmsg[attr] = ldb.MessageElement(replBlob, ldb.FLAG_MOD_REPLACE, attr)
- if self.do_modify(nmsg, ["local_oid:1.3.6.1.4.1.7165.4.3.14:0"],
+ if self.do_modify(nmsg, ["local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK_MODIFY_RO_REPLICA,
+ "local_oid:1.3.6.1.4.1.7165.4.3.14:0"],
"Failed to fix attribute %s" % attr):
self.report("Fixed attribute '%s' of '%s'\n" % (attr, dn))
+ def err_replmetadata_unknown_attid(self, dn, attr, repl_meta_data):
+ repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob,
+ str(repl_meta_data))
+ ctr = repl.ctr
+ for o in ctr.array:
+ # Search for an invalid attid
+ try:
+ att = self.samdb_schema.get_lDAPDisplayName_by_attid(o.attid)
+ except KeyError:
+ self.report('ERROR: attributeID 0X%0X is not known in our schema, not fixing %s on %s\n' % (o.attid, attr, dn))
+ return
+
+
+ def err_replmetadata_unsorted_attid(self, dn, attr, repl_meta_data):
+ repl = ndr_unpack(drsblobs.replPropertyMetaDataBlob,
+ str(repl_meta_data))
+ ctr = repl.ctr
+ found = False
+
+ self.report('ERROR: unsorted attributeID values in %s on %s\n' % (attr, dn))
+ if not self.confirm_all('Fix %s on %s by sorting the attribute list?'
+ % (attr, dn), 'fix_replmetadata_unsorted_attid'):
+ self.report('Not fixing %s on %s\n' % (attr, dn))
+ return
+
+ # Sort the array, except for the last element
+ ctr.array[:-1] = sorted(ctr.array[:-1], key=lambda o: o.attid)
+
+ replBlob = ndr_pack(repl)
+
+ nmsg = ldb.Message()
+ nmsg.dn = dn
+ nmsg[attr] = ldb.MessageElement(replBlob, ldb.FLAG_MOD_REPLACE, attr)
+ if self.do_modify(nmsg, ["local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK_MODIFY_RO_REPLICA,
+ "local_oid:1.3.6.1.4.1.7165.4.3.14:0",
+ "local_oid:1.3.6.1.4.1.7165.4.3.25:0"],
+ "Failed to fix attribute %s" % attr):
+ self.report("Fixed attribute '%s' of '%s'\n" % (attr, dn))
+
+
def is_deleted_deleted_objects(self, obj):
faulty = False
if "description" not in obj:
@@ -1125,8 +1173,8 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
return 1
obj = res[0]
error_count = 0
- list_attrs_from_md = []
- list_attrs_seen = []
+ set_attrs_from_md = set()
+ set_attrs_seen = set()
got_repl_property_meta_data = False
got_objectclass = False
@@ -1181,7 +1229,31 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
# We don't continue, as we may also have other fixes for this attribute
# based on what other attributes we see.
- list_attrs_from_md = self.process_metadata(obj[attrname])
+ try:
+ (set_attrs_from_md, list_attid_from_md) = self.process_metadata(obj[attrname])
+ except KeyError:
+ error_count += 1
+ self.err_replmetadata_unknown_attid(dn, attrname, obj[attrname])
--
Samba Shared Repository
More information about the samba-cvs
mailing list