]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:rpcclient: Use get_cmdline_auth_info_creds()
authorStefan Metzmacher <metze@samba.org>
Sun, 10 Nov 2019 23:44:22 +0000 (00:44 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 28 May 2020 06:43:38 +0000 (06:43 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/rpcclient/rpcclient.c

index 34d5caa61b913bbb39f51c89b6b3d25bfc9a4146..66d77302af3a66e8b35e9c7432850845b739ddf0 100644 (file)
@@ -795,7 +795,11 @@ static NTSTATUS do_cmd(struct cli_state *cli,
        /* Open pipe */
 
        if ((cmd_entry->table != NULL) && (cmd_entry->rpc_pipe == NULL)) {
-               enum credentials_use_kerberos use_kerberos = CRED_AUTO_USE_KERBEROS;
+               struct cli_credentials *creds =
+                       get_cmdline_auth_info_creds(auth_info);
+               enum credentials_use_kerberos krb5_state =
+                       cli_credentials_get_kerberos_state(creds);
+
                switch (pipe_default_auth_type) {
                case DCERPC_AUTH_TYPE_NONE:
                        ntresult = cli_rpc_pipe_open_noauth_transport(
@@ -806,28 +810,29 @@ static NTSTATUS do_cmd(struct cli_state *cli,
                case DCERPC_AUTH_TYPE_SPNEGO:
                        switch (pipe_default_auth_spnego_type) {
                        case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP:
-                               use_kerberos = CRED_DONT_USE_KERBEROS;
+                               krb5_state = CRED_DONT_USE_KERBEROS;
                                break;
                        case PIPE_AUTH_TYPE_SPNEGO_KRB5:
-                               use_kerberos = CRED_MUST_USE_KERBEROS;
+                               krb5_state = CRED_MUST_USE_KERBEROS;
                                break;
                        case PIPE_AUTH_TYPE_SPNEGO_NONE:
-                               use_kerberos = CRED_AUTO_USE_KERBEROS;
+                               krb5_state = CRED_AUTO_USE_KERBEROS;
                                break;
                        }
                        FALL_THROUGH;
                case DCERPC_AUTH_TYPE_NTLMSSP:
                case DCERPC_AUTH_TYPE_KRB5:
-                       ntresult = cli_rpc_pipe_open_generic_auth(
+                       if (krb5_state != CRED_AUTO_USE_KERBEROS) {
+                               cli_credentials_set_kerberos_state(creds,
+                                                                  krb5_state);
+                       }
+                       ntresult = cli_rpc_pipe_open_with_creds(
                                cli, cmd_entry->table,
                                default_transport,
-                               use_kerberos,
                                pipe_default_auth_type,
                                pipe_default_auth_level,
                                smbXcli_conn_remote_name(cli->conn),
-                               get_cmdline_auth_info_domain(auth_info),
-                               get_cmdline_auth_info_username(auth_info),
-                               get_cmdline_auth_info_password(auth_info),
+                               creds,
                                &cmd_entry->rpc_pipe);
                        break;
                case DCERPC_AUTH_TYPE_SCHANNEL:
@@ -1208,14 +1213,10 @@ out_free:
                rpcclient_netlogon_domain = lp_workgroup();
        }
 
-       nt_status = cli_full_connection(&cli, lp_netbios_name(), host,
+       nt_status = cli_full_connection_creds(&cli, lp_netbios_name(), host,
                                        opt_ipaddr ? &server_ss : NULL, opt_port,
                                        "IPC$", "IPC",
-                                       get_cmdline_auth_info_username(
-                                               popt_get_cmdline_auth_info()),
-                                       get_cmdline_auth_info_domain(
-                                               popt_get_cmdline_auth_info()),
-                                       get_cmdline_auth_info_password(
+                                       get_cmdline_auth_info_creds(
                                                popt_get_cmdline_auth_info()),
                                        flags,
                                        SMB_SIGNING_IPC_DEFAULT);
@@ -1227,12 +1228,8 @@ out_free:
        }
 
        if (get_cmdline_auth_info_smb_encrypt(popt_get_cmdline_auth_info())) {
-               nt_status = cli_cm_force_encryption(cli,
-                                       get_cmdline_auth_info_username(
-                                               popt_get_cmdline_auth_info()),
-                                       get_cmdline_auth_info_password(
-                                               popt_get_cmdline_auth_info()),
-                                       get_cmdline_auth_info_domain(
+               nt_status = cli_cm_force_encryption_creds(cli,
+                                       get_cmdline_auth_info_creds(
                                                popt_get_cmdline_auth_info()),
                                        "IPC$");
                if (!NT_STATUS_IS_OK(nt_status)) {