From: Pavel Kalugin Date: Sun, 3 Sep 2023 20:21:35 +0000 (+0300) Subject: s3:libsmb: Use lpcfg_set_cmdline() X-Git-Tag: tevent-0.16.0~548 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7a06f3a5db2694b0bb3f44b019a70e595e6a8af;p=thirdparty%2Fsamba.git s3:libsmb: Use lpcfg_set_cmdline() Signed-off-by: Pavel Kalugin Reviewed-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index 5588f9df66a..6ca265ad38a 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -254,7 +254,9 @@ struct SMBC_internal_data { } smb; uint16_t port; -}; + + struct loadparm_context *lp_ctx; +}; /* Functions in libsmb_cache.c */ int diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c index 783889a952d..a4c4c84a831 100644 --- a/source3/libsmb/libsmb_context.c +++ b/source3/libsmb/libsmb_context.c @@ -169,6 +169,16 @@ smbc_new_context(void) /* Initialize the context and establish reasonable defaults */ ZERO_STRUCTP(context->internal); + context->internal->lp_ctx = loadparm_init_s3(NULL, + loadparm_s3_helpers()); + if (context->internal->lp_ctx == NULL) { + SAFE_FREE(context->internal); + SAFE_FREE(context); + TALLOC_FREE(frame); + errno = ENOMEM; + return NULL; + } + smbc_setDebug(context, 0); smbc_setTimeout(context, 20000); smbc_setPort(context, 0); @@ -324,6 +334,7 @@ smbc_free_context(SMBCCTX *context, /* Free any DFS auth context. */ TALLOC_FREE(context->internal->creds); + TALLOC_FREE(context->internal->lp_ctx); SAFE_FREE(context->internal); SAFE_FREE(context); @@ -737,7 +748,6 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context, const char *user, const char *password) { - struct loadparm_context *lp_ctx = NULL; struct cli_credentials *creds = NULL; enum credentials_use_kerberos kerberos_state = CRED_USE_KERBEROS_DISABLED; @@ -765,13 +775,7 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context, return; } - lp_ctx = loadparm_init_s3(creds, loadparm_s3_helpers()); - if (lp_ctx == NULL) { - TALLOC_FREE(creds); - return; - } - - cli_credentials_set_conf(creds, lp_ctx); + cli_credentials_set_conf(creds, context->internal->lp_ctx); if (smbc_getOptionUseKerberos(context)) { kerberos_state = CRED_USE_KERBEROS_REQUIRED; diff --git a/source3/libsmb/libsmb_setget.c b/source3/libsmb/libsmb_setget.c index 9a8ef97f9fe..2d7717e40c2 100644 --- a/source3/libsmb/libsmb_setget.c +++ b/source3/libsmb/libsmb_setget.c @@ -26,6 +26,7 @@ #define __LIBSMBCLIENT_INTERNAL__ #include "libsmbclient.h" #include "libsmb_internal.h" +#include "lib/param/param.h" /** Get the netbios name used for making connections */ @@ -94,7 +95,7 @@ smbc_setDebug(SMBCCTX *c, int debug) TALLOC_CTX *frame = talloc_stackframe(); snprintf(buf, sizeof(buf), "%d", debug); c->debug = debug; - lp_set_cmdline("log level", buf); + lpcfg_set_cmdline(c->internal->lp_ctx, "log level", buf); TALLOC_FREE(frame); } @@ -534,11 +535,15 @@ smbc_setOptionProtocols(SMBCCTX *c, bool ok = true; if (min_proto != NULL) { - ok = lp_set_cmdline("client min protocol", min_proto); + ok = lpcfg_set_cmdline(c->internal->lp_ctx, + "client min protocol", + min_proto); } if (max_proto != NULL) { - ok &= lp_set_cmdline("client max protocol", max_proto); + ok &= lpcfg_set_cmdline(c->internal->lp_ctx, + "client max protocol", + max_proto); } return ok;