Discussion:
[SCM] Samba Shared Repository - branch v4-8-test updated
Stefan Metzmacher
2018-05-02 16:57:02 UTC
Permalink
The branch, v4-8-test has been updated
via 13f23ec nsswitch: fix memory leak in winbind_open_pipe_sock() when the privileged pipe is not accessable.
via bf0a664 ldb: Release ldb 1.3.3
via 21e10ff ldb: Add test to show a reindex failure must not leave the DB corrupt
via 89ce0d9 lib ldb tests: Prepare to run api and index test on tdb and lmdb
via 7f70fcd ldb_tdb: Ensure we can not commit an index that is corrupt due to partial re-index
via 3f15f1c ldb_tdb: Add tests for truncated index keys
via b1ac094 ldb_tdb: Do not fail in GUID index mode if there is a duplicate attribute
from f1bf8d7 VERSION: Bump version up to 4.8.2...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-8-test


- Log -----------------------------------------------------------------
commit 13f23ec11ef3c932b0cb2000613dfbc6dd14554b
Author: Stefan Metzmacher <***@samba.org>
Date: Tue Apr 24 10:59:05 2018 +0200

nsswitch: fix memory leak in winbind_open_pipe_sock() when the privileged pipe is not accessable.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13400

Signed-off-by: Stefan Metzmacher <***@samba.org>
Reviewed-by: Volker Lendecke <***@samba.org>
(cherry picked from commit ffe970007bf934955f72ec2d73bf8f94a2b796eb)

Autobuild-User(v4-8-test): Stefan Metzmacher <***@samba.org>
Autobuild-Date(v4-8-test): Wed May 2 18:56:45 CEST 2018 on sn-devel-144

commit bf0a6646108bd447c05f099a7f345cf2a3bda070
Author: Andrew Bartlett <***@samba.org>
Date: Mon Apr 30 11:15:55 2018 +1200

ldb: Release ldb 1.3.3

* Fix failure to upgrade to the GUID index DB format
* Add tests for GUID index behaviour

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13306

Signed-off-by: Andrew Bartlett <***@samba.org>
Reviewed-by: Stefan Metzmacher <***@samba.org>

commit 21e10ff3d46814c170ed9b35e341f3c6a72406ef
Author: Andrew Bartlett <***@samba.org>
Date: Mon Mar 26 16:07:45 2018 +1300

ldb: Add test to show a reindex failure must not leave the DB corrupt

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13335

Signed-off-by: Andrew Bartlett <***@samba.org>
Reviewed-by: Gary Lockyer <***@catalyst.net.nz>

Autobuild-User(master): Andrew Bartlett <***@samba.org>
Autobuild-Date(master): Thu Apr 5 07:53:10 CEST 2018 on sn-devel-144

(cherry picked from commit 653a0a1ba932fc0cc567253f3e153b2928505ba2)

commit 89ce0d90f70140b28a3cf6fa15e4fc6e803b5495
Author: Gary Lockyer <***@catalyst.net.nz>
Date: Tue Mar 6 09:13:31 2018 +1300

lib ldb tests: Prepare to run api and index test on tdb and lmdb

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13335

Signed-off-by: Gary Lockyer <***@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <***@samba.org>
(cherry picked from commit 06d9566ef7005588de18c5a1d07a5b9cd179d17b)

commit 7f70fcd8baa82ae13ce1a29fc493643bbe29c6b7
Author: Andrew Bartlett <***@samba.org>
Date: Mon Mar 26 16:01:13 2018 +1300

ldb_tdb: Ensure we can not commit an index that is corrupt due to partial re-index

The re-index traverse can abort part-way though and we need to ensure
that the transaction is never committed as that will leave an un-useable db.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13335

Signed-off-by: Andrew Bartlett <***@samba.org>
Reviewed-by: Gary Lockyer <***@catalyst.net.nz>
(cherry picked from commit e481e4f30f4dc540f6f129b4f2faea48ee195673)

commit 3f15f1c63b994066e4ea9bc5e407c1d182511918
Author: Gary Lockyer <***@catalyst.net.nz>
Date: Wed Feb 21 15:12:40 2018 +1300

ldb_tdb: Add tests for truncated index keys

Tests for the index truncation code as well as the GUID index
format in general.

Covers truncation of both the DN and equality search keys.

Signed-off-by: Gary Lockyer <***@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <***@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <***@samba.org>

Autobuild-User(master): Andrew Bartlett <***@samba.org>
Autobuild-Date(master): Sat Mar 3 09:58:40 CET 2018 on sn-devel-144

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13335

(cherry picked into 4.8 and cut down to operate without truncated
index values from master commit 4c0c888b571d4c21ab267024178353925a8c087c
by Andrew Bartlett)

commit b1ac0944146705ed13a89b0d0ac1b4656641c170
Author: Gary Lockyer <***@catalyst.net.nz>
Date: Wed Feb 28 11:47:22 2018 +1300

ldb_tdb: Do not fail in GUID index mode if there is a duplicate attribute

It is not the job of the index code to enforce this, but do give a
a warning given it has been detected.

However, now that we do allow it, we must never return the same
object twice to the caller, so filter for it in ltdb_index_filter().

The GUID list is sorted, which makes this cheap to handle, thankfully.

Signed-off-by: Gary Lockyer <***@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <***@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <***@samba.org>

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13335

(cherry picked from commit 5c1504b94d1417894176811f18c5d450de22cfd2)

-----------------------------------------------------------------------

Summary of changes:
lib/ldb/ABI/{ldb-1.3.2.sigs => ldb-1.3.3.sigs} | 0
...b-util.py3-1.3.2.sigs => pyldb-util-1.3.3.sigs} | 0
...il.py3-1.3.2.sigs => pyldb-util.py3-1.3.3.sigs} | 0
lib/ldb/ldb_tdb/ldb_index.c | 64 +-
lib/ldb/ldb_tdb/ldb_tdb.c | 30 +
lib/ldb/ldb_tdb/ldb_tdb.h | 2 +
lib/ldb/tests/python/api.py | 303 ++++--
lib/ldb/tests/python/index.py | 1032 ++++++++++++++++++++
lib/ldb/wscript | 4 +-
nsswitch/wb_common.c | 4 +-
10 files changed, 1371 insertions(+), 68 deletions(-)
copy lib/ldb/ABI/{ldb-1.3.2.sigs => ldb-1.3.3.sigs} (100%)
copy lib/ldb/ABI/{pyldb-util.py3-1.3.2.sigs => pyldb-util-1.3.3.sigs} (100%)
copy lib/ldb/ABI/{pyldb-util.py3-1.3.2.sigs => pyldb-util.py3-1.3.3.sigs} (100%)
create mode 100755 lib/ldb/tests/python/index.py


Changeset truncated at 500 lines:

diff --git a/lib/ldb/ABI/ldb-1.3.2.sigs b/lib/ldb/ABI/ldb-1.3.3.sigs
similarity index 100%
copy from lib/ldb/ABI/ldb-1.3.2.sigs
copy to lib/ldb/ABI/ldb-1.3.3.sigs
diff --git a/lib/ldb/ABI/pyldb-util.py3-1.3.2.sigs b/lib/ldb/ABI/pyldb-util-1.3.3.sigs
similarity index 100%
copy from lib/ldb/ABI/pyldb-util.py3-1.3.2.sigs
copy to lib/ldb/ABI/pyldb-util-1.3.3.sigs
diff --git a/lib/ldb/ABI/pyldb-util.py3-1.3.2.sigs b/lib/ldb/ABI/pyldb-util.py3-1.3.3.sigs
similarity index 100%
copy from lib/ldb/ABI/pyldb-util.py3-1.3.2.sigs
copy to lib/ldb/ABI/pyldb-util.py3-1.3.3.sigs
diff --git a/lib/ldb/ldb_tdb/ldb_index.c b/lib/ldb/ldb_tdb/ldb_index.c
index 99fef23..ee20273 100644
--- a/lib/ldb/ldb_tdb/ldb_index.c
+++ b/lib/ldb/ldb_tdb/ldb_index.c
@@ -1526,6 +1526,7 @@ static int ltdb_index_filter(struct ltdb_private *ltdb,
struct ldb_message *msg;
struct ldb_message *filtered_msg;
unsigned int i;
+ uint8_t previous_guid_key[LTDB_GUID_KEY_SIZE] = {};

ldb = ldb_module_get_ctx(ac->module);

@@ -1538,11 +1539,6 @@ static int ltdb_index_filter(struct ltdb_private *ltdb,
int ret;
bool matched;

- msg = ldb_msg_new(ac);
- if (!msg) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
ret = ltdb_idx_to_key(ac->module, ltdb,
ac, &dn_list->dn[i],
&tdb_key);
@@ -1550,6 +1546,33 @@ static int ltdb_index_filter(struct ltdb_private *ltdb,
return ret;
}

+ if (ltdb->cache->GUID_index_attribute != NULL) {
+ /*
+ * If we are in GUID index mode, then the dn_list is
+ * sorted. If we got a duplicate, forget about it, as
+ * otherwise we would send the same entry back more
+ * than once.
+ *
+ * This is needed in the truncated DN case, or if a
+ * duplicate was forced in via
+ * LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK
+ */
+
+ if (memcmp(previous_guid_key, tdb_key.dptr,
+ sizeof(previous_guid_key)) == 0) {
+ continue;
+ }
+
+ memcpy(previous_guid_key, tdb_key.dptr,
+ sizeof(previous_guid_key));
+ }
+
+ msg = ldb_msg_new(ac);
+ if (!msg) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+
ret = ltdb_search_key(ac->module, ltdb,
tdb_key, msg,
LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC|
@@ -1923,9 +1946,36 @@ static int ltdb_index_add1(struct ldb_module *module,
BINARY_ARRAY_SEARCH_GTE(list->dn, list->count,
*key_val, ldb_val_equal_exact_ordered,
exact, next);
+
+ /*
+ * Give a warning rather than fail, this could be a
+ * duplicate value in the record allowed by a caller
+ * forcing in the value with
+ * LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK
+ */
if (exact != NULL) {
- talloc_free(list);
- return LDB_ERR_OPERATIONS_ERROR;
+ /* This can't fail, gives a default at worst */
+ const struct ldb_schema_attribute *attr
+ = ldb_schema_attribute_by_name(
+ ldb,
+ ltdb->cache->GUID_index_attribute);
+ struct ldb_val v;
+ ret = attr->syntax->ldif_write_fn(ldb, list,
+ exact, &v);
+ if (ret == LDB_SUCCESS) {
+ ldb_debug(ldb, LDB_DEBUG_WARNING,
+ __location__
+ ": duplicate attribute value in %s "
+ "for index on %s, "
+ "duplicate of %s %*.*s in %s",
+ ldb_dn_get_linearized(msg->dn),
+ el->name,
+ ltdb->cache->GUID_index_attribute,
+ (int)v.length,
+ (int)v.length,
+ v.data,
+ ldb_dn_get_linearized(dn_key));
+ }
}

if (next == NULL) {
diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c
index 16e4b8e..a530a45 100644
--- a/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -410,6 +410,10 @@ static int ltdb_modified(struct ldb_module *module, struct ldb_dn *dn)
ret = ltdb_cache_reload(module);
}

+ if (ret != LDB_SUCCESS) {
+ ltdb->reindex_failed = true;
+ }
+
return ret;
}

@@ -1404,9 +1408,17 @@ static int ltdb_start_trans(struct ldb_module *module)

ltdb_index_transaction_start(module);

+ ltdb->reindex_failed = false;
+
return LDB_SUCCESS;
}

+/*
+ * Forward declaration to allow prepare_commit to in fact abort the
+ * transaction
+ */
+static int ltdb_del_trans(struct ldb_module *module);
+
static int ltdb_prepare_commit(struct ldb_module *module)
{
int ret;
@@ -1417,6 +1429,24 @@ static int ltdb_prepare_commit(struct ldb_module *module)
return LDB_SUCCESS;
}

+ /*
+ * Check if the last re-index failed.
+ *
+ * This can happen if for example a duplicate value was marked
+ * unique. We must not write a partial re-index into the DB.
+ */
+ if (ltdb->reindex_failed) {
+ /*
+ * We must instead abort the transaction so we get the
+ * old values and old index back
+ */
+ ltdb_del_trans(module);
+ ldb_set_errstring(ldb_module_get_ctx(module),
+ "Failure during re-index, so "
+ "transaction must be aborted.");
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
ret = ltdb_index_transaction_commit(module);
if (ret != LDB_SUCCESS) {
tdb_transaction_cancel(ltdb->tdb);
diff --git a/lib/ldb/ldb_tdb/ldb_tdb.h b/lib/ldb/ldb_tdb/ldb_tdb.h
index 7e18249..9591ee5 100644
--- a/lib/ldb/ldb_tdb/ldb_tdb.h
+++ b/lib/ldb/ldb_tdb/ldb_tdb.h
@@ -37,6 +37,8 @@ struct ltdb_private {

bool read_only;

+ bool reindex_failed;
+
const struct ldb_schema_syntax *GUID_index_syntax;
};

diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py
index 409f446..1167517 100755
--- a/lib/ldb/tests/python/api.py
+++ b/lib/ldb/tests/python/api.py
@@ -12,6 +12,9 @@ import shutil

PY3 = sys.version_info > (3, 0)

+TDB_PREFIX = "tdb://"
+MDB_PREFIX = "mdb://"
+

def tempdir():
import tempfile
@@ -44,13 +47,36 @@ class NoContextTests(TestCase):
encoded2 = ldb.binary_encode('test\\x')
self.assertEqual(encoded2, encoded)

-class SimpleLdb(TestCase):
+
+class LdbBaseTest(TestCase):
+ def setUp(self):
+ super(LdbBaseTest, self).setUp()
+ try:
+ if self.prefix is None:
+ self.prefix = TDB_PREFIX
+ except AttributeError:
+ self.prefix = TDB_PREFIX
+
+ def tearDown(self):
+ super(LdbBaseTest, self).tearDown()
+
+ def url(self):
+ return self.prefix + self.filename
+
+ def flags(self):
+ if self.prefix == MDB_PREFIX:
+ return ldb.FLG_NOSYNC
+ else:
+ return 0
+
+
+class SimpleLdb(LdbBaseTest):

def setUp(self):
super(SimpleLdb, self).setUp()
self.testdir = tempdir()
self.filename = os.path.join(self.testdir, "test.ldb")
- self.ldb = ldb.Ldb(self.filename)
+ self.ldb = ldb.Ldb(self.url(), flags=self.flags())

def tearDown(self):
shutil.rmtree(self.testdir)
@@ -58,16 +84,15 @@ class SimpleLdb(TestCase):
# Ensure the LDB is closed now, so we close the FD
del(self.ldb)

-
def test_connect(self):
- ldb.Ldb(self.filename)
+ ldb.Ldb(self.url(), flags=self.flags())

def test_connect_none(self):
ldb.Ldb()

def test_connect_later(self):
x = ldb.Ldb()
- x.connect(self.filename)
+ x.connect(self.url(), flags=self.flags())

def test_repr(self):
x = ldb.Ldb()
@@ -82,7 +107,7 @@ class SimpleLdb(TestCase):
self.assertEqual([], x.modules())

def test_modules_tdb(self):
- x = ldb.Ldb(self.filename)
+ x = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual("[<ldb module 'tdb'>]", repr(x.modules()))

def test_firstmodule_none(self):
@@ -90,53 +115,53 @@ class SimpleLdb(TestCase):
self.assertEqual(x.firstmodule, None)

def test_firstmodule_tdb(self):
- x = ldb.Ldb(self.filename)
+ x = ldb.Ldb(self.url(), flags=self.flags())
mod = x.firstmodule
self.assertEqual(repr(mod), "<ldb module 'tdb'>")

def test_search(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(len(l.search()), 0)

def test_search_controls(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(len(l.search(controls=["paged_results:0:5"])), 0)

def test_search_attrs(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(len(l.search(ldb.Dn(l, ""), ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0)

def test_search_string_dn(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(len(l.search("", ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0)

def test_search_attr_string(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertRaises(TypeError, l.search, attrs="dc")
self.assertRaises(TypeError, l.search, attrs=b"dc")

def test_opaque(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
l.set_opaque("my_opaque", l)
self.assertTrue(l.get_opaque("my_opaque") is not None)
self.assertEqual(None, l.get_opaque("unknown"))

def test_search_scope_base_empty_db(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(len(l.search(ldb.Dn(l, "dc=foo1"),
ldb.SCOPE_BASE)), 0)

def test_search_scope_onelevel_empty_db(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(len(l.search(ldb.Dn(l, "dc=foo1"),
ldb.SCOPE_ONELEVEL)), 0)

def test_delete(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertRaises(ldb.LdbError, lambda: l.delete(ldb.Dn(l, "dc=foo2")))

def test_delete_w_unhandled_ctrl(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=foo1")
m["b"] = [b"a"]
@@ -145,10 +170,10 @@ class SimpleLdb(TestCase):
l.delete(m.dn)

def test_contains(self):
- name = self.filename
- l = ldb.Ldb(name)
+ name = self.url()
+ l = ldb.Ldb(name, flags=self.flags())
self.assertFalse(ldb.Dn(l, "dc=foo3") in l)
- l = ldb.Ldb(name)
+ l = ldb.Ldb(name, flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=foo3")
m["b"] = ["a"]
@@ -160,23 +185,23 @@ class SimpleLdb(TestCase):
l.delete(m.dn)

def test_get_config_basedn(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(None, l.get_config_basedn())

def test_get_root_basedn(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(None, l.get_root_basedn())

def test_get_schema_basedn(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(None, l.get_schema_basedn())

def test_get_default_basedn(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(None, l.get_default_basedn())

def test_add(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=foo4")
m["bla"] = b"bla"
@@ -188,7 +213,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=foo4"))

def test_search_iterator(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
s = l.search_iterator()
s.abandon()
try:
@@ -288,7 +313,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=foo5"))

def test_add_text(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=foo4")
m["bla"] = "bla"
@@ -300,7 +325,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=foo4"))

def test_add_w_unhandled_ctrl(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=foo4")
m["bla"] = b"bla"
@@ -308,7 +333,7 @@ class SimpleLdb(TestCase):
self.assertRaises(ldb.LdbError, lambda: l.add(m,["search_options:1:2"]))

def test_add_dict(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = {"dn": ldb.Dn(l, "dc=foo5"),
"bla": b"bla"}
self.assertEqual(len(l.search()), 0)
@@ -319,7 +344,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=foo5"))

def test_add_dict_text(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = {"dn": ldb.Dn(l, "dc=foo5"),
"bla": "bla"}
self.assertEqual(len(l.search()), 0)
@@ -330,7 +355,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=foo5"))

def test_add_dict_string_dn(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = {"dn": "dc=foo6", "bla": b"bla"}
self.assertEqual(len(l.search()), 0)
l.add(m)
@@ -340,7 +365,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=foo6"))

def test_add_dict_bytes_dn(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = {"dn": b"dc=foo6", "bla": b"bla"}
self.assertEqual(len(l.search()), 0)
l.add(m)
@@ -350,7 +375,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=foo6"))

def test_rename(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=foo7")
m["bla"] = b"bla"
@@ -363,7 +388,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=bar"))

def test_rename_string_dns(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=foo8")
m["bla"] = b"bla"
@@ -377,7 +402,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=bar"))

def test_empty_dn(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
self.assertEqual(0, len(l.search()))
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=empty")
@@ -394,7 +419,7 @@ class SimpleLdb(TestCase):
self.assertEqual(0, len(rm[0]))

def test_modify_delete(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=modifydelete")
m["bla"] = [b"1234"]
@@ -417,7 +442,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=modifydelete"))

def test_modify_delete_text(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=modifydelete")
m.text["bla"] = ["1234"]
@@ -440,7 +465,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=modifydelete"))

def test_modify_add(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=add")
m["bla"] = [b"1234"]
@@ -458,7 +483,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=add"))

def test_modify_add_text(self):
- l = ldb.Ldb(self.filename)
+ l = ldb.Ldb(self.url(), flags=self.flags())
m = ldb.Message()
m.dn = ldb.Dn(l, "dc=add")
m.text["bla"] = ["1234"]
@@ -476,7 +501,7 @@ class SimpleLdb(TestCase):
l.delete(ldb.Dn(l, "dc=add"))

def test_modify_replace(self):
- l = ldb.Ldb(self.filename)
--
Samba Shared Repository
Karolin Seeger
2018-05-07 12:26:02 UTC
Permalink
The branch, v4-8-test has been updated
via 02b898e s3: libsmbclient: Fix hard-coded connection error return of ETIMEDOUT.
via dc7b7be s3:cleanupd: use MSG_SMB_BRL_VALIDATE to signal cleanupd unclean process shutdown
via 0ccfe32 ceph: VFS: Add asynchronous fsync to ceph module, fake using synchronous call.
via bde6633 ctdb-client: Remove ununsed functions from old client code
via 7cfaf700 rpc_server: Fix NetSessEnum with stale sessions
via 2fcd26a selftest: Add testcase for querying sessions after smbd crash
via b7b0870 rpcclient: Print number of entries for NetSessEnum
via 24a933e printing: return the same error code as windows does on upload failures
via 81e7736 s3: tests: Regression test to ensure we can never return a DIRECTORY attribute on a stream.
via 3d4a8f2 s3: smbd. Generic fix for incorrect reporting of stream dos attributes on a directory
via ace735e s3: vfs: vfs_streams_xattr: Don't blindly re-use the base file mode bits.
from 13f23ec nsswitch: fix memory leak in winbind_open_pipe_sock() when the privileged pipe is not accessable.

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-8-test


- Log -----------------------------------------------------------------
commit 02b898e44d3b71670473cd7698b27d7448d0a96e
Author: Jeremy Allison <***@samba.org>
Date: Wed May 2 11:19:31 2018 -0700

s3: libsmbclient: Fix hard-coded connection error return of ETIMEDOUT.

We shouldn't hard-code the connection error as ETIMEDOUT when
we have a perfectly good NT_STATUS to map from.

Found by the ChromeOS guys trying to connect an SMB2-only client
to an SMB1-only supporting server.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13419

Signed-off-by: Jeremy Allison <***@samba.org>
Reviewed-by: Volker Lendecke <***@SerNet.DE>

Autobuild-User(master): Jeremy Allison <***@samba.org>
Autobuild-Date(master): Thu May 3 02:42:20 CEST 2018 on sn-devel-144

(cherry picked from commit 795ec751ac5f6e58966385bec25063c4af4f185d)

Autobuild-User(v4-8-test): Karolin Seeger <***@samba.org>
Autobuild-Date(v4-8-test): Mon May 7 14:25:28 CEST 2018 on sn-devel-144

commit dc7b7beeee61beab3d23a7678090208f7d345901
Author: Ralph Boehme <***@samba.org>
Date: Mon Apr 30 19:03:41 2018 +0200

s3:cleanupd: use MSG_SMB_BRL_VALIDATE to signal cleanupd unclean process shutdown

Since 6423ca4bf293cac5e2f84b1a37bb29b06b5c05ed messaging_send_all()
broadcasts messages in a cluster, so cleanupd receives those broadcasts
and acts upon it by re-broadcasting the message. Result: message
storm.

By reactivating the currently unused MSG_SMB_BRL_VALIDATE for the
trigger message to cleanupd we avoid the storm.

Note that MSG_SMB_BRL_VALIDATE was unused only in the sense that noone
*listened* to it, but we were still *sending* the message in
smbd_parent_ctdb_reconfigured(). de6fe2a1dd6ab03b1c369b61da17fded72305b2d
removed listening for MSG_SMB_BRL_VALIDATE from cleanupd. This commits
brings it back.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13414

Signed-off-by: Ralph Boehme <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>
(cherry picked from commit d3b9d11bade8bc52d08688ee66a4a20fe0a31a04)

commit 0ccfe32047e0214a262b9392ece677ac0bc085e1
Author: Jeremy Allison <***@samba.org>
Date: Fri Apr 27 14:25:54 2018 -0700

ceph: VFS: Add asynchronous fsync to ceph module, fake using synchronous call.

This will allow me to ultimately simplify the VFS by removing the synchronous
fsync VFS call.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13412

Signed-off-by: Jeremy Allison <***@samba.org>
Reviewed-by: Ralph Boehme <***@samba.org>

Autobuild-User(master): Ralph Böhme <***@samba.org>
Autobuild-Date(master): Mon Apr 30 21:48:55 CEST 2018 on sn-devel-144

(cherry picked from commit aefe444d17a2eee3c0ff38bd34cf9e3f012ecf51)

commit bde663377381fed40bbba5f3e510987d16fa23cf
Author: Amitay Isaacs <***@gmail.com>
Date: Mon Apr 30 19:32:13 2018 +1000

ctdb-client: Remove ununsed functions from old client code

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13411

Signed-off-by: Amitay Isaacs <***@gmail.com>
Reviewed-by: Martin Schwenke <***@meltin.net>

(cherry picked from commit 01c8dc7e15b8764a9b8c8e34b84d0cab790edf47)

commit 7cfaf7000180c9308b18b1944dd41971f805bff1
Author: Christof Schmitt <***@samba.org>
Date: Tue Apr 24 13:53:41 2018 -0700

rpc_server: Fix NetSessEnum with stale sessions

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13407

Signed-off-by: Christof Schmitt <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>

Autobuild-User(master): Jeremy Allison <***@samba.org>
Autobuild-Date(master): Wed Apr 25 22:49:07 CEST 2018 on sn-devel-144

(cherry picked from commit a6fade4e10760284ef56abf45d3fa70038091cbe)

commit 2fcd26a31b0f0fd3778cadc31b497f3c4e132bbd
Author: Christof Schmitt <***@samba.org>
Date: Tue Apr 24 13:52:59 2018 -0700

selftest: Add testcase for querying sessions after smbd crash

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13407

Signed-off-by: Christof Schmitt <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>
(cherry picked from commit e04846c7df8e3eec1f3dbb2fc5eaf47ceb1c44d2)

commit b7b08709434f8bedf7158e90724f45fbf9a15985
Author: Christof Schmitt <***@samba.org>
Date: Tue Apr 24 12:18:49 2018 -0700

rpcclient: Print number of entries for NetSessEnum

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13407

Signed-off-by: Christof Schmitt <***@samba.org>
Reviewed-by: Jeremy Allison <***@samba.org>
(cherry picked from commit 501819fa9e7926c2f54cb92d508ac0e8437fd476)

commit 24a933e7bda083e0be16f1092c1c103eceb99608
Author: Björn Jacke <***@samba.org>
Date: Thu Apr 19 16:14:38 2018 +0200

printing: return the same error code as windows does on upload failures

Some print drivers inf files are broken and cause driver installation to fail
on Samba servers. Windows returns WERR_APP_INIT_FAILURE in that case, we should
do the same. Windows machines are less unlucky with that.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13395

Signed-off-by: Bjoern Jacke <***@samba.org>
Reviewed-by: Andreas Schneider <***@samba.org>

Autobuild-User(master): Björn Jacke <***@sernet.de>
Autobuild-Date(master): Wed Apr 25 13:55:25 CEST 2018 on sn-devel-144

(cherry picked from commit 35f2afe411a3b22fb1befadb3bee8da1bc14753c)

commit 81e7736c745dcceb8c1ad3859e33fa8c8de6d47e
Author: Jeremy Allison <***@samba.org>
Date: Wed Apr 11 10:33:22 2018 -0700

s3: tests: Regression test to ensure we can never return a DIRECTORY attribute on a stream.

Tests streams_xattr and also streams_depot.

Inspired from a real-world test case by Andrew Walker <***@ixsystems.com>.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13380

Signed-off-by: Jeremy Allison <***@samba.org>
Reviewed-by: Ralph Böhme <***@samba.org>

Autobuild-User(master): Jeremy Allison <***@samba.org>
Autobuild-Date(master): Thu Apr 12 02:04:28 CEST 2018 on sn-devel-144

(cherry picked from commit 82beaf868f252c4bc975ddafd80240af6f679b83)

commit 3d4a8f2c5f1f89415ae52539f3c99e6b0b52f020
Author: Jeremy Allison <***@samba.org>
Date: Wed Apr 11 11:05:14 2018 -0700

s3: smbd. Generic fix for incorrect reporting of stream dos attributes on a directory

According to MS-FSA a stream name does not have
separate DOS attribute metadata, so we must return
the DOS attribute from the base filename. With one caveat,
a non-default stream name can never be a directory.

As this is common to all streams data stores, we handle
it here instead of inside all stream VFS modules.

Otherwise identical logic would have to be added to
all streams modules in their [f]get_dos_attribute_fn()
VFS calls.

Found in real-world use case by Andrew Walker <***@ixsystems.com>.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13380

Signed-off-by: Jeremy Allison <***@samba.org>
Reviewed-by: Ralph Böhme <***@samba.org>
(cherry picked from commit 118e77d86a7171f589f805fa4f63246b0cb63672)

commit ace735eb2b23896ad43bbf570be818a8ad533b58
Author: Jeremy Allison <***@samba.org>
Date: Wed Apr 11 08:41:00 2018 -0700

s3: vfs: vfs_streams_xattr: Don't blindly re-use the base file mode bits.

When returning the stat struct for an xattr stream,
we originally base the st_ex_mode field on the value
from the base file containing the xattr. If the base
file is a directory, it will have S_IFDIR set in st_ex_mode,
but streams can never be directories, they must be reported
as regular files.

The original code OR'ed in S_IFREG, but neglected to
AND out S_IFDIR.

Note this is not a complete to fix bug 13380 as
it doesn't fix the generic case with all streams
modules. See later fix and regression test.

Found in real-world use case by Andrew Walker <***@ixsystems.com>.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13380

Signed-off-by: Jeremy Allison <***@samba.org>
Reviewed-by: Volker Lendecke <***@samba.org>
Reviewed-by: Ralph Böhme <***@samba.org>
(cherry picked from commit 4d839d0f46b723ed6809bb932b9ebe4ead2cec82)

-----------------------------------------------------------------------

Summary of changes:
ctdb/client/ctdb_client.c | 2535 +-------------------
ctdb/include/ctdb_client.h | 218 --
selftest/target/Samba3.pm | 4 +
source3/libsmb/libsmb_server.c | 2 +-
source3/modules/vfs_ceph.c | 53 +
source3/modules/vfs_streams_xattr.c | 2 +
source3/printing/nt_printing.c | 2 +-
source3/rpcclient/cmd_srvsvc.c | 2 +
source3/script/tests/test_rpcclient_netsessenum.sh | 55 +
source3/script/tests/test_smbclient_s3.sh | 76 +
source3/selftest/tests.py | 6 +
source3/smbd/dosmode.c | 22 +
source3/smbd/server.c | 2 +-
source3/smbd/session.c | 4 +
source3/smbd/smbd_cleanupd.c | 2 +-
15 files changed, 345 insertions(+), 2640 deletions(-)
create mode 100755 source3/script/tests/test_rpcclient_netsessenum.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index d399cb5..635a488 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -584,354 +584,6 @@ int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t pnn,


/*
- cancel a ctdb_fetch_lock operation, releasing the lock
- */
-static int fetch_lock_destructor(struct ctdb_record_handle *h)
-{
- ctdb_ltdb_unlock(h->ctdb_db, h->key);
- return 0;
-}
-
-/*
- force the migration of a record to this node
- */
-static int ctdb_client_force_migration(struct ctdb_db_context *ctdb_db, TDB_DATA key)
-{
- struct ctdb_call call;
- ZERO_STRUCT(call);
- call.call_id = CTDB_NULL_FUNC;
- call.key = key;
- call.flags = CTDB_IMMEDIATE_MIGRATION;
- return ctdb_call(ctdb_db, &call);
-}
-
-/*
- try to fetch a readonly copy of a record
- */
-static int
-ctdb_client_fetch_readonly(struct ctdb_db_context *ctdb_db, TDB_DATA key, TALLOC_CTX *mem_ctx, struct ctdb_ltdb_header **hdr, TDB_DATA *data)
-{
- int ret;
-
- struct ctdb_call call;
- ZERO_STRUCT(call);
-
- call.call_id = CTDB_FETCH_WITH_HEADER_FUNC;
- call.call_data.dptr = NULL;
- call.call_data.dsize = 0;
- call.key = key;
- call.flags = CTDB_WANT_READONLY;
- ret = ctdb_call(ctdb_db, &call);
-
- if (ret != 0) {
- return -1;
- }
- if (call.reply_data.dsize < sizeof(struct ctdb_ltdb_header)) {
- return -1;
- }
-
- *hdr = talloc_memdup(mem_ctx, &call.reply_data.dptr[0], sizeof(struct ctdb_ltdb_header));
- if (*hdr == NULL) {
- talloc_free(call.reply_data.dptr);
- return -1;
- }
-
- data->dsize = call.reply_data.dsize - sizeof(struct ctdb_ltdb_header);
- data->dptr = talloc_memdup(mem_ctx, &call.reply_data.dptr[sizeof(struct ctdb_ltdb_header)], data->dsize);
- if (data->dptr == NULL) {
- talloc_free(call.reply_data.dptr);
- talloc_free(hdr);
- return -1;
- }
-
- return 0;
-}
-
-/*
- get a lock on a record, and return the records data. Blocks until it gets the lock
- */
-struct ctdb_record_handle *ctdb_fetch_lock(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx,
- TDB_DATA key, TDB_DATA *data)
-{
- int ret;
- struct ctdb_record_handle *h;
-
- /*
- procedure is as follows:
-
- 1) get the chain lock.
- 2) check if we are dmaster
- 3) if we are the dmaster then return handle
- 4) if not dmaster then ask ctdb daemon to make us dmaster, and wait for
- reply from ctdbd
- 5) when we get the reply, goto (1)
- */
-
- h = talloc_zero(mem_ctx, struct ctdb_record_handle);
- if (h == NULL) {
- return NULL;
- }
-
- h->ctdb_db = ctdb_db;
- h->key = key;
- h->key.dptr = talloc_memdup(h, key.dptr, key.dsize);
- if (h->key.dptr == NULL) {
- talloc_free(h);
- return NULL;
- }
- h->data = data;
-
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_lock: key=%*.*s\n", (int)key.dsize, (int)key.dsize,
- (const char *)key.dptr));
-
-again:
- /* step 1 - get the chain lock */
- ret = ctdb_ltdb_lock(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " failed to lock ltdb record\n"));
- talloc_free(h);
- return NULL;
- }
-
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_lock: got chain lock\n"));
-
- talloc_set_destructor(h, fetch_lock_destructor);
-
- ret = ctdb_ltdb_fetch(ctdb_db, key, &h->header, h, data);
-
- /* when torturing, ensure we test the remote path */
- if ((ctdb_db->ctdb->flags & CTDB_FLAG_TORTURE) &&
- random() % 5 == 0) {
- h->header.dmaster = (uint32_t)-1;
- }
-
-
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_lock: done local fetch\n"));
-
- if (ret != 0 || h->header.dmaster != ctdb_db->ctdb->pnn) {
- ctdb_ltdb_unlock(ctdb_db, key);
- ret = ctdb_client_force_migration(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_lock: force_migration failed\n"));
- talloc_free(h);
- return NULL;
- }
- goto again;
- }
-
- /* if this is a request for read/write and we have delegations
- we have to revoke all delegations first
- */
- if ((h->header.dmaster == ctdb_db->ctdb->pnn) &&
- (h->header.flags & CTDB_REC_RO_HAVE_DELEGATIONS)) {
- ctdb_ltdb_unlock(ctdb_db, key);
- ret = ctdb_client_force_migration(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_readonly_lock: force_migration failed\n"));
- talloc_free(h);
- return NULL;
- }
- goto again;
- }
-
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_lock: we are dmaster - done\n"));
- return h;
-}
-
-/*
- get a readonly lock on a record, and return the records data. Blocks until it gets the lock
- */
-struct ctdb_record_handle *
-ctdb_fetch_readonly_lock(
- struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx,
- TDB_DATA key, TDB_DATA *data,
- int read_only)
-{
- int ret;
- struct ctdb_record_handle *h;
- struct ctdb_ltdb_header *roheader = NULL;
-
- h = talloc_zero(mem_ctx, struct ctdb_record_handle);
- if (h == NULL) {
- return NULL;
- }
-
- h->ctdb_db = ctdb_db;
- h->key = key;
- h->key.dptr = talloc_memdup(h, key.dptr, key.dsize);
- if (h->key.dptr == NULL) {
- talloc_free(h);
- return NULL;
- }
- h->data = data;
-
- data->dptr = NULL;
- data->dsize = 0;
-
-
-again:
- talloc_free(roheader);
- roheader = NULL;
-
- talloc_free(data->dptr);
- data->dptr = NULL;
- data->dsize = 0;
-
- /* Lock the record/chain */
- ret = ctdb_ltdb_lock(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " failed to lock ltdb record\n"));
- talloc_free(h);
- return NULL;
- }
-
- talloc_set_destructor(h, fetch_lock_destructor);
-
- /* Check if record exists yet in the TDB */
- ret = ctdb_ltdb_fetch_with_header(ctdb_db, key, &h->header, h, data);
- if (ret != 0) {
- ctdb_ltdb_unlock(ctdb_db, key);
- ret = ctdb_client_force_migration(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_readonly_lock: force_migration failed\n"));
- talloc_free(h);
- return NULL;
- }
- goto again;
- }
-
- /* if this is a request for read/write and we have delegations
- we have to revoke all delegations first
- */
- if ((read_only == 0)
- && (h->header.dmaster == ctdb_db->ctdb->pnn)
- && (h->header.flags & CTDB_REC_RO_HAVE_DELEGATIONS)) {
- ctdb_ltdb_unlock(ctdb_db, key);
- ret = ctdb_client_force_migration(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_readonly_lock: force_migration failed\n"));
- talloc_free(h);
- return NULL;
- }
- goto again;
- }
-
- /* if we are dmaster, just return the handle */
- if (h->header.dmaster == ctdb_db->ctdb->pnn) {
- return h;
- }
-
- if (read_only != 0) {
- TDB_DATA rodata = {NULL, 0};
-
- if ((h->header.flags & CTDB_REC_RO_HAVE_READONLY)
- || (h->header.flags & CTDB_REC_RO_HAVE_DELEGATIONS)) {
- return h;
- }
-
- ctdb_ltdb_unlock(ctdb_db, key);
- ret = ctdb_client_fetch_readonly(ctdb_db, key, h, &roheader, &rodata);
- if (ret != 0) {
- DEBUG(DEBUG_ERR,("ctdb_fetch_readonly_lock: failed. force migration and try again\n"));
- ret = ctdb_client_force_migration(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_readonly_lock: force_migration failed\n"));
- talloc_free(h);
- return NULL;
- }
-
- goto again;
- }
-
- if (!(roheader->flags&CTDB_REC_RO_HAVE_READONLY)) {
- ret = ctdb_client_force_migration(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_readonly_lock: force_migration failed\n"));
- talloc_free(h);
- return NULL;
- }
-
- goto again;
- }
-
- ret = ctdb_ltdb_lock(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " failed to lock ltdb record\n"));
- talloc_free(h);
- return NULL;
- }
-
- ret = ctdb_ltdb_fetch_with_header(ctdb_db, key, &h->header, h, data);
- if (ret != 0) {
- ctdb_ltdb_unlock(ctdb_db, key);
-
- ret = ctdb_client_force_migration(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_readonly_lock: force_migration failed\n"));
- talloc_free(h);
- return NULL;
- }
-
- goto again;
- }
-
- return h;
- }
-
- /* we are not dmaster and this was not a request for a readonly lock
- * so unlock the record, migrate it and try again
- */
- ctdb_ltdb_unlock(ctdb_db, key);
- ret = ctdb_client_force_migration(ctdb_db, key);
- if (ret != 0) {
- DEBUG(DEBUG_DEBUG,("ctdb_fetch_lock: force_migration failed\n"));
- talloc_free(h);
- return NULL;
- }
- goto again;
-}
-
-/*
- store some data to the record that was locked with ctdb_fetch_lock()
-*/
-int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data)
-{
- if (! ctdb_db_volatile(h->ctdb_db)) {
- DEBUG(DEBUG_ERR,
- ("ctdb_record_store prohibited for non-volatile dbs\n"));
- return -1;
- }
-
- return ctdb_ltdb_store(h->ctdb_db, h->key, &h->header, data);
-}
-
-/*
- non-locking fetch of a record
- */
-int ctdb_fetch(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx,
- TDB_DATA key, TDB_DATA *data)
-{
- struct ctdb_call call;
- int ret;
-
- call.call_id = CTDB_FETCH_FUNC;
- call.call_data.dptr = NULL;
- call.call_data.dsize = 0;
- call.key = key;
-
- ret = ctdb_call(ctdb_db, &call);
-
- if (ret == 0) {
- *data = call.reply_data;
- talloc_steal(mem_ctx, data->dptr);
- }
-
- return ret;
-}
-
-
-
-/*
called when a control completes or timesout to invoke the callback
function the user provided
*/
@@ -1210,134 +862,6 @@ int ctdb_control(struct ctdb_context *ctdb, uint32_t destnode, uint64_t srvid,
errormsg);
}

-
-
-
-/*
- a process exists call. Returns 0 if process exists, -1 otherwise
- */
-int ctdb_ctrl_process_exists(struct ctdb_context *ctdb, uint32_t destnode, pid_t pid)
-{
- int ret;
- TDB_DATA data;
- int32_t status;
-
- data.dptr = (uint8_t*)&pid;
- data.dsize = sizeof(pid);
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_PROCESS_EXISTS, 0, data,
- NULL, NULL, &status, NULL, NULL);
- if (ret != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for process_exists failed\n"));
- return -1;
- }
-
- return status;
-}
-
-/*
- get remote statistics
- */
-int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_statistics *status)
-{
- int ret;
- TDB_DATA data;
- int32_t res;
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_STATISTICS, 0, tdb_null,
- ctdb, &data, &res, NULL, NULL);
- if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for statistics failed\n"));
- return -1;
- }
-
- if (data.dsize != sizeof(struct ctdb_statistics)) {
- DEBUG(DEBUG_ERR,(__location__ " Wrong statistics size %u - expected %u\n",
- (unsigned)data.dsize, (unsigned)sizeof(struct ctdb_statistics)));
- return -1;
- }
-
- *status = *(struct ctdb_statistics *)data.dptr;
- talloc_free(data.dptr);
-
- return 0;
-}
-
-/*
- * get db statistics
- */
-int ctdb_ctrl_dbstatistics(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
- TALLOC_CTX *mem_ctx, struct ctdb_db_statistics_old **dbstat)
-{
- int ret;
- TDB_DATA indata, outdata;
- int32_t res;
- struct ctdb_db_statistics_old *wire, *s;
- char *ptr;
- int i;
-
- indata.dptr = (uint8_t *)&dbid;
- indata.dsize = sizeof(dbid);
-
- ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_GET_DB_STATISTICS,
- 0, indata, ctdb, &outdata, &res, NULL, NULL);
- if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for dbstatistics failed\n"));
- return -1;
- }
-
- if (outdata.dsize < offsetof(struct ctdb_db_statistics_old, hot_keys_wire)) {
- DEBUG(DEBUG_ERR,(__location__ " Wrong dbstatistics size %zi - expected >= %lu\n",
- outdata.dsize,
- (long unsigned int)sizeof(struct ctdb_statistics)));
- return -1;
- }
-
- s = talloc_zero(mem_ctx, struct ctdb_db_statistics_old);
- if (s == NULL) {
- talloc_free(outdata.dptr);
- CTDB_NO_MEMORY(ctdb, s);
- }
-
- wire = (struct ctdb_db_statistics_old *)outdata.dptr;
- memcpy(s, wire, offsetof(struct ctdb_db_statistics_old, hot_keys_wire));
- ptr = &wire->hot_keys_wire[0];
- for (i=0; i<wire->num_hot_keys; i++) {
- s->hot_keys[i].key.dptr = talloc_size(mem_ctx, s->hot_keys[i].key.dsize);
- if (s->hot_keys[i].key.dptr == NULL) {
- talloc_free(outdata.dptr);
- CTDB_NO_MEMORY(ctdb, s->hot_keys[i].key.dptr);
- }
-
- memcpy(s->hot_keys[i].key.dptr, ptr, s->hot_keys[i].key.dsize);
- ptr += wire->hot_keys[i].key.dsize;
- }
-
- talloc_free(outdata.dptr);
- *dbstat = s;
- return 0;
-}
-
-/*
- shutdown a remote ctdb node
- */
-int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
-{
- struct ctdb_client_control_state *state;
-
- state = ctdb_control_send(ctdb, destnode, 0,
- CTDB_CONTROL_SHUTDOWN, 0, tdb_null,
- NULL, &timeout, NULL);
- if (state == NULL) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for shutdown failed\n"));
- return -1;
- }
-
- return 0;
-}
-
/*
get vnn map from a remote node
*/
@@ -1554,259 +1078,68 @@ int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb,
return 0;
}

-/*
- load nodes file on a remote node and return as a node map
--
Samba Shared Repository
Loading...