From: John Hodge Date: Fri, 22 Nov 2013 09:46:22 +0000 (+0800) Subject: Usermode/libposix - Clear stdin buffer in getpass X-Git-Tag: rel0.15~76 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=878297a3b9d4ea6fdf38f5552e171baf503116d0;p=tpg%2Facess2.git Usermode/libposix - Clear stdin buffer in getpass --- diff --git a/Usermode/Libraries/libposix.so_src/unistd.c b/Usermode/Libraries/libposix.so_src/unistd.c index 211948f8..f5b330da 100644 --- a/Usermode/Libraries/libposix.so_src/unistd.c +++ b/Usermode/Libraries/libposix.so_src/unistd.c @@ -242,6 +242,7 @@ char *getpass(const char *prompt) mode.OutputMode = 0; _SysIOCtl(STDIN_FILENO, PTY_IOCTL_SETMODE, &mode); fprintf(stderr, "%s", prompt); + fflush(stdin); // clear stdin buffer fgets(passbuf, PASS_MAX+1, stdin); fprintf(stderr, "\n"); for( int i = strlen(passbuf); i > 0 && (passbuf[i-1] == '\r' || passbuf[i-1] == '\n'); i -- ) @@ -270,5 +271,7 @@ int ttyname_r(int fd, char *buf, size_t buflen) _SysIOCtl(fd, PTY_IOCTL_GETID, NULL); + _SysDebug("TODO: ttyname_r"); + return ENOTIMPL; }