From 66298d808034bb606478ff66aa156bda4e7e3f2a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 20 Nov 2007 17:18:16 -0800 Subject: More pstring elimination. Jeremy. (This used to be commit 15074de938539e7a9c527d9a6d81792adc2ac3d0) --- source3/passdb/passdb.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'source3/passdb/passdb.c') diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index a9dd90eda1..754702e333 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -864,7 +864,7 @@ bool init_sam_from_buffer_v3(struct samu *sampass, uint8 *buf, uint32 buflen) uint32 lm_pw_len, nt_pw_len, nt_pw_hist_len, hourslen; uint32 pwHistLen = 0; bool ret = True; - fstring tmpstring; + fstring tmp_string; bool expand_explicit = lp_passdb_expand_explicit(); if(sampass == NULL || buf == NULL) { @@ -930,12 +930,12 @@ bool init_sam_from_buffer_v3(struct samu *sampass, uint8 *buf, uint32 buflen) pdb_set_fullname(sampass, fullname, PDB_SET); if (homedir) { - fstrcpy( tmpstring, homedir ); + fstrcpy( tmp_string, homedir ); if (expand_explicit) { - standard_sub_basic( username, domain, tmpstring, - sizeof(tmpstring) ); + standard_sub_basic( username, domain, tmp_string, + sizeof(tmp_string) ); } - pdb_set_homedir(sampass, tmpstring, PDB_SET); + pdb_set_homedir(sampass, tmp_string, PDB_SET); } else { pdb_set_homedir(sampass, @@ -950,12 +950,12 @@ bool init_sam_from_buffer_v3(struct samu *sampass, uint8 *buf, uint32 buflen) pdb_set_dir_drive(sampass, lp_logon_drive(), PDB_DEFAULT ); if (logon_script) { - fstrcpy( tmpstring, logon_script ); + fstrcpy( tmp_string, logon_script ); if (expand_explicit) { - standard_sub_basic( username, domain, tmpstring, - sizeof(tmpstring) ); + standard_sub_basic( username, domain, tmp_string, + sizeof(tmp_string) ); } - pdb_set_logon_script(sampass, tmpstring, PDB_SET); + pdb_set_logon_script(sampass, tmp_string, PDB_SET); } else { pdb_set_logon_script(sampass, @@ -965,12 +965,12 @@ bool init_sam_from_buffer_v3(struct samu *sampass, uint8 *buf, uint32 buflen) } if (profile_path) { - fstrcpy( tmpstring, profile_path ); + fstrcpy( tmp_string, profile_path ); if (expand_explicit) { - standard_sub_basic( username, domain, tmpstring, - sizeof(tmpstring) ); + standard_sub_basic( username, domain, tmp_string, + sizeof(tmp_string) ); } - pdb_set_profile_path(sampass, tmpstring, PDB_SET); + pdb_set_profile_path(sampass, tmp_string, PDB_SET); } else { pdb_set_profile_path(sampass, -- cgit From 7ef6c19074495110d5c0b698b05c4ee52a0744d6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Nov 2007 17:42:52 -0800 Subject: Remove pstrings from pam_smbpass - make local_password_change return malloced strings. Jeremy. (This used to be commit f652fe2bdb7a3a36e83dcf4b08347543fdffb9f0) --- source3/passdb/passdb.c | 51 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'source3/passdb/passdb.c') diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index 754702e333..2a4d4c4a0a 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -635,17 +635,18 @@ bool lookup_global_sam_name(const char *name, int flags, uint32_t *rid, Change a password entry in the local smbpasswd file. *************************************************************/ -NTSTATUS local_password_change(const char *user_name, int local_flags, - const char *new_passwd, - char *err_str, size_t err_str_len, - char *msg_str, size_t msg_str_len) +NTSTATUS local_password_change(const char *user_name, + int local_flags, + const char *new_passwd, + char **pp_err_str, + char **pp_msg_str) { struct samu *sam_pass=NULL; uint32 other_acb; NTSTATUS result; - *err_str = '\0'; - *msg_str = '\0'; + *pp_err_str = NULL; + *pp_msg_str = NULL; /* Get the smb passwd entry for this user */ @@ -689,12 +690,12 @@ NTSTATUS local_password_change(const char *user_name, int local_flags, } if (!NT_STATUS_IS_OK(result)) { - slprintf(err_str, err_str_len-1, "Failed to " "initialize account for user %s: %s\n", + asprintf(pp_err_str, "Failed to " "initialize account for user %s: %s\n", user_name, nt_errstr(result)); return result; } } else { - slprintf(err_str, err_str_len-1,"Failed to find entry for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to find entry for user %s.\n", user_name); return NT_STATUS_NO_SUCH_USER; } } else { @@ -707,19 +708,19 @@ NTSTATUS local_password_change(const char *user_name, int local_flags, other_acb = (pdb_get_acct_ctrl(sam_pass) & (~(ACB_WSTRUST|ACB_DOMTRUST|ACB_SVRTRUST|ACB_NORMAL))); if (local_flags & LOCAL_TRUST_ACCOUNT) { if (!pdb_set_acct_ctrl(sam_pass, ACB_WSTRUST | other_acb, PDB_CHANGED) ) { - slprintf(err_str, err_str_len - 1, "Failed to set 'trusted workstation account' flags for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to set 'trusted workstation account' flags for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } } else if (local_flags & LOCAL_INTERDOM_ACCOUNT) { if (!pdb_set_acct_ctrl(sam_pass, ACB_DOMTRUST | other_acb, PDB_CHANGED)) { - slprintf(err_str, err_str_len - 1, "Failed to set 'domain trust account' flags for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to set 'domain trust account' flags for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } } else { if (!pdb_set_acct_ctrl(sam_pass, ACB_NORMAL | other_acb, PDB_CHANGED)) { - slprintf(err_str, err_str_len - 1, "Failed to set 'normal account' flags for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to set 'normal account' flags for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } @@ -732,13 +733,13 @@ NTSTATUS local_password_change(const char *user_name, int local_flags, if (local_flags & LOCAL_DISABLE_USER) { if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)|ACB_DISABLED, PDB_CHANGED)) { - slprintf(err_str, err_str_len-1, "Failed to set 'disabled' flag for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to set 'disabled' flag for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } } else if (local_flags & LOCAL_ENABLE_USER) { if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)&(~ACB_DISABLED), PDB_CHANGED)) { - slprintf(err_str, err_str_len-1, "Failed to unset 'disabled' flag for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to unset 'disabled' flag for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } @@ -746,7 +747,7 @@ NTSTATUS local_password_change(const char *user_name, int local_flags, if (local_flags & LOCAL_SET_NO_PASSWORD) { if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)|ACB_PWNOTREQ, PDB_CHANGED)) { - slprintf(err_str, err_str_len-1, "Failed to set 'no password required' flag for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to set 'no password required' flag for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } @@ -762,19 +763,19 @@ NTSTATUS local_password_change(const char *user_name, int local_flags, */ if ((pdb_get_lanman_passwd(sam_pass)==NULL) && (pdb_get_acct_ctrl(sam_pass)&ACB_DISABLED)) { if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)&(~ACB_DISABLED), PDB_CHANGED)) { - slprintf(err_str, err_str_len-1, "Failed to unset 'disabled' flag for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to unset 'disabled' flag for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } } if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)&(~ACB_PWNOTREQ), PDB_CHANGED)) { - slprintf(err_str, err_str_len-1, "Failed to unset 'no password required' flag for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to unset 'no password required' flag for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } if (!pdb_set_plaintext_passwd (sam_pass, new_passwd)) { - slprintf(err_str, err_str_len-1, "Failed to set password for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to set password for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } @@ -782,34 +783,34 @@ NTSTATUS local_password_change(const char *user_name, int local_flags, if (local_flags & LOCAL_ADD_USER) { if (NT_STATUS_IS_OK(pdb_add_sam_account(sam_pass))) { - slprintf(msg_str, msg_str_len-1, "Added user %s.\n", user_name); + asprintf(pp_msg_str, "Added user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_OK; } else { - slprintf(err_str, err_str_len-1, "Failed to add entry for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to add entry for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } } else if (local_flags & LOCAL_DELETE_USER) { if (!NT_STATUS_IS_OK(pdb_delete_sam_account(sam_pass))) { - slprintf(err_str,err_str_len-1, "Failed to delete entry for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to delete entry for user %s.\n", user_name); TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } - slprintf(msg_str, msg_str_len-1, "Deleted user %s.\n", user_name); + asprintf(pp_msg_str, "Deleted user %s.\n", user_name); } else { result = pdb_update_sam_account(sam_pass); if(!NT_STATUS_IS_OK(result)) { - slprintf(err_str, err_str_len-1, "Failed to modify entry for user %s.\n", user_name); + asprintf(pp_err_str, "Failed to modify entry for user %s.\n", user_name); TALLOC_FREE(sam_pass); return result; } if(local_flags & LOCAL_DISABLE_USER) - slprintf(msg_str, msg_str_len-1, "Disabled user %s.\n", user_name); + asprintf(pp_msg_str, "Disabled user %s.\n", user_name); else if (local_flags & LOCAL_ENABLE_USER) - slprintf(msg_str, msg_str_len-1, "Enabled user %s.\n", user_name); + asprintf(pp_msg_str, "Enabled user %s.\n", user_name); else if (local_flags & LOCAL_SET_NO_PASSWORD) - slprintf(msg_str, msg_str_len-1, "User %s password set to none.\n", user_name); + asprintf(pp_msg_str, "User %s password set to none.\n", user_name); } TALLOC_FREE(sam_pass); -- cgit