From: Stefan Metzmacher Date: Mon, 11 Nov 2019 14:18:11 +0000 (+0100) Subject: s3:net: make use of net_context_creds() in connect_to_service() X-Git-Tag: ldb-2.2.0~300 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7c366f1f8d8f2f1547d64801db6a49674570c6d;p=thirdparty%2Fsamba.git s3:net: make use of net_context_creds() in connect_to_service() Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c index 77bce564b13..c566ecc9000 100644 --- a/source3/utils/net_util.c +++ b/source3/utils/net_util.c @@ -108,32 +108,23 @@ NTSTATUS connect_to_service(struct net_context *c, const char *service_type) { NTSTATUS nt_status; - int flags = 0; enum smb_signing_setting signing_setting = SMB_SIGNING_DEFAULT; + struct cli_credentials *creds = NULL; - c->opt_password = net_prompt_pass(c, c->opt_user_name); - - if (c->opt_kerberos) { - flags |= CLI_FULL_CONNECTION_USE_KERBEROS; - } - - if (c->opt_kerberos && c->opt_password) { - flags |= CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS; - } - - if (c->opt_ccache) { - flags |= CLI_FULL_CONNECTION_USE_CCACHE; + creds = net_context_creds(c, c); + if (creds == NULL) { + d_fprintf(stderr, "net_context_creds() failed.\n"); + return NT_STATUS_INTERNAL_ERROR; } if (strequal(service_type, "IPC")) { signing_setting = SMB_SIGNING_IPC_DEFAULT; } - nt_status = cli_full_connection(cli_ctx, NULL, server_name, + nt_status = cli_full_connection_creds(cli_ctx, NULL, server_name, server_ss, c->opt_port, service_name, service_type, - c->opt_user_name, c->opt_workgroup, - c->opt_password, flags, + creds, 0, signing_setting); if (!NT_STATUS_IS_OK(nt_status)) { d_fprintf(stderr, _("Could not connect to server %s\n"), @@ -158,11 +149,9 @@ NTSTATUS connect_to_service(struct net_context *c, } if (c->smb_encrypt) { - nt_status = cli_cm_force_encryption(*cli_ctx, - c->opt_user_name, - c->opt_password, - c->opt_workgroup, - service_name); + nt_status = cli_cm_force_encryption_creds(*cli_ctx, + creds, + service_name); if (!NT_STATUS_IS_OK(nt_status)) { cli_shutdown(*cli_ctx); *cli_ctx = NULL;