From: Ralph Boehme Date: Fri, 3 Sep 2021 05:28:45 +0000 (+0200) Subject: lib/cmdline: restore pre-4.15 logging behaviour for daemons X-Git-Tag: ldb-2.5.0~774 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=877183ac0b57f5b2902446e41bb6ab3191f84fa6;p=thirdparty%2Fsamba.git lib/cmdline: restore pre-4.15 logging behaviour for daemons For servers ensure logging is configured to go to a logfile unless in interactive mode by calling setup_logging() before lp_load_global() is called. In 4.14 servers had the chance to call setup_logging(getprogname(), DEBUG_FILE) before they called lp_load_*() explicitly in the server. Now in 4.15 lp_load_*() is called internally when parsing the command line arguments triggered by the server running the poptGetNextOpt() loop, so it's too late when the server calls setup_logging(getprogname(), DEBUG_FILE) as lots of debugging from lp_load_()* was already written to DEBUG_DEFAULT_STDERR. Note that there's a chicken and egg problem *within* this patchset: this change here breaks stdout logging for servers until the servers are converted to use the new POPT_COMMON_DAEMON. The only way to address that would be squashing all changes into one patchset, but for the sake of reviewability (is that an actual english word? :)) I chose to split the changes. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14803 Signed-off-by: Ralph Boehme Reviewed-by: Volker Lendecke --- diff --git a/lib/cmdline/cmdline_s3.c b/lib/cmdline/cmdline_s3.c index 70fd768a648..1f8d9ed5eb5 100644 --- a/lib/cmdline/cmdline_s3.c +++ b/lib/cmdline/cmdline_s3.c @@ -55,10 +55,19 @@ static bool _samba_cmdline_load_config_s3(void) case SAMBA_CMDLINE_CONFIG_CLIENT: ok = lp_load_client(config_file); break; - case SAMBA_CMDLINE_CONFIG_SERVER: + case SAMBA_CMDLINE_CONFIG_SERVER: + { + const struct samba_cmdline_daemon_cfg *cmdline_daemon_cfg = + samba_cmdline_get_daemon_cfg(); + + if (!cmdline_daemon_cfg->interactive) { + setup_logging(getprogname(), DEBUG_FILE); + } + ok = lp_load_global(config_file); break; } + } if (!ok) { fprintf(stderr,