r6907: Unixinfo for samba4, not activated by default.
[samba.git] / source / torture / torture.c
index f5b45021c5f4c154930e1fff2fa8b93a443248aa..f5e52c53581489bff6a3635667b848d888a458e2 100644 (file)
@@ -25,6 +25,7 @@
 #include "libcli/raw/libcliraw.h"
 #include "system/time.h"
 #include "system/wait.h"
+#include "system/filesys.h"
 #include "ioctl.h"
 #include "librpc/gen_ndr/ndr_security.h"
 
@@ -44,12 +45,15 @@ BOOL torture_showall = False;
 
 static struct smbcli_state *open_nbt_connection(void)
 {
-       struct nmb_name called, calling;
+       struct nbt_name called, calling;
        struct smbcli_state *cli;
        const char *host = lp_parm_string(-1, "torture", "host");
 
-       make_nmb_name(&calling, lp_netbios_name(), 0x0);
-       choose_called_name(&called, host, 0x20);
+       calling.name = lp_netbios_name();
+       calling.type = NBT_NAME_CLIENT;
+       calling.scope = NULL;
+
+       nbt_choose_called_name(NULL, &called, host, NBT_NAME_SERVER);
 
        cli = smbcli_state_init(NULL);
        if (!cli) {
@@ -62,26 +66,10 @@ static struct smbcli_state *open_nbt_connection(void)
                return cli;
        }
 
-       cli->transport->socket->timeout = 120000; /* set a really long timeout (2 minutes) */
-
        if (!smbcli_transport_establish(cli, &calling, &called)) {
-               /*
-                * Well, that failed, try *SMBSERVER ... 
-                * However, we must reconnect as well ...
-                */
-               if (!smbcli_socket_connect(cli, host)) {
-                       printf("Failed to connect with %s\n", host);
-                       return False;
-               }
-
-               make_nmb_name(&called, "*SMBSERVER", 0x20);
-               if (!smbcli_transport_establish(cli, &calling, &called)) {
-                       printf("%s rejected the session\n",host);
-                       printf("We tried with a called name of %s & %s\n",
-                               host, "*SMBSERVER");
-                       smbcli_shutdown(cli);
-                       return NULL;
-               }
+               printf("%s rejected the session\n",host);
+               smbcli_shutdown(cli);
+               return NULL;
        }
 
        return cli;
@@ -91,19 +79,12 @@ 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");
-       const char *password = lp_parm_string(-1, "torture", "password");
 
        status = smbcli_full_connection(NULL,
-                                       c, lp_netbios_name(),
-                                       hostname, NULL, 
-                                       sharename, "?????", 
-                                       username, username[0]?userdomain:"",
-                                       password, flags, &retry);
+                                       c, hostname, 
+                                       sharename, NULL,
+                                       cmdline_credentials);
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to open connection - %s\n", nt_errstr(status));
                return False;
@@ -111,7 +92,6 @@ BOOL torture_open_connection_share(struct smbcli_state **c,
 
        (*c)->transport->options.use_oplocks = use_oplocks;
        (*c)->transport->options.use_level2_oplocks = use_level_II_oplocks;
-       (*c)->transport->socket->timeout = 120000;
 
        return True;
 }
@@ -138,18 +118,9 @@ BOOL torture_close_connection(struct smbcli_state *c)
        return ret;
 }
 
-/* initialise a DCOM context */
-NTSTATUS torture_dcom_init(struct dcom_context **ctx)
-{
-       dcom_init(ctx, lp_parm_string(-1, "torture", "userdomain"),
-                                       lp_parm_string(-1, "torture", "username"), 
-                                       lp_parm_string(-1, "torture", "password"));
-
-       return NT_STATUS_OK;
-}
-
 /* open a rpc connection to the chosen binding string */
-NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p, 
+NTSTATUS torture_rpc_connection(TALLOC_CTX *parent_ctx, 
+                               struct dcerpc_pipe **p, 
                                const char *pipe_name,
                                const char *pipe_uuid, 
                                uint32_t pipe_version)
@@ -162,16 +133,16 @@ NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       status = dcerpc_pipe_connect(p, binding, pipe_uuid, pipe_version,
-                                    lp_parm_string(-1, "torture", "userdomain"), 
-                                    lp_parm_string(-1, "torture", "username"),
-                                    lp_parm_string(-1, "torture", "password"));
+       status = dcerpc_pipe_connect(parent_ctx, 
+                                    p, binding, pipe_uuid, pipe_version,
+                                    cmdline_credentials);
  
         return status;
 }
 
 /* open a rpc connection to a specific transport */
-NTSTATUS torture_rpc_connection_transport(struct dcerpc_pipe **p, 
+NTSTATUS torture_rpc_connection_transport(TALLOC_CTX *parent_ctx, 
+                                         struct dcerpc_pipe **p, 
                                          const char *pipe_name,
                                          const char *pipe_uuid, 
                                          uint32_t pipe_version,
@@ -179,39 +150,36 @@ NTSTATUS torture_rpc_connection_transport(struct dcerpc_pipe **p,
 {
         NTSTATUS status;
        const char *binding = lp_parm_string(-1, "torture", "binding");
-       struct dcerpc_binding b;
-       TALLOC_CTX *mem_ctx = talloc_init("torture_rpc_connection_smb");
+       struct dcerpc_binding *b;
+       TALLOC_CTX *mem_ctx = talloc_named(parent_ctx, 0, "torture_rpc_connection_smb");
 
        if (!binding) {
                printf("You must specify a ncacn binding string\n");
+               talloc_free(mem_ctx);
                return NT_STATUS_INVALID_PARAMETER;
        }
 
        status = dcerpc_parse_binding(mem_ctx, binding, &b);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Failed to parse dcerpc binding '%s'\n", binding));
-               talloc_destroy(mem_ctx);
+               talloc_free(mem_ctx);
                return status;
        }
 
-       b.transport = transport;
+       b->transport = transport;
 
-       status = dcerpc_pipe_connect_b(p, &b, pipe_uuid, pipe_version,
-                                      lp_parm_string(-1, "torture", "userdomain"), 
-                                      lp_parm_string(-1, "torture", "username"),
-                                      lp_parm_string(-1, "torture", "password"));
+       status = dcerpc_pipe_connect_b(mem_ctx, p, b, pipe_uuid, pipe_version,
+                                                                  cmdline_credentials);
+                                          
+       if (NT_STATUS_IS_OK(status)) {
+               *p = talloc_reference(parent_ctx, *p);
+       } else {
+               *p = NULL;
+       }
+       talloc_free(mem_ctx);
         return status;
 }
 
-/* close a rpc connection to a named pipe */
-NTSTATUS torture_rpc_close(struct dcerpc_pipe *p)
-{
-       dcerpc_pipe_close(p);
-       return NT_STATUS_OK;
-}
-
-
 /* check if the server produced the expected error code */
 BOOL check_error(const char *location, struct smbcli_state *c, 
                 uint8_t eclass, uint32_t ecode, NTSTATUS nterr)
@@ -267,7 +235,7 @@ static BOOL rw_torture(struct smbcli_state *c)
        int fnum2;
        pid_t pid2, pid = getpid();
        int i, j;
-       char buf[1024];
+       uint8_t buf[1024];
        BOOL correct = True;
 
        fnum2 = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL, 
@@ -281,7 +249,7 @@ static BOOL rw_torture(struct smbcli_state *c)
 
 
        for (i=0;i<torture_numops;i++) {
-               uint_t n = (uint_t)sys_random()%10;
+               uint_t n = (uint_t)random()%10;
                if (i % 10 == 0) {
                        printf("%d\r", i); fflush(stdout);
                }
@@ -298,13 +266,13 @@ static BOOL rw_torture(struct smbcli_state *c)
                        break;
                }
 
-               if (smbcli_write(c->tree, fnum, 0, (char *)&pid, 0, sizeof(pid)) != sizeof(pid)) {
+               if (smbcli_write(c->tree, fnum, 0, &pid, 0, sizeof(pid)) != sizeof(pid)) {
                        printf("write failed (%s)\n", smbcli_errstr(c->tree));
                        correct = False;
                }
 
                for (j=0;j<50;j++) {
-                       if (smbcli_write(c->tree, fnum, 0, (char *)buf, 
+                       if (smbcli_write(c->tree, fnum, 0, buf, 
                                      sizeof(pid)+(j*sizeof(buf)), 
                                      sizeof(buf)) != sizeof(buf)) {
                                printf("write failed (%s)\n", smbcli_errstr(c->tree));
@@ -314,7 +282,7 @@ static BOOL rw_torture(struct smbcli_state *c)
 
                pid2 = 0;
 
-               if (smbcli_read(c->tree, fnum, (char *)&pid2, 0, sizeof(pid)) != sizeof(pid)) {
+               if (smbcli_read(c->tree, fnum, &pid2, 0, sizeof(pid)) != sizeof(pid)) {
                        printf("read failed (%s)\n", smbcli_errstr(c->tree));
                        correct = False;
                }
@@ -362,104 +330,6 @@ static BOOL run_torture(struct smbcli_state *cli, int dummy)
        return ret;
 }
 
-static BOOL rw_torture3(struct smbcli_state *c, const char *lockfname)
-{
-       int fnum = -1;
-       uint_t i = 0;
-       char buf[131072];
-       char buf_rd[131072];
-       uint_t count;
-       uint_t countprev = 0;
-       ssize_t sent = 0;
-       BOOL correct = True;
-
-       for (i = 0; i < sizeof(buf); i += sizeof(uint32_t))
-       {
-               SIVAL(buf, i, sys_random());
-       }
-
-       if (procnum == 0)
-       {
-               fnum = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL, 
-                               DENY_NONE);
-               if (fnum == -1) {
-                       printf("first open read/write of %s failed (%s)\n",
-                                       lockfname, smbcli_errstr(c->tree));
-                       return False;
-               }
-       }
-       else
-       {
-               for (i = 0; i < 500 && fnum == -1; i++)
-               {
-                       fnum = smbcli_open(c->tree, lockfname, O_RDONLY, 
-                                       DENY_NONE);
-                       msleep(10);
-               }
-               if (fnum == -1) {
-                       printf("second open read-only of %s failed (%s)\n",
-                                       lockfname, smbcli_errstr(c->tree));
-                       return False;
-               }
-       }
-
-       i = 0;
-       for (count = 0; count < sizeof(buf); count += sent)
-       {
-               if (count >= countprev) {
-                       printf("%d %8d\r", i, count);
-                       fflush(stdout);
-                       i++;
-                       countprev += (sizeof(buf) / 20);
-               }
-
-               if (procnum == 0)
-               {
-                       sent = ((uint_t)sys_random()%(20))+ 1;
-                       if (sent > sizeof(buf) - count)
-                       {
-                               sent = sizeof(buf) - count;
-                       }
-
-                       if (smbcli_write(c->tree, fnum, 0, buf+count, count, (size_t)sent) != sent) {
-                               printf("write failed (%s)\n", smbcli_errstr(c->tree));
-                               correct = False;
-                       }
-               }
-               else
-               {
-                       sent = smbcli_read(c->tree, fnum, buf_rd+count, count,
-                                       sizeof(buf)-count);
-                       if (sent < 0)
-                       {
-                               printf("read failed offset:%d size:%d (%s)\n",
-                                               count, sizeof(buf)-count,
-                                               smbcli_errstr(c->tree));
-                               correct = False;
-                               sent = 0;
-                       }
-                       if (sent > 0)
-                       {
-                               if (memcmp(buf_rd+count, buf+count, sent) != 0)
-                               {
-                                       printf("read/write compare failed\n");
-                                       printf("offset: %d req %d recvd %d\n",
-                                               count, sizeof(buf)-count, sent);
-                                       correct = False;
-                                       break;
-                               }
-                       }
-               }
-
-       }
-
-       if (NT_STATUS_IS_ERR(smbcli_close(c->tree, fnum))) {
-               printf("close failed (%s)\n", smbcli_errstr(c->tree));
-               correct = False;
-       }
-
-       return correct;
-}
 
 static BOOL rw_torture2(struct smbcli_state *c1, struct smbcli_state *c2)
 {
@@ -496,7 +366,7 @@ static BOOL rw_torture2(struct smbcli_state *c1, struct smbcli_state *c2)
 
        for (i=0;i<torture_numops;i++)
        {
-               size_t buf_size = ((uint_t)sys_random()%(sizeof(buf)-1))+ 1;
+               size_t buf_size = ((uint_t)random()%(sizeof(buf)-1))+ 1;
                if (i % 10 == 0) {
                        printf("%d\r", i); fflush(stdout);
                }
@@ -542,6 +412,8 @@ static BOOL rw_torture2(struct smbcli_state *c1, struct smbcli_state *c2)
        return correct;
 }
 
+#define BOOLSTR(b) ((b) ? "Yes" : "No")
+
 static BOOL run_readwritetest(void)
 {
        struct smbcli_state *cli1, *cli2;
@@ -572,20 +444,6 @@ static BOOL run_readwritetest(void)
        return (test1 && test2);
 }
 
-static BOOL run_readwritemulti(struct smbcli_state *cli, int dummy)
-{
-       BOOL test;
-
-       test = rw_torture3(cli, "\\multitest.txt");
-
-       if (!torture_close_connection(cli)) {
-               test = False;
-       }
-       
-       return test;
-}
-
-
 /*
   this checks to see if a secondary tconx can use open files from an
   earlier tconx
@@ -597,7 +455,7 @@ static BOOL run_tcon_test(void)
        int fnum1;
        uint16_t cnum1, cnum2, cnum3;
        uint16_t vuid1, vuid2;
-       char buf[4];
+       uint8_t buf[4];
        BOOL ret = True;
        struct smbcli_tree *tree1;
        const char *host = lp_parm_string(-1, "torture", "host");
@@ -748,22 +606,15 @@ 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");
        const char *share = lp_parm_string(-1, "torture", "share");
-       const char *username = lp_parm_string(-1, "torture", "username");
-       const char *userdomain = lp_parm_string(-1, "torture", "userdomain");
-       const char *password = lp_parm_string(-1, "torture", "password");
        
        status = smbcli_full_connection(NULL,
-                                       &cli1, lp_netbios_name(),
-                                       host, NULL, 
-                                       share, "?????",
-                                       username, userdomain,
-                                       password, flags, &retry);
+                                       &cli1, host, 
+                                       share, NULL,
+                                       cmdline_credentials);
 
        if (!NT_STATUS_IS_OK(status)) {
                printf("could not open connection\n");
@@ -818,7 +669,7 @@ static BOOL run_fdpasstest(void)
        struct smbcli_state *cli1, *cli2;
        const char *fname = "\\fdpass.tst";
        int fnum1, oldtid;
-       pstring buf;
+       uint8_t buf[1024];
 
        if (!torture_open_connection(&cli1) || !torture_open_connection(&cli2)) {
                return False;
@@ -1057,7 +908,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);
                }
@@ -1284,7 +1135,7 @@ static BOOL run_trans2test(void)
 
        fnum = smbcli_open(cli->tree, fname2, 
                        O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
-       smbcli_write(cli->tree, fnum,  0, (char *)&fnum, 0, sizeof(fnum));
+       smbcli_write(cli->tree, fnum,  0, &fnum, 0, sizeof(fnum));
        smbcli_close(cli->tree, fnum);
        if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time2, &w_time, &size, NULL, NULL))) {
                printf("ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree));
@@ -1422,7 +1273,7 @@ static BOOL run_pipe_number(void)
 
        printf("Opening %d connections\n", torture_numops);
        
-       cli = malloc(sizeof(struct smbcli_state *) * torture_numops);
+       cli = malloc_array_p(struct smbcli_state *, torture_numops);
 
        for (i=0;i<torture_numops;i++) {
                if (!torture_open_connection(&cli[i])) {
@@ -1536,7 +1387,7 @@ static BOOL run_vuidtest(void)
        static struct smbcli_state *cli2;
        const char *fname = "\\readonly.file";
        int fnum1, fnum2;
-       char buf[20];
+       uint8_t buf[20];
        size_t fsize;
        BOOL correct = True;
        char *tmp_path;
@@ -2158,30 +2009,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)
 {
 }
@@ -2199,6 +2026,8 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result
        int num_unc_names = 0;
        struct timeval tv;
 
+       *result = True;
+
        synccount = 0;
 
        signal(SIGCONT, sigcont);
@@ -2235,10 +2064,10 @@ 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)));
+                       srandom(((int)mypid) ^ ((int)time(NULL)));
 
                        asprintf(&myname, "CLIENT%d", i);
                        lp_set_cmdline("netbios name", myname);
@@ -2246,8 +2075,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);
@@ -2363,7 +2192,6 @@ static struct {
        {"BASE-TCONDEV",  run_tcon_devtype_test, 0},
        {"BASE-VUID", run_vuidtest, 0},
        {"BASE-RW1",  run_readwritetest, 0},
-       {"BASE-RW2",  NULL, run_readwritemulti},
        {"BASE-OPEN", run_opentest, 0},
        {"BASE-DEFER_OPEN", NULL, run_deferopen},
        {"BASE-XCOPY", run_xcopy, 0},
@@ -2382,6 +2210,10 @@ static struct {
        {"BENCH-HOLDCON",  torture_holdcon, 0},
        {"BENCH-NBENCH",  torture_nbench, 0},
        {"BENCH-TORTURE", NULL, run_torture},
+       {"BENCH-NBT",     torture_bench_nbt, 0},
+       {"BENCH-WINS",    torture_bench_wins, 0},
+       {"BENCH-RPC",     torture_bench_rpc, 0},
+       {"BENCH-CLDAP",   torture_bench_cldap, 0},
 
        /* RAW smb tests */
        {"RAW-QFSINFO", torture_raw_qfsinfo, 0},
@@ -2408,6 +2240,7 @@ static struct {
        {"RAW-STREAMS", torture_raw_streams, 0},
        {"RAW-ACLS", torture_raw_acls, 0},
        {"RAW-RAP", torture_raw_rap, 0},
+       {"RAW-COMPOSITE", torture_raw_composite, 0},
 
        /* protocol scanners */
        {"SCAN-TRANS2", torture_trans2_scan, 0},
@@ -2419,6 +2252,7 @@ static struct {
        {"SCAN-CASETABLE", torture_casetable, 0},
        {"SCAN-PIPE_NUMBER", run_pipe_number, 0},
        {"SCAN-IOCTL",  torture_ioctl_test, 0},
+       {"SCAN-RAP",  torture_rap_scan, 0},
 
        /* rpc testers */
         {"RPC-LSA", torture_rpc_lsa, 0},
@@ -2426,6 +2260,7 @@ static struct {
         {"RPC-DFS", torture_rpc_dfs, 0},
         {"RPC-SPOOLSS", torture_rpc_spoolss, 0},
         {"RPC-SAMR", torture_rpc_samr, 0},
+        {"RPC-UNIXINFO", torture_rpc_unixinfo, 0},
         {"RPC-NETLOGON", torture_rpc_netlogon, 0},
         {"RPC-SAMLOGON", torture_rpc_samlogon, 0},
         {"RPC-SAMSYNC", torture_rpc_samsync, 0},
@@ -2437,6 +2272,7 @@ static struct {
         {"RPC-EVENTLOG", torture_rpc_eventlog, 0},
         {"RPC-EPMAPPER", torture_rpc_epmapper, 0},
         {"RPC-WINREG", torture_rpc_winreg, 0},
+        {"RPC-INITSHUTDOWN", torture_rpc_initshutdown, 0},
         {"RPC-OXIDRESOLVE", torture_rpc_oxidresolve, 0},
         {"RPC-REMACT", torture_rpc_remact, 0},
         {"RPC-MGMT", torture_rpc_mgmt, 0},
@@ -2447,9 +2283,8 @@ static struct {
        {"RPC-DRSUAPI", torture_rpc_drsuapi, 0},
        {"RPC-LOGIN", torture_rpc_login, 0},
        {"RPC-ROT", torture_rpc_rot, 0},
-
-       /* Distributed COM testers */
-       {"DCOM-SIMPLE", torture_dcom_simple, 0},
+       {"RPC-DSSETUP", torture_rpc_dssetup, 0},
+        {"RPC-ALTERCONTEXT", torture_rpc_alter_context, 0},
 
        /* local (no server) testers */
        {"LOCAL-NTLMSSP", torture_ntlmssp_self_check, 0},
@@ -2458,9 +2293,25 @@ static struct {
        {"LOCAL-MESSAGING", torture_local_messaging, 0},
        {"LOCAL-BINDING", torture_local_binding_string, 0},
        {"LOCAL-IDTREE", torture_local_idtree, 0},
+       {"LOCAL-SOCKET", torture_local_socket, 0},
+
+       /* COM (Component Object Model) testers */
+       {"COM-SIMPLE", torture_com_simple, 0 },
 
        /* ldap testers */
        {"LDAP-BASIC", torture_ldap_basic, 0},
+       {"LDAP-CLDAP", torture_cldap, 0},
+
+       /* nbt tests */
+       {"NBT-REGISTER", torture_nbt_register, 0},
+       {"NBT-WINS", torture_nbt_wins, 0},
+       {"NBT-WINSREPLICATION", torture_nbt_winsreplication, 0},
+       {"NBT-DGRAM", torture_nbt_dgram, 0},
+       
+       /* libnet tests */
+       {"NET-USERINFO", torture_userinfo, 0},
+       {"NET-USERADD", torture_useradd, 0},
+       {"NET-USERDEL", torture_userdel, 0},
 
        {NULL, NULL, 0}};
 
@@ -2491,7 +2342,7 @@ static BOOL run_test(const char *name)
                        init_iconv();
                        printf("Running %s\n", torture_ops[i].name);
                        if (torture_ops[i].multi_fn) {
-                               BOOL result;
+                               BOOL result = False;
                                t = torture_create_procs(torture_ops[i].multi_fn, 
                                                         &result);
                                if (!result) { 
@@ -2567,6 +2418,50 @@ static void usage(poptContext pc)
        poptPrintUsage(pc, stdout, 0);
        printf("\n");
 
+       printf("The binding format is:\n\n");
+
+       printf("  TRANSPORT:host[flags]\n\n");
+
+       printf("  where TRANSPORT is either ncacn_np for SMB or ncacn_ip_tcp for RPC/TCP\n\n");
+
+       printf("  'host' is an IP or hostname or netbios name. If the binding string\n");
+       printf("  identifies the server side of an endpoint, 'host' may be an empty\n");
+       printf("  string.\n\n");
+
+       printf("  'flags' can include a SMB pipe name if using the ncacn_np transport or\n");
+       printf("  a TCP port number if using the ncacn_ip_tcp transport, otherwise they\n");
+       printf("  will be auto-determined.\n\n");
+
+       printf("  other recognised flags are:\n\n");
+
+       printf("    sign : enable ntlmssp signing\n");
+       printf("    seal : enable ntlmssp sealing\n");
+       printf("    connect : enable rpc connect level auth (auth, but no sign or seal)\n");
+       printf("    validate: enable the NDR validator\n");
+       printf("    print: enable debugging of the packets\n");
+       printf("    bigendian: use bigendian RPC\n");
+       printf("    padcheck: check reply data for non-zero pad bytes\n\n");
+
+       printf("  For example, these all connect to the samr pipe:\n\n");
+
+       printf("    ncacn_np:myserver\n");
+       printf("    ncacn_np:myserver[samr]\n");
+       printf("    ncacn_np:myserver[\\pipe\\samr]\n");
+       printf("    ncacn_np:myserver[/pipe/samr]\n");
+       printf("    ncacn_np:myserver[samr,sign,print]\n");
+       printf("    ncacn_np:myserver[\\pipe\\samr,sign,seal,bigendian]\n");
+       printf("    ncacn_np:myserver[/pipe/samr,seal,validate]\n");
+       printf("    ncacn_np:\n");
+       printf("    ncacn_np:[/pipe/samr]\n\n");
+
+       printf("    ncacn_ip_tcp:myserver\n");
+       printf("    ncacn_ip_tcp:myserver[1024]\n");
+       printf("    ncacn_ip_tcp:myserver[1024,sign,seal]\n\n");
+
+       printf("The unc format is:\n\n");
+
+       printf("    //server/share\n\n");
+
        printf("tests are:");
        for (i=0;torture_ops[i].name;i++) {
                if ((i%perline)==0) {
@@ -2577,19 +2472,19 @@ static void usage(poptContext pc)
        printf("\n\n");
 
        printf("default test is ALL\n");
-       
+
        exit(1);
 }
 
 static BOOL is_binding_string(const char *binding_string)
 {
        TALLOC_CTX *mem_ctx = talloc_init("is_binding_string");
-       struct dcerpc_binding binding_struct;
+       struct dcerpc_binding *binding_struct;
        NTSTATUS status;
        
        status = dcerpc_parse_binding(mem_ctx, binding_string, &binding_struct);
 
-       talloc_destroy(mem_ctx);
+       talloc_free(mem_ctx);
        return NT_STATUS_IS_OK(status);
 }
 
@@ -2634,7 +2529,7 @@ static BOOL is_binding_string(const char *binding_string)
 #endif
 
        pc = poptGetContext("smbtorture", argc, (const char **) argv, long_options, 
-                               POPT_CONTEXT_KEEP_FIRST);
+                           POPT_CONTEXT_KEEP_FIRST);
 
        poptSetOtherOptionHelp(pc, "<binding>|<unc> TEST1 TEST2 ...");
 
@@ -2653,7 +2548,7 @@ static BOOL is_binding_string(const char *binding_string)
                        parse_dns(poptGetOptArg(pc));
                        break;
                case OPT_DANGEROUS:
-                       lp_set_cmdline("torture:dangerous", "1");
+                       lp_set_cmdline("torture:dangerous", "Yes");
                        break;
                default:
                        d_printf("Invalid option %s: %s\n", 
@@ -2700,9 +2595,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);
                }
@@ -2713,25 +2608,6 @@ static BOOL is_binding_string(const char *binding_string)
                lp_set_cmdline("torture:binding", binding);
        }
 
-       if (!lp_parm_string(-1,"torture","username")) {
-               lp_set_cmdline("torture:username", cmdline_get_username());
-       }
-       if (!lp_parm_string(-1,"torture","userdomain")) {
-               /* 
-                * backward compatibility
-                * maybe we should remove this to make this consistent
-                * for all cmdline tools
-                * --metze
-                */
-               if (strequal(lp_netbios_name(),cmdline_get_userdomain())) {
-                       cmdline_set_userdomain(lp_workgroup());
-               }
-               lp_set_cmdline("torture:userdomain", cmdline_get_userdomain());
-       }
-       if (!lp_parm_string(-1,"torture","password")) {
-               lp_set_cmdline("torture:password", cmdline_get_userpassword());
-       }
-
        if (argc_new == 0) {
                printf("You must specify a test to run, or 'ALL'\n");
        } else {