mirror of
https://github.com/samba-team/samba.git
synced 2025-08-26 01:49:31 +03:00
Add TALLOC_CTX pointer to generate_random_str(), for consistency with
Samba 4.
This commit is contained in:
@ -578,7 +578,7 @@ void gencache_unlock_entry( const char *key );
|
||||
void set_rand_reseed_callback(void (*fn)(int *));
|
||||
void set_need_random_reseed(void);
|
||||
void generate_random_buffer( unsigned char *out, int len);
|
||||
char *generate_random_str(size_t len);
|
||||
char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
|
||||
|
||||
/* The following definitions come from lib/iconv.c */
|
||||
|
||||
|
@ -205,15 +205,11 @@ void generate_random_buffer( unsigned char *out, int len)
|
||||
|
||||
static char c_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,";
|
||||
|
||||
char *generate_random_str(size_t len)
|
||||
char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len)
|
||||
{
|
||||
static unsigned char retstr[256];
|
||||
unsigned char *retstr = talloc_zero_array(mem_ctx, unsigned char, len);
|
||||
size_t i;
|
||||
|
||||
memset(retstr, '\0', sizeof(retstr));
|
||||
|
||||
if (len > sizeof(retstr)-1)
|
||||
len = sizeof(retstr) -1;
|
||||
generate_random_buffer( retstr, len);
|
||||
for (i = 0; i < len; i++)
|
||||
retstr[i] = c_list[ retstr[i] % (sizeof(c_list)-1) ];
|
||||
|
@ -33,7 +33,7 @@ ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_princip
|
||||
return ADS_ERROR_SYSTEM(ENOENT);
|
||||
}
|
||||
|
||||
new_password = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
|
||||
new_password = generate_random_str(talloc_tos(), DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
|
||||
|
||||
ret = kerberos_set_password(ads->auth.kdc_server, host_principal, password, host_principal, new_password, ads->auth.time_offset);
|
||||
|
||||
|
@ -775,7 +775,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
|
||||
ZERO_STRUCT(user_pol);
|
||||
|
||||
if (!r->in.machine_password) {
|
||||
r->in.machine_password = talloc_strdup(mem_ctx, generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH));
|
||||
r->in.machine_password = generate_random_str(mem_ctx, DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
|
||||
NT_STATUS_HAVE_NO_MEMORY(r->in.machine_password);
|
||||
}
|
||||
|
||||
|
@ -33,13 +33,12 @@ NTSTATUS trust_pw_change_and_store_it(struct rpc_pipe_client *cli, TALLOC_CTX *m
|
||||
{
|
||||
unsigned char new_trust_passwd_hash[16];
|
||||
char *new_trust_passwd;
|
||||
char *str;
|
||||
NTSTATUS nt_status;
|
||||
|
||||
/* Create a random machine account password */
|
||||
str = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
|
||||
new_trust_passwd = generate_random_str(mem_ctx, DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
|
||||
|
||||
if ((new_trust_passwd = talloc_strdup(mem_ctx, str)) == NULL) {
|
||||
if (new_trust_passwd == NULL) {
|
||||
DEBUG(0, ("talloc_strdup failed\n"));
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
@ -330,12 +330,8 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
|
||||
|
||||
/* Create a random machine account password */
|
||||
|
||||
{
|
||||
char *str;
|
||||
str = generate_random_str(DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
|
||||
clear_trust_password = SMB_STRDUP(str);
|
||||
E_md4hash(clear_trust_password, md4_trust_password);
|
||||
}
|
||||
clear_trust_password = generate_random_str(talloc_tos(), DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
|
||||
E_md4hash(clear_trust_password, md4_trust_password);
|
||||
|
||||
/* Set password on machine account */
|
||||
|
||||
@ -468,7 +464,7 @@ done:
|
||||
|
||||
cli_shutdown(cli);
|
||||
|
||||
SAFE_FREE(clear_trust_password);
|
||||
TALLOC_FREE(clear_trust_password);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
Reference in New Issue
Block a user