The branch, v4-7-test has been updated via 6a67866 lib/util/run_cmd: use a cleanup function instead of a destructor via 31eefb6 lib/util/run_cmd: remove a printf via c7f33ca lib/util/run_cmd: ensure fd_stdin gets set to -1 in the destructor via 634514a lib/util/run_cmd: prevent zombies in samba_runcmd_send on timeout via 3711ec4 selftest: Check re-opening sam.ldb corrects the @ATTRIBUTES and @INDEXLIST from 16594ab VERSION: Bump version up to 4.7.1...
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-7-test - Log ----------------------------------------------------------------- commit 6a678665aec5ec026edb49841f037703ea2fd5a7 Author: Ralph Boehme <s...@samba.org> Date: Fri Sep 29 13:07:53 2017 +0200 lib/util/run_cmd: use a cleanup function instead of a destructor Bug: https://bugzilla.samba.org/show_bug.cgi?id=13062 Pair-programmed-with: Stefan Metzmacher <me...@samba.org> Signed-off-by: Stefan Metzmacher <me...@samba.org> Signed-off-by: Ralph Boehme <s...@samba.org> Autobuild-User(master): Ralph Böhme <s...@samba.org> Autobuild-Date(master): Sat Sep 30 12:14:57 CEST 2017 on sn-devel-144 (cherry picked from commit 6539cc8a24204697b20506896c401e7b40eee928) Autobuild-User(v4-7-test): Stefan Metzmacher <me...@samba.org> Autobuild-Date(v4-7-test): Mon Oct 2 13:17:15 CEST 2017 on sn-devel-144 commit 31eefb6c98418cdde9dcee383262a298ae956ac4 Author: Ralph Boehme <s...@samba.org> Date: Fri Sep 29 13:07:26 2017 +0200 lib/util/run_cmd: remove a printf Bug: https://bugzilla.samba.org/show_bug.cgi?id=13062 Pair-programmed-with: Stefan Metzmacher <me...@samba.org> Signed-off-by: Stefan Metzmacher <me...@samba.org> Signed-off-by: Ralph Boehme <s...@samba.org> (cherry picked from commit 94a8331e5425b735f9e2c0121afc2fb108bec891) commit c7f33ca3183a68be725587044ce8cf0c44d5d549 Author: Ralph Boehme <s...@samba.org> Date: Fri Sep 29 13:06:08 2017 +0200 lib/util/run_cmd: ensure fd_stdin gets set to -1 in the destructor Bug: https://bugzilla.samba.org/show_bug.cgi?id=13062 Pair-programmed-with: Stefan Metzmacher <me...@samba.org> Signed-off-by: Stefan Metzmacher <me...@samba.org> Signed-off-by: Ralph Boehme <s...@samba.org> (cherry picked from commit 4aaf072d1fd732abf2cbea135d508260cdafa4eb) commit 634514a8d431b45a070f1d052b552bcf5f0a3bee Author: Ralph Boehme <s...@samba.org> Date: Fri Sep 29 12:45:24 2017 +0200 lib/util/run_cmd: prevent zombies in samba_runcmd_send on timeout Ensure the state desctructor calls tfork_destroy to reap the waiter and worker processes. Otherwise we leave the waiter process as a zombie behind us as we never call waitpid on it in case of a timeout or talloc_free() from the caller. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13062 Pair-programmed-with: Stefan Metzmacher <me...@samba.org> Signed-off-by: Stefan Metzmacher <me...@samba.org> Signed-off-by: Ralph Boehme <s...@samba.org> (cherry picked from commit 9a8eeabd95afca2e88666b3e8f2af954dbf23ba9) commit 3711ec4dafc098668eb0c1bee9dee62838024a59 Author: Andrew Bartlett <abart...@samba.org> Date: Wed Sep 13 16:13:06 2017 +1200 selftest: Check re-opening sam.ldb corrects the @ATTRIBUTES and @INDEXLIST https://bugzilla.samba.org/show_bug.cgi?id=13025 Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> (cherry picked from commit 51be27522caffde8a3806f8c0c877a0f85eaf398) ----------------------------------------------------------------------- Summary of changes: lib/util/util_runcmd.c | 19 +++++----- python/samba/tests/dsdb_schema_attributes.py | 53 ++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 8 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/util/util_runcmd.c b/lib/util/util_runcmd.c index 6077fdd..42d84a8 100644 --- a/lib/util/util_runcmd.c +++ b/lib/util/util_runcmd.c @@ -32,18 +32,21 @@ #include "../lib/util/tfork.h" #include "../lib/util/sys_rw.h" -static int samba_runcmd_state_destructor(struct samba_runcmd_state *state) +static void samba_runcmd_cleanup_fn(struct tevent_req *req, + enum tevent_req_state req_state) { - if (state->pid > 0) { - kill(state->pid, SIGKILL); - waitpid(state->pid, NULL, 0); - state->pid = -1; + struct samba_runcmd_state *state = tevent_req_data( + req, struct samba_runcmd_state); + + if (state->tfork != NULL) { + tfork_destroy(&state->tfork); } + state->pid = -1; if (state->fd_stdin != -1) { close(state->fd_stdin); + state->fd_stdin = -1; } - return 0; } static void samba_runcmd_io_handler(struct tevent_context *ev, @@ -110,7 +113,6 @@ struct tevent_req *samba_runcmd_send(TALLOC_CTX *mem_ctx, state->tfork = tfork_create(); if (state->tfork == NULL) { - printf("state->tfork == NULL\n"); close(p1[0]); close(p1[1]); close(p2[0]); @@ -141,7 +143,7 @@ struct tevent_req *samba_runcmd_send(TALLOC_CTX *mem_ctx, smb_set_close_on_exec(state->fd_stderr); smb_set_close_on_exec(state->fd_status); - talloc_set_destructor(state, samba_runcmd_state_destructor); + tevent_req_set_cleanup_fn(req, samba_runcmd_cleanup_fn); state->fde_stdout = tevent_add_fd(ev, state, state->fd_stdout, @@ -275,6 +277,7 @@ static void samba_runcmd_io_handler(struct tevent_context *ev, tevent_req_error(req, errno); return; } + state->pid = -1; TALLOC_FREE(fde); if (WIFEXITED(status)) { diff --git a/python/samba/tests/dsdb_schema_attributes.py b/python/samba/tests/dsdb_schema_attributes.py index df6c8bb..2bebbb5 100644 --- a/python/samba/tests/dsdb_schema_attributes.py +++ b/python/samba/tests/dsdb_schema_attributes.py @@ -173,3 +173,56 @@ systemOnly: FALSE self.assertIn(attr_ldap_name, [str(x) for x in idx_res[0]["@IDXATTR"]]) self.assertIn(attr_ldap_name2, [str(x) for x in idx_res[0]["@IDXATTR"]]) + + def test_modify_at_attributes(self): + m = {"dn": "@ATTRIBUTES", + "@TEST_EXTRA": ["HIDDEN"] + } + + msg = ldb.Message.from_dict(self.samdb, m, ldb.FLAG_MOD_ADD) + self.samdb.modify(msg) + + res = self.samdb.search(base="@ATTRIBUTES", scope=ldb.SCOPE_BASE, + attrs=["@TEST_EXTRA"]) + self.assertEquals(len(res), 1) + self.assertEquals(str(res[0].dn), "@ATTRIBUTES") + self.assertEquals(len(res[0]), 1) + self.assertTrue("@TEST_EXTRA" in res[0]) + self.assertEquals(len(res[0]["@TEST_EXTRA"]), 1) + self.assertEquals(res[0]["@TEST_EXTRA"][0], "HIDDEN") + + samdb2 = samba.tests.connect_samdb(self.lp.samdb_url()) + + res = self.samdb.search(base="@ATTRIBUTES", scope=ldb.SCOPE_BASE, + attrs=["@TEST_EXTRA"]) + self.assertEquals(len(res), 1) + self.assertEquals(str(res[0].dn), "@ATTRIBUTES") + self.assertEquals(len(res[0]), 0) + self.assertFalse("@TEST_EXTRA" in res[0]) + + + def test_modify_at_indexlist(self): + m = {"dn": "@INDEXLIST", + "@TEST_EXTRA": ["1"] + } + + msg = ldb.Message.from_dict(self.samdb, m, ldb.FLAG_MOD_ADD) + self.samdb.modify(msg) + + res = self.samdb.search(base="@INDEXLIST", scope=ldb.SCOPE_BASE, + attrs=["@TEST_EXTRA"]) + self.assertEquals(len(res), 1) + self.assertEquals(str(res[0].dn), "@INDEXLIST") + self.assertEquals(len(res[0]), 1) + self.assertTrue("@TEST_EXTRA" in res[0]) + self.assertEquals(len(res[0]["@TEST_EXTRA"]), 1) + self.assertEquals(res[0]["@TEST_EXTRA"][0], "1") + + samdb2 = samba.tests.connect_samdb(self.lp.samdb_url()) + + res = self.samdb.search(base="@INDEXLIST", scope=ldb.SCOPE_BASE, + attrs=["@TEST_EXTRA"]) + self.assertEquals(len(res), 1) + self.assertEquals(str(res[0].dn), "@INDEXLIST") + self.assertEquals(len(res[0]), 0) + self.assertFalse("@TEST_EXTRA" in res[0]) -- Samba Shared Repository