]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libsmb_server: make use of SMBC_auth_credentials() in SMBC_attr_server()
authorStefan Metzmacher <metze@samba.org>
Mon, 11 Nov 2019 16:25:47 +0000 (17:25 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 28 May 2020 06:43:39 +0000 (06:43 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libsmb/libsmb_server.c

index f32162e9fda7b1294a9c0a2bad2acb866b0e2163..6069035a1176194d66255b4275e2f940d0b2b18a 100644 (file)
@@ -781,6 +781,7 @@ SMBC_attr_server(TALLOC_CTX *ctx,
         ipc_srv = SMBC_find_server(ctx, context, server, "*IPC$",
                                    pp_workgroup, pp_username, pp_password);
         if (!ipc_srv) {
+               struct cli_credentials *creds = NULL;
                int signing_state = SMB_SIGNING_DEFAULT;
 
                 /* We didn't find a cached connection.  Get the password */
@@ -797,38 +798,41 @@ SMBC_attr_server(TALLOC_CTX *ctx,
                 }
 
                 flags = 0;
-                if (smbc_getOptionUseKerberos(context)) {
-                        flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
-                }
-                if (smbc_getOptionUseCCache(context)) {
-                        flags |= CLI_FULL_CONNECTION_USE_CCACHE;
-                }
+
+               creds = SMBC_auth_credentials(NULL,
+                                             context,
+                                             *pp_workgroup,
+                                             *pp_username,
+                                             *pp_password);
+               if (creds == NULL) {
+                       errno = ENOMEM;
+                       return NULL;
+               }
+
                if (context->internal->smb_encryption_level != SMBC_ENCRYPTLEVEL_NONE) {
                        signing_state = SMB_SIGNING_REQUIRED;
                }
 
-                nt_status = cli_full_connection(&ipc_cli,
+               nt_status = cli_full_connection_creds(&ipc_cli,
                                                lp_netbios_name(), server,
                                                NULL, 0, "IPC$", "?????",
-                                               *pp_username,
-                                               *pp_workgroup,
-                                               *pp_password,
+                                               creds,
                                                flags,
                                                signing_state);
                 if (! NT_STATUS_IS_OK(nt_status)) {
+                       TALLOC_FREE(creds);
                         DEBUG(1,("cli_full_connection failed! (%s)\n",
                                  nt_errstr(nt_status)));
                         errno = ENOTSUP;
                         return NULL;
                 }
+               talloc_steal(ipc_cli, creds);
 
                if (context->internal->smb_encryption_level) {
                        /* Attempt encryption. */
-                       nt_status = cli_cm_force_encryption(ipc_cli,
-                                                           *pp_username,
-                                                           *pp_password,
-                                                           *pp_workgroup,
-                                                           "IPC$");
+                       nt_status = cli_cm_force_encryption_creds(ipc_cli,
+                                                                 creds,
+                                                                 "IPC$");
                        if (!NT_STATUS_IS_OK(nt_status)) {
 
                                /*