[SCM] Samba Shared Repository - branch v4-13-test updated

Karolin Seeger kseeger at samba.org
Tue May 25 08:56:01 UTC 2021


The branch, v4-13-test has been updated
       via  c67dbd55aad ctdb: Fix a crash in run_proc_signal_handler()
       via  037f4b8fb9a ctdb: Introduce output before and after the 10-second timeout
       via  87265cef4b7 ctdb: Wait for SIGCHLD if script timed out
       via  e70a8cbdb4a ctdb: Introduce a helper variable in run_event_test.c
       via  5e55d2c0dcf ctdb: Call run_event_recv() in a callback function
       via  83511576a1c ctdb: fix typos
      from  abcddbae481 s3: smbd: Ensure POSIX default ACL is mapped into returned Windows ACL for directory handles.

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


- Log -----------------------------------------------------------------
commit c67dbd55aadfffb8ee7623aacbda13aa5c676418
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 18 08:32:45 2021 +0200

    ctdb: Fix a crash in run_proc_signal_handler()
    
    If a script times out the caller can talloc_free() the script_list
    output of run_event_recv, which talloc_free's proc->output from
    run_proc.c as well. If the script generates further output after the
    timeout and then exits after a while, the SIGCHLD handler in the
    eventd tries to read into proc->output, which was already free'ed.
    
    Fix this by not doing just a talloc_steal but a talloc_move. This way
    proc_read_handler() called from run_proc_signal_handler() does not try
    to realloc the stale reference to proc->output but gets a NULL
    reference.
    
    I don't really know how to do a knownfail in ctdb, so this commit
    actually activates catching the signal by waiting long enough for
    22.bar to exit and generate the SIGCHLD.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit adef87a621b17baf746d12f991c60a8a3ffcfcd3)
    
    Autobuild-User(v4-13-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-13-test): Tue May 25 08:55:59 UTC 2021 on sn-devel-184

commit 037f4b8fb9a3f3ee373441ea31ab0755053df3c2
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 18 08:28:16 2021 +0200

    ctdb: Introduce output before and after the 10-second timeout
    
    This will lead to a crash in run_event_test.c soon
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit f320d1a7ab0f81eefdb28b36bfe346eacb8980de)

commit 87265cef4b7e47d8b7a0eac7bb30ff3682714f43
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 18 08:23:05 2021 +0200

    ctdb: Wait for SIGCHLD if script timed out
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 19290f10c7d39e055847eb45affd9e229a116b18)

commit e70a8cbdb4a1b571651bdc8712ae905d9d9d5283
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 18 08:18:25 2021 +0200

    ctdb: Introduce a helper variable in run_event_test.c
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 07ab9b7a71d59f3ff2b9dee662632315062213ab)

commit 5e55d2c0dcfa41c10ae0637cd930625a5a273b3a
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 18 08:01:06 2021 +0200

    ctdb: Call run_event_recv() in a callback function
    
    Triggers a different code path in run_event_* and aligns it more what
    the ctdb eventd really does.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 9398d4b912387be8cde0c2ca30734eca7d547d19)

commit 83511576a1c8a4b3b674b176cf190fc8710eb421
Author: Volker Lendecke <vl at samba.org>
Date:   Fri May 7 17:36:58 2021 +0200

    ctdb: fix typos
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit f188c9d732e4b9b3d37c4cb09608aba747845997)

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

Summary of changes:
 ctdb/common/run_proc.c                 |  6 ++--
 ctdb/tests/UNIT/cunit/run_event_001.sh |  3 ++
 ctdb/tests/src/run_event_test.c        | 52 +++++++++++++++++++++++++++-------
 3 files changed, 47 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/common/run_proc.c b/ctdb/common/run_proc.c
index 0c3c1de72fe..d55af6c3a1e 100644
--- a/ctdb/common/run_proc.c
+++ b/ctdb/common/run_proc.c
@@ -426,7 +426,7 @@ static void run_proc_done(struct tevent_req *req)
 
 	state->result = state->proc->result;
 	if (state->proc->output != NULL) {
-		state->output = talloc_steal(state, state->proc->output);
+		state->output = talloc_move(state, &state->proc->output);
 	}
 	talloc_steal(state, state->proc);
 
@@ -464,7 +464,7 @@ static void run_proc_timedout(struct tevent_req *subreq)
 
 	state->result.err = ETIMEDOUT;
 	if (state->proc->output != NULL) {
-		state->output = talloc_steal(state, state->proc->output);
+		state->output = talloc_move(state, &state->proc->output);
 	}
 	state->pid = state->proc->pid;
 
@@ -495,7 +495,7 @@ bool run_proc_recv(struct tevent_req *req, int *perr,
 	}
 
 	if (output != NULL) {
-		*output = talloc_steal(mem_ctx, state->output);
+		*output = talloc_move(mem_ctx, &state->output);
 	}
 
 	return true;
diff --git a/ctdb/tests/UNIT/cunit/run_event_001.sh b/ctdb/tests/UNIT/cunit/run_event_001.sh
index 50051bfaab2..4df3b4bdad6 100755
--- a/ctdb/tests/UNIT/cunit/run_event_001.sh
+++ b/ctdb/tests/UNIT/cunit/run_event_001.sh
@@ -113,7 +113,9 @@ unit_test run_event_test "$scriptdir" run 10 monitor
 cat > "$scriptdir/22.bar.script" <<EOF
 #!/bin/sh
 
+echo before sleep
 sleep 10
+echo after sleep
 EOF
 
 # Timed out script
@@ -124,6 +126,7 @@ unit_test run_event_test "$scriptdir" enable 22.bar
 
 ok <<EOF
 11.foo: hello
+22.bar: before sleep
 Event monitor completed with result=-$(errcode ETIMEDOUT)
 11.foo result=0
 22.bar result=-$(errcode ETIMEDOUT)
diff --git a/ctdb/tests/src/run_event_test.c b/ctdb/tests/src/run_event_test.c
index cfe5f161d1d..94548647014 100644
--- a/ctdb/tests/src/run_event_test.c
+++ b/ctdb/tests/src/run_event_test.c
@@ -52,6 +52,19 @@ static char *compact_args(const char **argv, int argc, int from)
 	return arg_str;
 }
 
+static void run_done(struct tevent_req *req)
+{
+	struct run_event_script_list **script_list =
+		tevent_req_callback_data_void(req);
+	bool status;
+	int ret;
+
+	status = run_event_recv(req, &ret, NULL, script_list);
+	if (!status) {
+		fprintf(stderr, "run_event_recv() failed, ret=%d\n", ret);
+	}
+}
+
 static void do_run(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 		   struct run_event_context *run_ctx,
 		   int argc, const char **argv)
@@ -61,8 +74,8 @@ static void do_run(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 	struct run_event_script_list *script_list = NULL;
 	char *arg_str;
 	unsigned int i;
-	int ret, t;
-	bool status;
+	int t;
+	bool wait_for_signal = false;
 
 	if (argc < 5) {
 		usage(argv[0]);
@@ -86,17 +99,13 @@ static void do_run(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			     timeout,
 			     false);
 	if (req == NULL) {
-		fprintf(stderr, "run_proc_send() failed\n");
+		fprintf(stderr, "run_event_send() failed\n");
 		return;
 	}
 
-	tevent_req_poll(req, ev);
+	tevent_req_set_callback(req, run_done, &script_list);
 
-	status = run_event_recv(req, &ret, mem_ctx, &script_list);
-	if (! status) {
-		fprintf(stderr, "run_proc_recv() failed, ret=%d\n", ret);
-		return;
-	}
+	tevent_req_poll(req, ev);
 
 	if (script_list == NULL || script_list->num_scripts == 0) {
 		printf("No event scripts found\n");
@@ -106,9 +115,30 @@ static void do_run(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 	printf("Event %s completed with result=%d\n",
 	       argv[4], script_list->summary);
 	for (i=0; i<script_list->num_scripts; i++) {
-		printf("%s result=%d\n", script_list->script[i].name,
-		       script_list->script[i].summary);
+		struct run_event_script *s = &script_list->script[i];
+		printf("%s result=%d\n", s->name, s->summary);
+
+		if (s->summary == -ETIMEDOUT) {
+			wait_for_signal = true;
+		}
+	}
+
+	TALLOC_FREE(script_list);
+	TALLOC_FREE(req);
+
+	if (!wait_for_signal) {
+		return;
 	}
+
+	req = tevent_wakeup_send(
+		ev, ev, tevent_timeval_current_ofs(10, 0));
+	if (req == NULL) {
+		fprintf(stderr, "Could not wait for signal\n");
+		return;
+	}
+
+	tevent_req_poll(req, ev);
+	TALLOC_FREE(req);
 }
 
 static void do_list(TALLOC_CTX *mem_ctx, struct tevent_context *ev,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list