[PATCH 14/16] cmdline: Use new samba_getpass() function.

Andreas Schneider asn at samba.org
Tue Nov 27 04:23:54 MST 2012


Signed-off-by: Andreas Schneider <asn at samba.org>
---
 source4/lib/cmdline/credentials.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/source4/lib/cmdline/credentials.c b/source4/lib/cmdline/credentials.c
index f919842..fb517f3 100644
--- a/source4/lib/cmdline/credentials.c
+++ b/source4/lib/cmdline/credentials.c
@@ -24,19 +24,23 @@
 
 static const char *cmdline_get_userpassword(struct cli_credentials *credentials)
 {
-	char *ret;
 	TALLOC_CTX *mem_ctx = talloc_new(NULL);
-
 	const char *prompt_name = cli_credentials_get_unparsed_name(credentials, mem_ctx);
 	const char *prompt;
+	static char pwd[256]; /* FIXME: Return a dup pwd and free it. */
+	int rc;
 
 	prompt = talloc_asprintf(mem_ctx, "Password for [%s]:", 
 				 prompt_name);
 
-	ret = getpass(prompt);
-
+	memset(pwd, '\0', sizeof(pwd));
+	rc = samba_getpass(prompt, pwd, sizeof(pwd), false, false);
 	talloc_free(mem_ctx);
-	return ret;
+	if (rc < 0) {
+		return NULL;
+	}
+
+	return pwd;
 }
 
 bool cli_credentials_set_cmdline_callbacks(struct cli_credentials *cred)
-- 
1.8.0




More information about the samba-technical mailing list