s3:torture: make use of cli_session_creds_init() in masktest.c
authorStefan Metzmacher <metze@samba.org>
Fri, 28 Oct 2016 10:42:01 +0000 (12:42 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 15 Nov 2016 10:00:29 +0000 (11:00 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/torture/masktest.c

index 5402663024469455242c7a11e30eaa7a8aab9869..537cfb0aa9517fb95441496e1e02bd590735f8e5 100644 (file)
@@ -27,6 +27,7 @@
 static fstring password;
 static fstring username;
 static int got_pass;
+static struct cli_credentials *test_creds;
 static int max_protocol = -1;
 static bool showall = False;
 static bool old_list = False;
@@ -197,19 +198,7 @@ static struct cli_state *connect_one(char *share)
                return NULL;
        }
 
-       if (!got_pass) {
-               char pwd[256] = {0};
-               int rc;
-
-               rc = samba_getpass("Password: ", pwd, sizeof(pwd), false, false);
-               if (rc == 0) {
-                       fstrcpy(password, pass);
-               }
-       }
-
-       status = cli_session_setup(c, username,
-                                  password,
-                                  lp_workgroup());
+       status = cli_session_setup_creds(c, test_creds);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("session setup failed: %s\n", nt_errstr(status)));
                return NULL;
@@ -549,6 +538,30 @@ static void usage(void)
 
        max_protocol = lp_client_max_protocol();
 
+       if (!got_pass) {
+               char pwd[256] = {0};
+               int rc;
+
+               rc = samba_getpass("Password: ", pwd, sizeof(pwd), false, false);
+               if (rc == 0) {
+                       fstrcpy(password, pass);
+               }
+       }
+
+       test_creds = cli_session_creds_init(frame,
+                                           username,
+                                           lp_workgroup(),
+                                           NULL, /* realm */
+                                           password,
+                                           false, /* use_kerberos */
+                                           false, /* fallback_after_kerberos */
+                                           false, /* use_ccache */
+                                           false); /* password_is_nt_hash */
+       if (test_creds == NULL) {
+               d_printf("cli_session_creds_init() failed.\n");
+               exit(1);
+       }
+
        cli = connect_one(share);
        if (!cli) {
                DEBUG(0,("Failed to connect to %s\n", share));