lib/debug: fix fd check before dup'ing to stderr
authorRalph Boehme <slow@samba.org>
Wed, 10 Nov 2021 13:13:11 +0000 (14:13 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 11 Nov 2021 13:49:32 +0000 (13:49 +0000)
commit948a82bd2651e73e4e669a89dc77ba93abbb9b2f
tree5251e033c6da4723da14f442326e8cc5872ae282
parent117d45df47a1f3206bc38aaeaa11f2b327e43530
lib/debug: fix fd check before dup'ing to stderr

Before I added per-class logfile and we had only one fd for the logfile the code
looked like this:

        /* Take over stderr to catch output into logs */
        if (state.fd > 0) {
                if (dup2(state.fd, 2) == -1) {
                        /* Close stderr too, if dup2 can't point it -
                           at the logfile.  There really isn't much
                           that can be done on such a fundamental
                           failure... */
                        close_low_fd(2);
                }
        }

In the current code the equivalent to state.fd is dbgc_config[DBGC_ALL].fd.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/util/debug.c