wbinfo: add wbinfo_prompt_pass.
authorGünther Deschner <gd@samba.org>
Tue, 19 Aug 2008 13:32:37 +0000 (15:32 +0200)
committerGünther Deschner <gd@samba.org>
Thu, 21 Aug 2008 10:13:32 +0000 (12:13 +0200)
Guenther
(cherry picked from commit 7cf6ed68236e7dd64657cb1087a5a687d6f59ad1)

source/nsswitch/wbinfo.c

index c1d41a53fdc785e91c867d38966d50a0df09c1f3..3ae3d218f4c3f161d1d6ac1a399116a334fa6c74 100644 (file)
@@ -879,6 +879,33 @@ static bool wbinfo_lookupname(const char *full_name)
        return true;
 }
 
+static char *wbinfo_prompt_pass(const char *prefix,
+                               const char *username)
+{
+       char *prompt;
+       const char *ret = NULL;
+
+       prompt = talloc_asprintf(talloc_tos(), "Enter %s's ", username);
+       if (!prompt) {
+               return NULL;
+       }
+       if (prefix) {
+               prompt = talloc_asprintf_append(prompt, "%s ", prefix);
+               if (!prompt) {
+                       return NULL;
+               }
+       }
+       prompt = talloc_asprintf_append(prompt, "password: ");
+       if (!prompt) {
+               return NULL;
+       }
+
+       ret = getpass(prompt);
+       TALLOC_FREE(prompt);
+
+       return SMB_STRDUP(ret);
+}
+
 /* Authenticate a user with a plaintext password */
 
 static bool wbinfo_auth_krb5(char *username, const char *cctype, uint32 flags)