s4-torture: allow host-only in unc lists in smbtorture
[ira/wip.git] / source4 / libcli / cliconnect.c
index 4858a96110b7a46df9b3e99e88edeacdbcad7560..1a5bd607b48b2fedbed6d4adffe98c77418b5d88 100644 (file)
 #include "libcli/raw/raw_proto.h"
 #include "libcli/auth/libcli_auth.h"
 #include "libcli/smb_composite/smb_composite.h"
-#include "param/param.h"
 
 /*
   wrapper around smbcli_sock_connect()
 */
 bool smbcli_socket_connect(struct smbcli_state *cli, const char *server, 
                           const char **ports, 
+                          struct tevent_context *ev_ctx,
                           struct resolve_context *resolve_ctx,
-                          struct smbcli_options *options)
+                          struct smbcli_options *options,
+                          struct smb_iconv_convenience *iconv_convenience,
+               const char *socket_options)
 {
        struct smbcli_socket *sock;
 
-       sock = smbcli_sock_connect_byname(server, ports, NULL, resolve_ctx, 
-                                         NULL);
+       sock = smbcli_sock_connect_byname(server, ports, NULL,
+                                         resolve_ctx, ev_ctx,
+                      socket_options);
 
        if (sock == NULL) return false;
        
-       cli->transport = smbcli_transport_init(sock, cli, true, options);
+       cli->transport = smbcli_transport_init(sock, cli, true, options, 
+                                                                                  iconv_convenience);
        if (!cli->transport) {
                return false;
        }
@@ -68,18 +72,22 @@ NTSTATUS smbcli_negprot(struct smbcli_state *cli, bool unicode, int maxprotocol)
 /* wrapper around smb_raw_sesssetup() */
 NTSTATUS smbcli_session_setup(struct smbcli_state *cli, 
                              struct cli_credentials *credentials,
-                             const char *workgroup)
+                             const char *workgroup,
+                             struct smbcli_session_options options,
+                             struct gensec_settings *gensec_settings)
 {
        struct smb_composite_sesssetup setup;
        NTSTATUS status;
 
-       cli->session = smbcli_session_init(cli->transport, cli, true);
+       cli->session = smbcli_session_init(cli->transport, cli, true,
+                                          options);
        if (!cli->session) return NT_STATUS_UNSUCCESSFUL;
 
        setup.in.sesskey = cli->transport->negotiate.sesskey;
        setup.in.capabilities = cli->transport->negotiate.capabilities;
        setup.in.credentials = credentials;
        setup.in.workgroup = workgroup;
+       setup.in.gensec_settings = gensec_settings;
 
        status = smb_composite_sesssetup(cli->session, &setup);
 
@@ -140,10 +148,14 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
                                const char **ports,
                                const char *sharename,
                                const char *devtype,
+                               const char *socket_options,
                                struct cli_credentials *credentials,
                                struct resolve_context *resolve_ctx,
-                               struct event_context *ev,
-                               struct smbcli_options *options)
+                               struct tevent_context *ev,
+                               struct smbcli_options *options,
+                               struct smbcli_session_options *session_options,
+                               struct smb_iconv_convenience *iconv_convenience,
+                               struct gensec_settings *gensec_settings)
 {
        struct smbcli_tree *tree;
        NTSTATUS status;
@@ -153,8 +165,12 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
        status = smbcli_tree_full_connection(parent_ctx,
                                             &tree, host, ports, 
                                             sharename, devtype,
+                                                socket_options,
                                             credentials, resolve_ctx, ev,
-                                            options);
+                                            options,
+                                            session_options,
+                                                iconv_convenience,
+                                                gensec_settings);
        if (!NT_STATUS_IS_OK(status)) {
                goto done;
        }
@@ -222,13 +238,13 @@ bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
 {
        char *p;
 
-       *hostname = *sharename = NULL;
-
        if (strncmp(unc_name, "\\\\", 2) &&
            strncmp(unc_name, "//", 2)) {
                return false;
        }
 
+       *hostname = *sharename = NULL;
+
        *hostname = talloc_strdup(mem_ctx, &unc_name[2]);
        p = terminate_path_at_separator(*hostname);