r5963: Fix parameter passing for gentest and locktest
[samba.git] / source4 / torture / gentest.c
index 5d8c7bf8fdbc6d6583ba0140ec8016f87ff67904..5f036910b60b477e7abbbd39746393be15b5c102 100644 (file)
@@ -21,6 +21,7 @@
 #include "includes.h"
 #include "dynconfig.h"
 #include "system/time.h"
+#include "system/filesys.h"
 #include "request.h"
 #include "libcli/raw/libcliraw.h"
 #include "librpc/gen_ndr/ndr_security.h"
@@ -59,8 +60,7 @@ static struct {
        struct smbcli_state *cli[NINSTANCES];
        char *server_name;
        char *share_name;
-       char *username;
-       char *password;
+       struct cli_credentials *credentials;
 } servers[NSERVERS];
 
 /* the seeds and flags for each operation */
@@ -175,13 +175,13 @@ static BOOL connect_servers(void)
                        NTSTATUS status;
                        printf("Connecting to \\\\%s\\%s as %s - instance %d\n",
                               servers[i].server_name, servers[i].share_name, 
-                              servers[i].username, j);
+                              servers[i].credentials->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].credentials);
                        if (!NT_STATUS_IS_OK(status)) {
                                printf("Failed to connect to \\\\%s\\%s - %s\n",
                                       servers[i].server_name, servers[i].share_name,
@@ -1358,7 +1358,7 @@ static BOOL handler_writex(int instance)
        parm[0].writex.in.wmode = gen_bits_mask(0xFFFF);
        parm[0].writex.in.remaining = gen_io_count();
        parm[0].writex.in.count = gen_io_count();
-       parm[0].writex.in.data = talloc_zero(current_op.mem_ctx, parm[0].writex.in.count);
+       parm[0].writex.in.data = talloc_zero_size(current_op.mem_ctx, parm[0].writex.in.count);
 
        GEN_COPY_PARM;
        GEN_SET_FNUM(writex.in.fnum);
@@ -1392,7 +1392,7 @@ static BOOL handler_lockingx(int instance)
        } while (nlocks == 0);
 
        if (nlocks > 0) {
-               parm[0].lockx.in.locks = talloc_array_p(current_op.mem_ctx,
+               parm[0].lockx.in.locks = talloc_array(current_op.mem_ctx,
                                                        struct smb_lock_entry,
                                                        nlocks);
                for (n=0;n<nlocks;n++) {
@@ -1927,7 +1927,7 @@ static int run_test(void)
 
                ret = gen_ops[which_op].handler(instance);
 
-               talloc_destroy(current_op.mem_ctx);
+               talloc_free(current_op.mem_ctx);
 
                gen_ops[which_op].count++;
                if (NT_STATUS_IS_OK(current_op.status)) {
@@ -2115,6 +2115,7 @@ static void usage(void)
 
        for (i=0;i<NSERVERS;i++) {
                const char *share = argv[1+i];
+               servers[i].credentials = cli_credentials_init(NULL);
                if (!split_unc_name(share, &servers[i].server_name, &servers[i].share_name)) {
                        printf("Invalid share name '%s'\n", share);
                        return -1;
@@ -2135,13 +2136,8 @@ static void usage(void)
        while ((opt = getopt(argc, argv, "U:s:o:ad:i:AOhS:LFXC")) != EOF) {
                switch (opt) {
                case 'U':
-                       i = servers[0].username?1:0;
-                       if (!split_username(optarg, 
-                                           &servers[i].username, 
-                                           &servers[i].password)) {
-                               printf("Must supply USER%%PASS\n");
-                               return -1;
-                       }
+                       i = servers[0].credentials->username?1:0;
+                       cli_credentials_parse_string(servers[i].credentials, optarg, CRED_SPECIFIED);
                        break;
                case 'd':
                        DEBUGLEVEL = atoi(optarg);
@@ -2191,13 +2187,13 @@ static void usage(void)
 
        gentest_init_subsystems;
 
-       if (!servers[0].username) {
+       if (!servers[0].credentials->username) {
                usage();
                return -1;
        }
-       if (!servers[1].username) {
-               servers[1].username = servers[0].username;
-               servers[1].password = servers[0].password;
+       if (!servers[1].credentials->username) {
+               servers[1].credentials->username = servers[0].credentials->username;
+               servers[1].credentials->password = servers[0].credentials->password;
        }
 
        printf("seed=%u\n", options.seed);