mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-10-06 10:59:48 +08:00
Fix_Issue_1828: Respect forever flag on failed login
The shell main loop used a single result variable both to record whether the previous login/command attempt succeeded and to decide whether the loop should continue. When the login function failed after repeated incorrect passwords, result became false, and the loop condition then exited the shell regardless of the forever flag being set. Track login failures separately with a new login_failed flag, and use it alongside result in the loop condition so that a failed login correctly falls through to a new login attempt when forever is set, matching the documented behavior of that flag. Other exit paths EOF, explicit logout and exit are unaffected.
This commit is contained in:
committed by
Joel Sherrill
parent
f5ced1f843
commit
181e86a199
@@ -1072,6 +1072,7 @@ static bool shell_main_loop(
|
||||
)
|
||||
{
|
||||
bool result = false;
|
||||
bool login_failed = false;
|
||||
int line = 0;
|
||||
int cmd_count;
|
||||
char *cmds[RTEMS_SHELL_CMD_COUNT];
|
||||
@@ -1114,6 +1115,7 @@ static bool shell_main_loop(
|
||||
}
|
||||
|
||||
do {
|
||||
login_failed = false;
|
||||
result = rtems_shell_init_user_env();
|
||||
|
||||
if (result) {
|
||||
@@ -1124,6 +1126,7 @@ static bool shell_main_loop(
|
||||
*/
|
||||
if (shell_env->login_check != NULL) {
|
||||
result = rtems_shell_login(shell_env, stdin, stdout);
|
||||
login_failed = !result;
|
||||
} else {
|
||||
setuid(shell_env->uid);
|
||||
setgid(shell_env->gid);
|
||||
@@ -1228,7 +1231,7 @@ static bool shell_main_loop(
|
||||
fflush( stderr );
|
||||
}
|
||||
shell_std_debug("end: %d %d\n", result, shell_env->forever);
|
||||
} while (result && shell_env->forever);
|
||||
} while (shell_env->forever && (result || login_failed));
|
||||
}
|
||||
|
||||
free(cmds[0]);
|
||||
|
||||
Reference in New Issue
Block a user