[SCM] Samba Shared Repository - branch master updated
Ralph Böhme
slow at samba.org
Tue May 18 11:33:01 UTC 2021
The branch, master has been updated
via bebe313ced7 lib:cmdline: Fix setting 'log file' from smb.conf
via adef87a621b ctdb: Fix a crash in run_proc_signal_handler()
via f320d1a7ab0 ctdb: Introduce output before and after the 10-second timeout
via 19290f10c7d ctdb: Wait for SIGCHLD if script timed out
via 07ab9b7a71d ctdb: Introduce a helper variable in run_event_test.c
via 9398d4b9123 ctdb: Call run_event_recv() in a callback function
via f188c9d732e ctdb: fix typos
from a204e42c2f8 dlz: remove support for ancient binds
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit bebe313ced732ebd53e127c5baf059eb1ae2b528
Author: Andreas Schneider <asn at samba.org>
Date: Mon May 17 11:00:29 2021 +0200
lib:cmdline: Fix setting 'log file' from smb.conf
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
Autobuild-User(master): Ralph Böhme <slow at samba.org>
Autobuild-Date(master): Tue May 18 11:32:41 UTC 2021 on sn-devel-184
commit adef87a621b17baf746d12f991c60a8a3ffcfcd3
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>
commit f320d1a7ab0f81eefdb28b36bfe346eacb8980de
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>
commit 19290f10c7d39e055847eb45affd9e229a116b18
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>
commit 07ab9b7a71d59f3ff2b9dee662632315062213ab
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>
commit 9398d4b912387be8cde0c2ca30734eca7d547d19
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>
commit f188c9d732e4b9b3d37c4cb09608aba747845997
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>
-----------------------------------------------------------------------
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 +++++++++++++++++++++++++++-------
lib/cmdline/cmdline.c | 25 +++++++++++-----
4 files changed, 65 insertions(+), 21 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,
diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c
index 1802a291f4c..e7e65ff13be 100644
--- a/lib/cmdline/cmdline.c
+++ b/lib/cmdline/cmdline.c
@@ -286,9 +286,10 @@ static bool log_to_file;
static bool set_logfile(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx,
const char *log_basename,
- const char *process_name)
+ const char *process_name,
+ bool from_cmdline)
{
- bool ok;
+ bool ok = false;
char *new_logfile = talloc_asprintf(mem_ctx,
"%s/log.%s",
log_basename,
@@ -297,9 +298,15 @@ static bool set_logfile(TALLOC_CTX *mem_ctx,
return false;
}
- ok = lpcfg_set_cmdline(lp_ctx,
- "log file",
- new_logfile);
+ if (from_cmdline) {
+ ok = lpcfg_set_cmdline(lp_ctx,
+ "log file",
+ new_logfile);
+ } else {
+ ok = lpcfg_do_global_parameter(lp_ctx,
+ "log file",
+ new_logfile);
+ }
if (!ok) {
fprintf(stderr,
"Failed to set log to %s\n",
@@ -336,7 +343,11 @@ static void popt_samba_callback(poptContext popt_ctx,
"Command line parsing not initialized!\n");
exit(1);
}
- ok = set_logfile(mem_ctx, lp_ctx, get_dyn_LOGFILEBASE(), pname);
+ ok = set_logfile(mem_ctx,
+ lp_ctx,
+ get_dyn_LOGFILEBASE(),
+ pname,
+ false);
if (!ok) {
fprintf(stderr,
"Failed to set log file for %s\n",
@@ -411,7 +422,7 @@ static void popt_samba_callback(poptContext popt_ctx,
break;
case 'l':
if (arg != NULL) {
- ok = set_logfile(mem_ctx, lp_ctx, arg, pname);
+ ok = set_logfile(mem_ctx, lp_ctx, arg, pname, true);
if (!ok) {
fprintf(stderr,
"Failed to set log file for %s\n",
--
Samba Shared Repository
More information about the samba-cvs
mailing list