From 8052e522542c004cb8fe6970d3313184a27763c2 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 20 May 2013 16:20:57 +0800 Subject: [PATCH] Usermode/libposix - Fixed getpass for new PTY --- .../Libraries/libposix.so_src/include_exp/unistd.h | 1 + Usermode/Libraries/libposix.so_src/unistd.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Usermode/Libraries/libposix.so_src/include_exp/unistd.h b/Usermode/Libraries/libposix.so_src/include_exp/unistd.h index 8a644a74..118cdfe6 100644 --- a/Usermode/Libraries/libposix.so_src/include_exp/unistd.h +++ b/Usermode/Libraries/libposix.so_src/include_exp/unistd.h @@ -39,6 +39,7 @@ extern int close(int fd); extern ssize_t write(int fd, const void *buf, size_t count); extern ssize_t read(int fd, void *buf, size_t count); +extern off_t lseek(int fd, off_t offset, int whence); extern int fork(void); extern int execv(const char *b, char *v[]); diff --git a/Usermode/Libraries/libposix.so_src/unistd.c b/Usermode/Libraries/libposix.so_src/unistd.c index 78896db9..e41ebfd0 100644 --- a/Usermode/Libraries/libposix.so_src/unistd.c +++ b/Usermode/Libraries/libposix.so_src/unistd.c @@ -11,6 +11,7 @@ #include #include #include +#include // === CODE === int unlink(const char *pathname) @@ -78,6 +79,11 @@ int seek(int fd, int whence, off_t dest) return _SysSeek(fd, whence, dest); } +off_t lseek(int fd, off_t offset, int whence) +{ + return _SysSeek(fd, whence, offset); +} + off_t tell(int fd) { return _SysTell(fd); @@ -180,11 +186,19 @@ int mkdir(const char *pathname, mode_t mode) char *getpass(const char *prompt) { static char passbuf[PASS_MAX+1]; + struct ptymode oldmode, mode; + _SysIOCtl(STDIN_FILENO, PTY_IOCTL_GETMODE, &oldmode); + mode.InputMode = PTYIMODE_CANON; + mode.OutputMode = 0; + _SysIOCtl(STDIN_FILENO, PTY_IOCTL_SETMODE, &mode); fprintf(stderr, "%s", prompt); 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 -- ) passbuf[i-1] = 0; + + _SysIOCtl(STDIN_FILENO, PTY_IOCTL_SETMODE, &oldmode); + return passbuf; } -- 2.20.1