lib/cmdline: restore pre-4.15 logging behaviour for daemons
authorRalph Boehme <slow@samba.org>
Fri, 3 Sep 2021 05:28:45 +0000 (07:28 +0200)
committerRalph Boehme <slow@samba.org>
Mon, 6 Sep 2021 13:26:35 +0000 (13:26 +0000)
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 <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
lib/cmdline/cmdline_s3.c

index 70fd768a648d28dca2d54db55e10f05550e3e51b..1f8d9ed5eb502a140a5434bb0873f33f47af2442 100644 (file)
@@ -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,