r4758: - added async support to the session request code
authorAndrew Tridgell <tridge@samba.org>
Sat, 15 Jan 2005 11:58:52 +0000 (11:58 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:08:50 +0000 (13:08 -0500)
- added async support to the negprot client code

- removed two unused parameters from smbcli_full_connection() code

- converted smbclient to use smbcli_full_connection() rather than
  reinventing everything itself

16 files changed:
source/auth/auth_domain.c
source/client/client.c
source/client/smbspool.c
source/libcli/cliconnect.c
source/libcli/raw/clisession.c
source/libcli/raw/clitransport.c
source/libcli/raw/clitree.c
source/libcli/raw/rawnegotiate.c
source/librpc/rpc/dcerpc_util.c
source/rpc_server/dcerpc_server.c
source/torture/gentest.c
source/torture/locktest.c
source/torture/locktest2.c
source/torture/masktest.c
source/torture/rpc/xplogin.c
source/torture/torture.c

index 2452f8f65d55117f194bf5c490dbeae10801f5e7..a1868e1b138d49d22e8cfd3aef14ea52e7eb9cd9 100644 (file)
@@ -170,7 +170,7 @@ static NTSTATUS connect_to_domain_password_server(struct smbcli_state **cli,
        
        /* Attempt connection */
        result = smbcli_full_connection(NULL, cli, lp_netbios_name(), remote_machine,
-                                    &dest_ip, 0, "IPC$", "IPC", "", "", "",0, retry);
+                                       0, "IPC$", NULL, "", "", "");
 
        if (!NT_STATUS_IS_OK(result)) {
                release_server_mutex();
index b2255fc7b85a6e27c8b805c78d0401ab6a50b803..6449781b3f0f6b927a632c5064fea3cdb734c982 100644 (file)
@@ -3045,86 +3045,21 @@ return a connection to a server
 static struct smbcli_state *do_connect(const char *server, const char *share)
 {
        struct smbcli_state *c;
-       struct nmb_name called, calling;
-       const char *server_n;
-       fstring servicename;
-       char *sharename;
        NTSTATUS status;
-       
-       /* make a copy so we don't modify the global string 'service' */
-       fstrcpy(servicename, share);
-       sharename = servicename;
-       if (*sharename == '\\') {
-               server = sharename+2;
-               sharename = strchr_m(server,'\\');
-               if (!sharename) return NULL;
-               *sharename = 0;
-               sharename++;
-       }
-
-       asprintf(&sharename, "\\\\%s\\%s", server, sharename);
 
-       server_n = dest_ip?dest_ip:server;
-       
-       make_nmb_name(&calling, lp_netbios_name(), 0x0);
-       choose_called_name(&called, server, name_type);
-
- again:
-       /* have to open a new connection */
-       if (!(c=smbcli_state_init(NULL)) || !smbcli_socket_connect(c, server_n)) {
-               d_printf("Connection to %s failed\n", server_n);
-               return NULL;
-       }
-
-       if (!smbcli_transport_establish(c, &calling, &called)) {
-               char *p;
-               d_printf("session request to %s failed\n", 
-                        called.name);
-               smbcli_shutdown(c);
-               if ((p=strchr_m(called.name, '.'))) {
-                       *p = 0;
-                       goto again;
-               }
-               if (strcmp(called.name, "*SMBSERVER")) {
-                       make_nmb_name(&called , "*SMBSERVER", 0x20);
-                       goto again;
-               }
-               return NULL;
+       if (strncmp(share, "\\\\", 2) == 0 ||
+           strncmp(share, "//", 2) == 0) {
+               smbcli_parse_unc(share, NULL, &server, &share);
        }
-
-       DEBUG(4,(" session request ok\n"));
-
-       if (NT_STATUS_IS_ERR(smbcli_negprot(c))) {
-               d_printf("protocol negotiation failed\n");
-               smbcli_shutdown(c);
-               return NULL;
-       }
-
-       status = smbcli_session_setup(c, username, password, domain);
-       if (NT_STATUS_IS_ERR(status)) {
-               d_printf("authenticated session setup failed: %s\n", nt_errstr(status));
-               /* if a password was not supplied then try again with a null username */
-               if (password[0] || !username[0]) {
-                       status = smbcli_session_setup(c, "", "", lp_workgroup());
-               }
-               if (NT_STATUS_IS_ERR(status)) {
-                       d_printf("session setup failed: %s\n", nt_errstr(status));
-                       smbcli_shutdown(c);
-                       return NULL;
-               }
-               d_printf("Anonymous login successful\n");
-       }
-
-       DEBUG(4,(" session setup ok\n"));
-
-       if (NT_STATUS_IS_ERR(smbcli_send_tconX(c, sharename, "?????", password))) {
-               d_printf("tree connect failed: %s\n", smbcli_errstr(c->tree));
-               smbcli_shutdown(c);
+       
+       status = smbcli_full_connection(NULL, &c, lp_netbios_name(), server,
+                                       share, NULL, username, domain, password);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("Connection to \\\\%s\\%s failed - %s\n", 
+                        server, share, nt_errstr(status));
                return NULL;
        }
 
-       DEBUG(4,(" tconx ok\n"));
-
        return c;
 }
 
index e81453a23b45b92c8572fde02408298ed84cf06c..620e4b301c1ac6c9f91cf6a97beea44e1e5119f1 100644 (file)
@@ -279,8 +279,8 @@ smb_connect(const char *workgroup,          /* I - Workgroup */
 
   myname = get_myname();  
        
-  nt_status = smbcli_full_connection(NULL, &c, myname, server, NULL, 0, share, "?????", 
-                                 username, workgroup, password, 0, NULL);
+  nt_status = smbcli_full_connection(NULL, &c, myname, server, 0, share, NULL,
+                                    username, workgroup, password);
   
   free(myname);
   if (!NT_STATUS_IS_OK(nt_status)) {
index a0ba5ae0a1a7ffdd88be6664ae7cf4c26059b368..4d46d1d23c7cdca7bc8269abebc66a2b402ef7b0 100644 (file)
@@ -57,7 +57,7 @@ BOOL smbcli_transport_establish(struct smbcli_state *cli,
 /* wrapper around smb_raw_negotiate() */
 NTSTATUS smbcli_negprot(struct smbcli_state *cli)
 {
-       return smb_raw_negotiate(cli->transport);
+       return smb_raw_negotiate(cli->transport, lp_maxprotocol());
 }
 
 /* wrapper around smb_raw_session_setup() */
@@ -155,14 +155,11 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
                                struct smbcli_state **ret_cli, 
                                const char *myname,
                                const char *host,
-                               struct ipv4_addr *ip,
                                const char *sharename,
                                const char *devtype,
                                const char *username,
                                const char *domain,
-                               const char *password,
-                               uint_t flags,
-                               BOOL *retry)
+                               const char *password)
 {
        struct smbcli_tree *tree;
        NTSTATUS status;
@@ -231,3 +228,31 @@ void smbcli_shutdown(struct smbcli_state *cli)
 {
        talloc_free(cli);
 }
+
+/*
+  parse a //server/share type UNC name
+*/
+BOOL smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
+                     const char **hostname, const char **sharename)
+{
+       char *p;
+
+       if (strncmp(unc_name, "\\\\", 2) &&
+           strncmp(unc_name, "//", 2)) {
+               return False;
+       }
+
+       *hostname = talloc_strdup(mem_ctx, &unc_name[2]);
+       p = strchr_m(&(*hostname)[2],'/');
+       if (!p) {
+               p = strchr_m(&(*hostname)[2],'\\');
+               if (!p) return False;
+       }
+       *p = 0;
+       *sharename = talloc_strdup(mem_ctx, p+1);
+
+       return True;
+}
+
+
+
index dcc0c8adbeeb9e9350e169a21a0c78b3d3ae3984..322d27688e357571876d3794eb5f53a3b67b8343 100644 (file)
@@ -38,16 +38,14 @@ struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport)
        uint16_t flags2;
        uint32_t capabilities;
 
-       session = talloc_p(transport, struct smbcli_session);
+       session = talloc_zero(transport, struct smbcli_session);
        if (!session) {
                return NULL;
        }
 
-       ZERO_STRUCTP(session);
        session->transport = talloc_reference(session, transport);
        session->pid = (uint16_t)getpid();
        session->vuid = UID_FIELD_INVALID;
-
        
        capabilities = transport->negotiate.capabilities;
 
index 855543d670371b5c98d97b1dd2e156a24535302c..fc9de577ee57a4a3392516f1cadfe3eb9f871619 100644 (file)
@@ -140,12 +140,12 @@ static void smbcli_transport_write_disable(struct smbcli_transport *transport)
        transport->socket->event.fde->flags &= ~EVENT_FD_WRITE;
 }
 
-/****************************************************************************
-send a session request (if appropriate)
-****************************************************************************/
-BOOL smbcli_transport_connect(struct smbcli_transport *transport,
-                          struct nmb_name *calling, 
-                          struct nmb_name *called)
+/*
+  send a session request
+*/
+struct smbcli_request *smbcli_transport_connect_send(struct smbcli_transport *transport,
+                                                    struct nmb_name *calling, 
+                                                    struct nmb_name *called)
 {
        uint8_t *p;
        int len = NBT_HDR_SIZE;
@@ -155,13 +155,10 @@ BOOL smbcli_transport_connect(struct smbcli_transport *transport,
                transport->called = *called;
        }
 
-       /* 445 doesn't have session request */
-       if (transport->socket->port == 445) {
-               return True;
-       }
-
        /* allocate output buffer */
-       req = smbcli_request_setup_nonsmb(transport, NBT_HDR_SIZE + 2*nbt_mangled_name_len());
+       req = smbcli_request_setup_nonsmb(transport, 
+                                         NBT_HDR_SIZE + 2*nbt_mangled_name_len());
+       if (req == NULL) return NULL;
 
        /* put in the destination name */
        p = req->out.buffer + NBT_HDR_SIZE;
@@ -176,15 +173,27 @@ BOOL smbcli_transport_connect(struct smbcli_transport *transport,
        _smb_setlen(req->out.buffer,len-4);
        SCVAL(req->out.buffer,0,0x81);
 
-       if (!smbcli_request_send(req) ||
-           !smbcli_request_receive(req)) {
+       if (!smbcli_request_send(req)) {
+               smbcli_request_destroy(req);
+               return NULL;
+       }
+
+       return req;
+}
+
+/*
+  finish a smbcli_transport_connect()
+*/
+BOOL smbcli_transport_connect_recv(struct smbcli_request *req)
+{
+       if (!smbcli_request_receive(req)) {
                smbcli_request_destroy(req);
                return False;
        }
-       
+
        if (CVAL(req->in.buffer,0) != 0x82) {
-               transport->error.etype = ETYPE_NBT;
-               transport->error.e.nbt_error = CVAL(req->in.buffer,4);
+               req->transport->error.etype = ETYPE_NBT;
+               req->transport->error.e.nbt_error = CVAL(req->in.buffer,4);
                smbcli_request_destroy(req);
                return False;
        }
@@ -194,6 +203,24 @@ BOOL smbcli_transport_connect(struct smbcli_transport *transport,
 }
 
 
+/*
+  send a session request (if needed)
+*/
+BOOL smbcli_transport_connect(struct smbcli_transport *transport,
+                             struct nmb_name *calling, 
+                             struct nmb_name *called)
+{
+       struct smbcli_request *req;
+       
+       if (transport->socket->port == 445) {
+               return True;
+       }
+
+       req = smbcli_transport_connect_send(transport, 
+                                           calling, called);
+       return smbcli_transport_connect_recv(req);
+}
+
 /****************************************************************************
 get next mid in sequence
 ****************************************************************************/
index 0f56c0fe2e7fb50bdce6d99a5aa7693e24f46681..cc7fefd084e82e0021b964a5295684dcb0287618 100644 (file)
@@ -34,12 +34,11 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session)
 {
        struct smbcli_tree *tree;
 
-       tree = talloc_p(session, struct smbcli_tree);
+       tree = talloc_zero(session, struct smbcli_tree);
        if (!tree) {
                return NULL;
        }
 
-       ZERO_STRUCTP(tree);
        tree->session = talloc_reference(tree, session);
 
        return tree;
@@ -48,7 +47,8 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session)
 /****************************************************************************
  Send a tconX (async send)
 ****************************************************************************/
-struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb_tcon *parms)
+struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, 
+                                            union smb_tcon *parms)
 {
        struct smbcli_request *req = NULL;
 
@@ -83,7 +83,8 @@ struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb
 /****************************************************************************
  Send a tconX (async recv)
 ****************************************************************************/
-NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_tcon *parms)
+NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, 
+                              union smb_tcon *parms)
 {
        uint8_t *p;
 
@@ -124,7 +125,8 @@ failed:
 /****************************************************************************
  Send a tconX (sync interface)
 ****************************************************************************/
-NTSTATUS smb_tree_connect(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms)
+NTSTATUS smb_tree_connect(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, 
+                         union smb_tcon *parms)
 {
        struct smbcli_request *req = smb_tree_connect_send(tree, parms);
        return smb_tree_connect_recv(req, mem_ctx, parms);
@@ -203,7 +205,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
 
 
        /* negotiate protocol options with the server */
-       status = smb_raw_negotiate(transport);
+       status = smb_raw_negotiate(transport, lp_maxprotocol());
        if (!NT_STATUS_IS_OK(status)) {
                talloc_free(transport);
                return status;
index a8cf603d46f9b879121a43af633aeada2fdd2889..d2d6b66d5970aca94a5038a3d061e708111c8fba 100644 (file)
@@ -1,7 +1,9 @@
 /* 
    Unix SMB/CIFS implementation.
+
    SMB client negotiate context management functions
-   Copyright (C) Andrew Tridgell 1994-1998
+
+   Copyright (C) Andrew Tridgell 1994-2005
    Copyright (C) James Myers 2003 <myersjj@samba.org>
    
    This program is free software; you can redistribute it and/or modify
@@ -40,10 +42,11 @@ static const struct {
        {PROTOCOL_NT1,"NT LM 0.12"},
 };
 
-/****************************************************************************
- Send a negprot command.
-****************************************************************************/
-struct smbcli_request *smb_negprot_send(struct smbcli_transport *transport, int maxprotocol)
+/*
+  Send a negprot command.
+*/
+struct smbcli_request *smb_raw_negotiate_send(struct smbcli_transport *transport, 
+                                             int maxprotocol)
 {
        struct smbcli_request *req;
        int i;
@@ -82,19 +85,14 @@ struct smbcli_request *smb_negprot_send(struct smbcli_transport *transport, int
        return req;
 }
 
-/****************************************************************************
+/*
  Send a negprot command.
-****************************************************************************/
-NTSTATUS smb_raw_negotiate(struct smbcli_transport *transport) 
+*/
+NTSTATUS smb_raw_negotiate_recv(struct smbcli_request *req)
 {
-       struct smbcli_request *req;
+       struct smbcli_transport *transport = req->transport;
        int protocol;
 
-       req = smb_negprot_send(transport, lp_maxprotocol());
-       if (!req) {
-               return NT_STATUS_UNSUCCESSFUL;
-       }
-
        if (!smbcli_request_receive(req) ||
            smbcli_request_is_error(req)) {
                return smbcli_request_destroy(req);
@@ -183,3 +181,13 @@ NTSTATUS smb_raw_negotiate(struct smbcli_transport *transport)
 failed:
        return smbcli_request_destroy(req);
 }
+
+
+/*
+ Send a negprot command (sync interface)
+*/
+NTSTATUS smb_raw_negotiate(struct smbcli_transport *transport, int maxprotocol)
+{
+       struct smbcli_request *req = smb_raw_negotiate_send(transport, maxprotocol);
+       return smb_raw_negotiate_recv(req);
+}
index b815f5317dd11f48871554dc0ed39170333e7567..8b974df0fdc163afe459077acfc810428a6116d2 100644 (file)
@@ -827,7 +827,6 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(struct dcerpc_pipe **pp,
 {
        struct dcerpc_pipe *p;
        NTSTATUS status;
-       BOOL retry;
        struct smbcli_state *cli;
        const char *pipe_name = NULL;
        TALLOC_CTX *tmp_ctx;
@@ -866,15 +865,15 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(struct dcerpc_pipe **pp,
        if (!username || !username[0] || 
            (binding->flags & DCERPC_SCHANNEL_ANY)) {
                status = smbcli_full_connection(p->conn, &cli, lp_netbios_name(),
-                                               binding->host, NULL, 
-                                               "ipc$", "?????"
-                                               "", "", NULL, 0, &retry);
+                                               binding->host, 
+                                               "ipc$", NULL
+                                               "", "", NULL);
        } else {
                status = smbcli_full_connection(p->conn, &cli, lp_netbios_name(),
-                                               binding->host, NULL, 
-                                               "ipc$", "?????", 
+                                               binding->host, 
+                                               "ipc$", NULL,
                                                username, domain,
-                                               password, 0, &retry);
+                                               password);
        }
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Failed to connect to %s - %s\n", binding->host, nt_errstr(status)));
index 1fcd9a326127924e103b1ff5a9c90e83df63c2cd..40335e42463b744221c9dfa2f4985294748f8a22 100644 (file)
@@ -1172,8 +1172,6 @@ static NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx, const char **endpoint_s
        struct dcesrv_context *dce_ctx;
        int i;
 
-       DEBUG(1,("dcesrv_init\n"));
-
        if (!endpoint_servers) {
                DEBUG(0,("dcesrv_init_context: no endpoint servers configured\n"));
                return NT_STATUS_INTERNAL_ERROR;
index 81e2a59f345f095fdc070b2fd9d8c638ce66215e..46514a6a43f7b780ac4a066b1613ee72d2739f1a 100644 (file)
@@ -177,11 +177,12 @@ static BOOL connect_servers(void)
                               servers[i].server_name, servers[i].share_name, 
                               servers[i].username, j);
                        status = smbcli_full_connection(NULL, &servers[i].cli[j],
-                                                    "gentest",
-                                                    servers[i].server_name, NULL, 
-                                                    servers[i].share_name, "?????", 
-                                                    servers[i].username, lp_workgroup(),
-                                                    servers[i].password, 0, NULL);
+                                                       "gentest",
+                                                       servers[i].server_name, 
+                                                       servers[i].share_name, NULL,
+                                                       servers[i].username, 
+                                                       lp_workgroup(),
+                                                       servers[i].password);
                        if (!NT_STATUS_IS_OK(status)) {
                                printf("Failed to connect to \\\\%s\\%s - %s\n",
                                       servers[i].server_name, servers[i].share_name,
index 9c7c3632596da9aa1e8da87c85b282b661abb1f8..161f51e1da6bcac4dff575cc4908e8c4846c1be1 100644 (file)
@@ -108,7 +108,6 @@ static struct smbcli_state *connect_one(char *share, int snum)
 {
        struct smbcli_state *c;
        fstring server, myname;
-       uint_t flags = 0;
        NTSTATUS status;
        int retries = 10;
 
@@ -122,10 +121,10 @@ static struct smbcli_state *connect_one(char *share, int snum)
 
        do {
                status = smbcli_full_connection(NULL, &c, myname,
-                                            server, NULL,  
-                                            share, "?????", 
-                                            servers[snum].username, lp_workgroup(), 
-                                            servers[snum].password, flags, NULL);
+                                               server, 
+                                               share, NULL,
+                                               servers[snum].username, lp_workgroup(), 
+                                               servers[snum].password);
                if (!NT_STATUS_IS_OK(status)) {
                        sleep(2);
                }
index 46254ad5e37d9085a66f64ad92a119b92d0353ae..3eb3398bd17920feb671f9f1d92bd19fcff47cf8 100644 (file)
@@ -164,10 +164,8 @@ static struct smbcli_state *connect_one(char *share)
        slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
 
        nt_status = smbcli_full_connection(NULL, 
-                                          &c, myname, server_n, NULL, 0, share, "?????", 
-                                          username, lp_workgroup(), password, 0,
-                                          NULL);
-
+                                          &c, myname, server_n, 0, share, NULL,
+                                          username, lp_workgroup(), password);
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
                return NULL;
index ee15f92d8053a1a7b790335517b6094b3c980845..a560c19f44b3e7b82f05082c68955f8fad955bcb 100644 (file)
@@ -69,7 +69,6 @@ static struct smbcli_state *connect_one(char *share)
 {
        struct smbcli_state *c;
        fstring server;
-       uint_t flags = 0;
        NTSTATUS status;
 
        fstrcpy(server,share+2);
@@ -79,10 +78,10 @@ static struct smbcli_state *connect_one(char *share)
        share++;
 
        status = smbcli_full_connection(NULL, &c, "masktest",
-                                    server, NULL
-                                    share, "?????", 
-                                    username, lp_workgroup(), 
-                                    password, flags, NULL);
+                                       server
+                                       share, NULL,
+                                       username, lp_workgroup(), 
+                                       password);
 
        if (!NT_STATUS_IS_OK(status)) {
                return NULL;
index ce16cf2b1d1727d1a592b2065a25030ebaa8f20c..d8a8a4e2e93e9271713cc97555ca43d2245ee229 100644 (file)
@@ -75,7 +75,7 @@ static NTSTATUS after_negprot(struct smbcli_transport **dst_transport,
        }
 
        /* negotiate protocol options with the server */
-       status = smb_raw_negotiate(transport);
+       status = smb_raw_negotiate(transport, lp_maxprotocol());
        if (!NT_STATUS_IS_OK(status)) {
                talloc_free(transport);
                return NT_STATUS_UNSUCCESSFUL;
index d50bb9366a838dc24ced0435be19842ea1e09e15..f9faf21957791e139bdbccd19dd858455bb2cfd7 100644 (file)
@@ -89,8 +89,6 @@ BOOL torture_open_connection_share(struct smbcli_state **c,
                                   const char *hostname, 
                                   const char *sharename)
 {
-       BOOL retry;
-       int flags = 0;
        NTSTATUS status;
        const char *username = lp_parm_string(-1, "torture", "username");
        const char *userdomain = lp_parm_string(-1, "torture", "userdomain");
@@ -98,10 +96,10 @@ BOOL torture_open_connection_share(struct smbcli_state **c,
 
        status = smbcli_full_connection(NULL,
                                        c, lp_netbios_name(),
-                                       hostname, NULL, 
-                                       sharename, "?????", 
+                                       hostname, 
+                                       sharename, NULL,
                                        username, username[0]?userdomain:"",
-                                       password, flags, &retry);
+                                       password);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to open connection - %s\n", nt_errstr(status));
                return False;
@@ -745,8 +743,6 @@ static BOOL tcon_devtest(struct smbcli_state *cli,
 static BOOL run_tcon_devtype_test(void)
 {
        struct smbcli_state *cli1 = NULL;
-       BOOL retry;
-       int flags = 0;
        NTSTATUS status;
        BOOL ret = True;
        const char *host = lp_parm_string(-1, "torture", "host");
@@ -757,10 +753,10 @@ static BOOL run_tcon_devtype_test(void)
        
        status = smbcli_full_connection(NULL,
                                        &cli1, lp_netbios_name(),
-                                       host, NULL, 
-                                       share, "?????",
+                                       host, 
+                                       share, NULL,
                                        username, userdomain,
-                                       password, flags, &retry);
+                                       password);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("could not open connection\n");
@@ -1054,7 +1050,7 @@ static BOOL run_negprot_nowait(void)
        for (i=0;i<10000;i++) {
                struct smbcli_request *req;
                time_t t1 = time(NULL);
-               req = smb_negprot_send(cli->transport, PROTOCOL_NT1);
+               req = smb_raw_negotiate_send(cli->transport, PROTOCOL_NT1);
                while (req->state == SMBCLI_REQUEST_SEND && time(NULL) < t1+5) {
                        smbcli_transport_process(cli->transport);
                }
@@ -2155,30 +2151,6 @@ BOOL torture_chkpath_test(void)
 }
 
 
-/*
-  parse a //server/share type UNC name
-*/
-static BOOL parse_unc(const char *unc_name, char **hostname, char **sharename)
-{
-       char *p;
-
-       if (strncmp(unc_name, "//", 2)) {
-               return False;
-       }
-
-       *hostname = strdup(&unc_name[2]);
-       p = strchr_m(&(*hostname)[2],'/');
-       if (!p) {
-               return False;
-       }
-       *p = 0;
-       *sharename = strdup(p+1);
-
-       return True;
-}
-
-
-
 static void sigcont(int sig)
 {
 }
@@ -2234,7 +2206,7 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result
                procnum = i;
                if (fork() == 0) {
                        char *myname;
-                       char *hostname=NULL, *sharename;
+                       const char *hostname=NULL, *sharename;
 
                        pid_t mypid = getpid();
                        sys_srandom(((int)mypid) ^ ((int)time(NULL)));
@@ -2245,8 +2217,8 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result
 
 
                        if (unc_list) {
-                               if (!parse_unc(unc_list[i % num_unc_names],
-                                              &hostname, &sharename)) {
+                               if (!smbcli_parse_unc(unc_list[i % num_unc_names],
+                                                     NULL, &hostname, &sharename)) {
                                        printf("Failed to parse UNC name %s\n",
                                               unc_list[i % num_unc_names]);
                                        exit(1);
@@ -2746,9 +2718,9 @@ static BOOL is_binding_string(const char *binding_string)
                lp_set_cmdline("torture:binding", argv_new[1]);
        } else {
                char *binding = NULL;
-               char *host = NULL, *share = NULL;
+               const char *host = NULL, *share = NULL;
 
-               if (!parse_unc(argv_new[1], &host, &share)) {
+               if (!smbcli_parse_unc(argv_new[1], NULL, &host, &share)) {
                        d_printf("Invalid option: %s is not a valid torture target (share or binding string)\n\n", argv_new[1]);
                        usage(pc);
                }