diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-11-30 22:13:48 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-11-30 22:13:48 +0000 |
commit | 6f70c0705783ecc12a783a6c09bb0495a3d85261 (patch) | |
tree | e2fcd001c4e0b35d05dcf0a4cbf10957e6ecedf9 /cpukit | |
parent | 2009-11-30 Fernando Nicodemos <fgnicodemos@terra.com.br> (diff) | |
download | rtems-6f70c0705783ecc12a783a6c09bb0495a3d85261.tar.bz2 |
2009-11-30 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/shell/login_prompt.c: Fix problem where timeout on login
prompt at console results in tight loop repeating login prompt.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/ChangeLog | 5 | ||||
-rw-r--r-- | cpukit/libmisc/shell/login_prompt.c | 24 |
2 files changed, 19 insertions, 10 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index f52266601e..a517eb4d46 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,8 @@ +2009-11-30 Joel Sherrill <joel.sherrill@oarcorp.com> + + * libmisc/shell/login_prompt.c: Fix problem where timeout on login + prompt at console results in tight loop repeating login prompt. + 2009-11-30 Sebastian Huber <sebastian.huber@embedded-brains.de> * score/src/threaddelayended.c: Clear only the states that are used to diff --git a/cpukit/libmisc/shell/login_prompt.c b/cpukit/libmisc/shell/login_prompt.c index 2c04667ee3..d277b7f0d5 100644 --- a/cpukit/libmisc/shell/login_prompt.c +++ b/cpukit/libmisc/shell/login_prompt.c @@ -70,6 +70,7 @@ #include <termios.h> #include <unistd.h> #include <ctype.h> +#include <errno.h> #include <rtems/shell.h> @@ -98,14 +99,15 @@ static bool rtems_shell_get_text( tcdrain( fd_in); if (out != NULL){ - tcdrain( fileno( out)); + tcdrain( fileno(out) ); } while (true) { - int c = fgetc( in); + int c = fgetc(in); switch (c) { case EOF: + clearerr( in ); return false; case '\n': case '\r': @@ -138,6 +140,7 @@ static bool rtems_shell_get_text( break; } } + return true; } bool rtems_shell_login_prompt( @@ -147,7 +150,7 @@ bool rtems_shell_login_prompt( rtems_shell_login_check_t check ) { - int fd_in = fileno( in); + int fd_in = fileno(in); struct termios termios_previous; bool restore_termios = false; int i = 0; @@ -168,22 +171,23 @@ bool rtems_shell_login_prompt( char user [32]; char passphrase [128]; - fprintf( out, "%s login: ", device); - fflush( out); - if ( !rtems_shell_get_text( in, out, user, sizeof( user)) ) + fprintf( out, "%s login: ", device ); + fflush( out ); + result = rtems_shell_get_text( in, out, user, sizeof(user) ); + if ( !result ) break; fflush( in); fprintf( out, "Password: "); fflush( out); - if ( !rtems_shell_get_text( in, NULL, passphrase, sizeof( passphrase)) ) + result = rtems_shell_get_text( in, NULL, passphrase, sizeof(passphrase) ); + if ( !result ) break; fputc( '\n', out); - result = check( user, passphrase); - if (result) { + result = check( user, passphrase ); + if (result) break; - } fprintf( out, "Login incorrect\n\n"); sleep( 2); |