s3-librpc Make cli_rpc_pipe_open_spnego_ntlmssp() generic
[metze/samba/wip.git] / source3 / rpcclient / rpcclient.c
index c2f3e4c917ce93aa0c586e380850e39b06080256..39b54bf0524ab8674704f2ffac7acd0f76a35e7e 100644 (file)
@@ -31,6 +31,7 @@
 #include "../libcli/security/security.h"
 #include "passdb.h"
 #include "libsmb/libsmb.h"
+#include "auth/gensec/gensec.h"
 
 enum pipe_auth_type_spnego {
        PIPE_AUTH_TYPE_SPNEGO_NONE = 0,
@@ -240,7 +241,7 @@ static NTSTATUS cmd_listcommands(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ct
        {
                tmp_set = tmp->cmd_set;
 
-               if (!StrCaseCmp(argv[1], tmp_set->name))
+               if (!strcasecmp_m(argv[1], tmp_set->name))
                {
                        printf("Available commands on the %s pipe:\n\n", tmp_set->name);
 
@@ -690,55 +691,48 @@ static NTSTATUS do_cmd(struct cli_state *cli,
                                &cmd_entry->rpc_pipe);
                        break;
                case DCERPC_AUTH_TYPE_SPNEGO:
+               {
+                       /* won't happen, but if it does it will fail in cli_rpc_pipe_open_spnego() eventually */
+                       const char *oid = "INVALID";
                        switch (pipe_default_auth_spnego_type) {
                        case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP:
-                               ntresult = cli_rpc_pipe_open_spnego_ntlmssp(
-                                               cli, cmd_entry->interface,
-                                               default_transport,
-                                               pipe_default_auth_level,
-                                               get_cmdline_auth_info_domain(auth_info),
-                                               get_cmdline_auth_info_username(auth_info),
-                                               get_cmdline_auth_info_password(auth_info),
-                                               &cmd_entry->rpc_pipe);
+                               oid = GENSEC_OID_NTLMSSP;
                                break;
                        case PIPE_AUTH_TYPE_SPNEGO_KRB5:
-                               ntresult = cli_rpc_pipe_open_spnego_krb5(
-                                               cli, cmd_entry->interface,
-                                               default_transport,
-                                               pipe_default_auth_level,
-                                               cli->desthost,
-                                               NULL, NULL,
-                                               &cmd_entry->rpc_pipe);
+                               oid = GENSEC_OID_KERBEROS5;
                                break;
-                       default:
-                               ntresult = NT_STATUS_INTERNAL_ERROR;
                        }
-                       break;
-               case DCERPC_AUTH_TYPE_NTLMSSP:
-                       ntresult = cli_rpc_pipe_open_ntlmssp(
+                       ntresult = cli_rpc_pipe_open_spnego(
                                cli, cmd_entry->interface,
                                default_transport,
+                               oid,
                                pipe_default_auth_level,
+                               cli_state_remote_name(cli),
                                get_cmdline_auth_info_domain(auth_info),
                                get_cmdline_auth_info_username(auth_info),
                                get_cmdline_auth_info_password(auth_info),
                                &cmd_entry->rpc_pipe);
                        break;
-               case DCERPC_AUTH_TYPE_SCHANNEL:
-                       ntresult = cli_rpc_pipe_open_schannel(
+               }
+               case DCERPC_AUTH_TYPE_NTLMSSP:
+               case DCERPC_AUTH_TYPE_KRB5:
+                       ntresult = cli_rpc_pipe_open_generic_auth(
                                cli, cmd_entry->interface,
                                default_transport,
+                               pipe_default_auth_type,
                                pipe_default_auth_level,
+                               cli_state_remote_name(cli),
                                get_cmdline_auth_info_domain(auth_info),
+                               get_cmdline_auth_info_username(auth_info),
+                               get_cmdline_auth_info_password(auth_info),
                                &cmd_entry->rpc_pipe);
                        break;
-               case DCERPC_AUTH_TYPE_KRB5:
-                       ntresult = cli_rpc_pipe_open_krb5(
+               case DCERPC_AUTH_TYPE_SCHANNEL:
+                       ntresult = cli_rpc_pipe_open_schannel(
                                cli, cmd_entry->interface,
                                default_transport,
                                pipe_default_auth_level,
-                               cli->desthost,
-                               NULL, NULL,
+                               get_cmdline_auth_info_domain(auth_info),
                                &cmd_entry->rpc_pipe);
                        break;
                default:
@@ -773,9 +767,9 @@ static NTSTATUS do_cmd(struct cli_state *cli,
                        }
 
                        ntresult = rpccli_netlogon_setup_creds(cmd_entry->rpc_pipe,
-                                               cli->desthost,   /* server name */
+                                               cmd_entry->rpc_pipe->desthost,   /* server name */
                                                get_cmdline_auth_info_domain(auth_info),  /* domain */
-                                               global_myname(), /* client name */
+                                               lp_netbios_name(), /* client name */
                                                machine_account, /* machine account name */
                                                trust_password,
                                                sec_channel_type,
@@ -892,7 +886,6 @@ out_free:
        struct sockaddr_storage server_ss;
        NTSTATUS                nt_status;
        static int              opt_port = 0;
-       fstring new_workgroup;
        int result = 0;
        TALLOC_CTX *frame = talloc_stackframe();
        uint32_t flags = 0;
@@ -975,22 +968,11 @@ out_free:
                goto done;
        }
 
-       /* save the workgroup...
-
-          FIXME!! do we need to do this for other options as well
-          (or maybe a generic way to keep lp_load() from overwriting
-          everything)?  */
-
-       fstrcpy( new_workgroup, lp_workgroup() );
-
        /* Load smb.conf file */
 
-       if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True))
+       if (!lp_load_global(get_dyn_CONFIGFILE()))
                fprintf(stderr, "Can't load %s\n", get_dyn_CONFIGFILE());
 
-       if ( strlen(new_workgroup) != 0 )
-               set_global_myworkgroup( new_workgroup );
-
        /*
         * Get password
         * from stdin if necessary
@@ -1091,7 +1073,7 @@ out_free:
        }
 
 
-       nt_status = cli_full_connection(&cli, global_myname(), binding->host,
+       nt_status = cli_full_connection(&cli, lp_netbios_name(), binding->host,
                                        opt_ipaddr ? &server_ss : NULL, opt_port,
                                        "IPC$", "IPC",
                                        get_cmdline_auth_info_username(rpcclient_auth_info),