s4:torture/rpc: use generate_random_password()
authorStefan Metzmacher <metze@samba.org>
Wed, 24 Feb 2010 14:12:17 +0000 (15:12 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 26 Feb 2010 07:57:29 +0000 (08:57 +0100)
metze

source4/torture/rpc/netlogon.c
source4/torture/rpc/samba3rpc.c
source4/torture/rpc/samr.c
source4/torture/rpc/schannel.c
source4/torture/rpc/testjoin.c

index 2806cca52b2e65f4344749f41fe380c202f992de..0270a5aea9a2c76e1b7711adffd99f9e81645bf3 100644 (file)
@@ -292,7 +292,7 @@ static bool test_SetPassword(struct torture_context *tctx,
        r.in.new_password = &new_password;
        r.out.return_authenticator = &return_authenticator;
 
-       password = generate_random_str(tctx, 8);
+       password = generate_random_password(tctx, 8, 255);
        E_md4hash(password, new_password.hash);
 
        netlogon_creds_des_encrypt(creds, &new_password);
@@ -367,7 +367,7 @@ static bool test_SetPassword_flags(struct torture_context *tctx,
        r.in.new_password = &new_password;
        r.out.return_authenticator = &return_authenticator;
 
-       password = generate_random_str(tctx, 8);
+       password = generate_random_password(tctx, 8, 255);
        E_md4hash(password, new_password.hash);
 
        netlogon_creds_des_encrypt(creds, &new_password);
@@ -460,7 +460,7 @@ static bool test_SetPassword2(struct torture_context *tctx,
        r.in.new_password = &new_password;
        r.out.return_authenticator = &return_authenticator;
 
-       password = generate_random_str(tctx, 8);
+       password = generate_random_password(tctx, 8, 255);
        encode_pw_buffer(password_buf.data, password, STR_UNICODE);
        netlogon_creds_arcfour_crypt(creds, password_buf.data, 516);
 
@@ -518,7 +518,7 @@ static bool test_SetPassword2(struct torture_context *tctx,
                "ServerPasswordSet failed to actually change the password");
 
        /* now try a random password */
-       password = generate_random_str(tctx, 8);
+       password = generate_random_password(tctx, 8, 255);
        encode_pw_buffer(password_buf.data, password, STR_UNICODE);
        netlogon_creds_arcfour_crypt(creds, password_buf.data, 516);
 
index 86f41b058bcff32f29901835483a77ed3348a3fa..9e7b18b4d7b90da6fdcdeaf347909b1c67d60d28 100644 (file)
@@ -1161,7 +1161,7 @@ static bool schan(struct smbcli_state *cli,
 
        {
                struct netr_ServerPasswordSet s;
-               char *password = generate_random_str(wks_creds, 8);
+               char *password = generate_random_password(wks_creds, 8, 255);
                struct netlogon_creds_CredentialState *creds_state;
                struct netr_Authenticator credential, return_authenticator;
                struct samr_Password new_password;
@@ -1285,7 +1285,7 @@ bool torture_netlogon_samba3(struct torture_context *torture)
        cli_credentials_set_username(wks_creds, wks_name, CRED_SPECIFIED);
        cli_credentials_set_workstation(wks_creds, wks_name, CRED_SPECIFIED);
        cli_credentials_set_password(wks_creds,
-                                    generate_random_str(wks_creds, 8),
+                                    generate_random_password(wks_creds, 8, 255),
                                     CRED_SPECIFIED);
 
        if (!join3(cli, torture->lp_ctx, false, cmdline_credentials, wks_creds)) {
@@ -1376,7 +1376,7 @@ static bool test_join3(struct torture_context *tctx,
        cli_credentials_set_username(wks_creds, wks_name, CRED_SPECIFIED);
        cli_credentials_set_workstation(wks_creds, wks_name, CRED_SPECIFIED);
        cli_credentials_set_password(wks_creds,
-                                    generate_random_str(wks_creds, 8),
+                                    generate_random_password(wks_creds, 8, 255),
                                     CRED_SPECIFIED);
 
        if (!join3(cli, tctx->lp_ctx, use_level25, samr_creds, wks_creds)) {
@@ -1804,7 +1804,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
        cli_credentials_set_username(user_creds, "torture_username",
                                     CRED_SPECIFIED);
        cli_credentials_set_password(user_creds,
-                                    generate_random_str(user_creds, 8),
+                                    generate_random_password(user_creds, 8, 255),
                                     CRED_SPECIFIED);
 
        if (!create_user(mem_ctx, cli, torture->lp_ctx, cmdline_credentials,
index 41e12acc4038da58fd3c56d605ddd422e3adf10f..92a255e0fb8bd9220de2bbef072da5b9efda2bc4 100644 (file)
@@ -574,8 +574,8 @@ static bool test_SetUserInfo(struct dcerpc_pipe *p, struct torture_context *tctx
 */
 static char *samr_rand_pass_silent(TALLOC_CTX *mem_ctx, int min_len)
 {
-       size_t len = MAX(8, min_len) + (random() % 6);
-       char *s = generate_random_str(mem_ctx, len);
+       size_t len = MAX(8, min_len);
+       char *s = generate_random_password(mem_ctx, len, len+6);
        return s;
 }
 
@@ -610,7 +610,7 @@ static DATA_BLOB samr_very_rand_pass(TALLOC_CTX *mem_ctx, int len)
 */
 static char *samr_rand_pass_fixed_len(TALLOC_CTX *mem_ctx, int len)
 {
-       char *s = generate_random_str(mem_ctx, len);
+       char *s = generate_random_password(mem_ctx, len, len);
        printf("Generated password '%s'\n", s);
        return s;
 }
index 0ada20d888ff640f8a68e7324a371f976dd7186d..2f9d60ad305f074d9271d4fca47853bdb4b067b1 100644 (file)
@@ -770,7 +770,7 @@ bool torture_rpc_schannel_bench1(struct torture_context *torture)
 
        {
                struct netr_ServerPasswordSet pwset;
-               char *password = generate_random_str(s->join_ctx1, 8);
+               char *password = generate_random_password(s->join_ctx1, 8, 255);
                struct netlogon_creds_CredentialState *creds_state;
                struct dcerpc_pipe *net_pipe;
                struct netr_Authenticator credential, return_authenticator;
index 454912287e3de831c96a05991e34ec50a4ac40d4..00676e44b90f4ef63a111ac8fbb5772bbc8115b0 100644 (file)
@@ -235,7 +235,7 @@ again:
                policy_min_pw_len = pwp.out.info->min_password_length;
        }
 
-       random_pw = generate_random_str(join, MAX(8, policy_min_pw_len));
+       random_pw = generate_random_password(join, MAX(8, policy_min_pw_len), 255);
 
        printf("Setting account password '%s'\n", random_pw);