cmdline: Use new samba_getpass() function.
authorAndreas Schneider <asn@samba.org>
Fri, 23 Nov 2012 13:48:00 +0000 (14:48 +0100)
committerAndreas Schneider <asn@samba.org>
Mon, 3 Dec 2012 13:35:10 +0000 (14:35 +0100)
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
source4/lib/cmdline/credentials.c

index f919842e6aa7841fb8cadd4d8f3a1a6e2ac10350..fb517f3c0847e02271600b9c77189aa4a02a8cb4 100644 (file)
 
 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)