]> git.pond.sub.org Git - empserver/commitdiff
client: New get_password()
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 27 Dec 2020 09:06:08 +0000 (10:06 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 23 Jan 2021 06:08:03 +0000 (07:08 +0100)
I'm going to drop use of getpass().  As a first step, weaken the bond
by hiding it in a separate function.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/client/login.c

index 61fe62f69644898d943a6c1b26e4680930b816c2..6707bc294445b275904eae9df1724d06d4f2da01 100644 (file)
@@ -29,7 +29,7 @@
  *  Known contributors to this file:
  *     Dave Pare, 1989
  *     Steve McClure, 1998
- *     Markus Armbruster, 2004-2009
+ *     Markus Armbruster, 2004-2020
  */
 
 #include <config.h>
 #include "misc.h"
 #include "proto.h"
 
-#ifndef HAVE_GETPASS
-#define getpass ersatz_getpass
 static char *
-ersatz_getpass(char *prompt)
+get_password(const char *prompt)
 {
+#ifdef HAVE_GETPASS
+    return getpass(prompt);
+#else
     static char buf[128];
     char *p;
     size_t len;
@@ -75,8 +76,8 @@ ersatz_getpass(char *prompt)
     if (p[len - 1] == '\n')
        p[len - 1] = 0;
     return p;
+#endif /* !HAVE_GETPASS */
 }
-#endif
 
 int
 login(int s, char *uname, char *cname, char *cpass,
@@ -123,7 +124,7 @@ login(int s, char *uname, char *cname, char *cpass,
        return 0;
     }
     if (cpass == NULL) {
-       cpass = getpass("Your name? ");
+       cpass = get_password("Your name? ");
        if (cpass == NULL || *cpass == 0)
            return 0;
     }