[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Sat Jul 31 16:59:01 UTC 2021
The branch, master has been updated
via 7818513053a samba-bgqd: Fix samba-bgqd with "clustering=yes"/"include=registry"
from 2acad276860 s3: smbd: Don't leak meta-data about the containing directory of the share root.
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 7818513053aabda046645583fa5bb79a03e2b5ac
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jul 30 11:43:08 2021 +0200
samba-bgqd: Fix samba-bgqd with "clustering=yes"/"include=registry"
With the above combination, some flavor of lp_load() already
initializes global_event_ctx, for which the closeall_except() later on
will happily close the epoll fd for. If we want to close all file
descriptors at startup, this must be the very first thing overall.
Can't really write a proper test for this with knownfail that is
removed with the fix, because if we have clustering+include=registry,
the whole clusteredmember environment does not even start up.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
Autobuild-Date(master): Sat Jul 31 16:58:41 UTC 2021 on sn-devel-184
-----------------------------------------------------------------------
Summary of changes:
selftest/target/Samba3.pm | 1 +
source3/printing/samba-bgqd.c | 58 +++++++++++++++++++++++++++++++++++--------
2 files changed, 48 insertions(+), 11 deletions(-)
Changeset truncated at 500 lines:
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index dc1c14e9628..d0ef659da99 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -517,6 +517,7 @@ sub setup_clusteredmember
server signing = on
clustering = yes
ctdbd socket = ${socket}
+ include = registry
dbwrap_tdb_mutexes:* = yes
${require_mutexes}
";
diff --git a/source3/printing/samba-bgqd.c b/source3/printing/samba-bgqd.c
index 4b96fc43092..8ac6ec525b2 100644
--- a/source3/printing/samba-bgqd.c
+++ b/source3/printing/samba-bgqd.c
@@ -195,6 +195,44 @@ static int closeall_except(int *fds, size_t num_fds)
return 0;
}
+static int closeall_except_fd_params(
+ size_t num_fd_params,
+ const char *fd_params[],
+ int argc,
+ const char *argv[])
+{
+ int fds[num_fd_params+3];
+ size_t i;
+ struct poptOption long_options[num_fd_params + 1];
+ poptContext pc;
+ int ret;
+
+ for (i=0; i<num_fd_params; i++) {
+ fds[i] = -1;
+ long_options[i] = (struct poptOption) {
+ .longName = fd_params[i],
+ .argInfo = POPT_ARG_INT,
+ .arg = &fds[i],
+ };
+ }
+ long_options[num_fd_params] = (struct poptOption) { .longName=NULL, };
+
+ fds[num_fd_params] = 0;
+ fds[num_fd_params+1] = 1;
+ fds[num_fd_params+2] = 2;
+
+ pc = poptGetContext(argv[0], argc, argv, long_options, 0);
+
+ while ((ret = poptGetNextOpt(pc)) != -1) {
+ /* do nothing */
+ }
+
+ poptFreeContext(pc);
+
+ ret = closeall_except(fds, ARRAY_SIZE(fds));
+ return ret;
+}
+
int main(int argc, const char *argv[])
{
const struct loadparm_substitution *lp_sub =
@@ -261,6 +299,15 @@ int main(int argc, const char *argv[])
POPT_TABLEEND
};
+ {
+ const char *fd_params[] = {
+ "ready-signal-fd", "parent-watch-fd",
+ };
+
+ closeall_except_fd_params(
+ ARRAY_SIZE(fd_params), fd_params, argc, argv);
+ }
+
frame = talloc_stackframe();
umask(0);
@@ -293,17 +340,6 @@ int main(int argc, const char *argv[])
log_stdout = (debug_get_log_type() == DEBUG_STDOUT);
- {
- int keep[] = { 0, 1, 2, ready_signal_fd, watch_fd };
- ret = closeall_except(keep, ARRAY_SIZE(keep));
- if (ret != 0) {
- fprintf(stderr,
- "Could not close fds: %s\n",
- strerror(ret));
- goto done;
- }
- }
-
if (foreground) {
daemon_status(progname, "Starting process ... ");
} else {
--
Samba Shared Repository
More information about the samba-cvs
mailing list