s3:utils: Fix setting the debug level
authorAndreas Schneider <asn@samba.org>
Wed, 6 Dec 2023 07:48:34 +0000 (08:48 +0100)
committerJule Anger <janger@samba.org>
Tue, 12 Dec 2023 09:02:18 +0000 (09:02 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15525

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 763b2efe69dc74e1c0cd954607031012f832486d)

source3/utils/smbget.c

index 5c99dcf918a3eb426d28c5ed1a4a6036da4c7202..8d98ba24602cfb9bd6b470d1b4b845918526b475 100644 (file)
@@ -849,6 +849,7 @@ int main(int argc, char **argv)
        uint32_t gensec_features;
        bool use_wbccache = false;
        SMBCCTX *smb_ctx = NULL;
+       int dbg_lvl = -1;
        int rc;
 
        smb_init_locale();
@@ -922,13 +923,16 @@ int main(int argc, char **argv)
 
        samba_cmdline_burn(argc, argv);
 
+       /* smbc_new_context() will set the log level to 0 */
+       dbg_lvl = debuglevel_get();
+
        smb_ctx = smbc_new_context();
        if (smb_ctx == NULL) {
                fprintf(stderr, "Unable to initialize libsmbclient\n");
                ok = false;
                goto done;
        }
-       smbc_setDebug(smb_ctx, debuglevel_get());
+       smbc_setDebug(smb_ctx, dbg_lvl);
 
        rc = smbc_setConfiguration(smb_ctx, lp_default_path());
        if (rc < 0) {