mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 06:15:37 +00:00
Accept carriage return for EOL in addition to newline.
Since visudo doesn't alter the terminal settings it is possible for the terminal to have the ONLCR bit set in the output control flags. In that case, we will get a CR, not a NL when the user presses enter/return. One way this can happen is if visudo is run in the background from a shell that supports line editing and the editor restores the (cbreak-style) terminal mode when it finishes.
This commit is contained in:
@@ -312,7 +312,7 @@ main(int argc, char *argv[])
|
||||
continue;
|
||||
if (sp != TAILQ_FIRST(&sudoerslist)) {
|
||||
printf(_("press return to edit %s: "), sp->opath);
|
||||
while ((ch = getchar()) != EOF && ch != '\n')
|
||||
while ((ch = getchar()) != EOF && ch != '\r' && ch != '\n')
|
||||
continue;
|
||||
}
|
||||
edit_sudoers(sp, editor, editor_argc, editor_argv, -1);
|
||||
@@ -703,7 +703,7 @@ reparse_sudoers(char *editor, int editor_argc, char **editor_argv,
|
||||
bool modified = false;
|
||||
do {
|
||||
printf(_("press return to edit %s: "), sp->opath);
|
||||
while ((ch = getchar()) != EOF && ch != '\n')
|
||||
while ((ch = getchar()) != EOF && ch != '\r' && ch != '\n')
|
||||
continue;
|
||||
edit_sudoers(sp, editor, editor_argc, editor_argv, -1);
|
||||
if (sp->modified)
|
||||
@@ -854,7 +854,7 @@ whatnow(void)
|
||||
for (;;) {
|
||||
(void) fputs(_("What now? "), stdout);
|
||||
choice = getchar();
|
||||
for (c = choice; c != '\n' && c != EOF;)
|
||||
for (c = choice; c != '\r' && c != '\n' && c != EOF;)
|
||||
c = getchar();
|
||||
|
||||
switch (choice) {
|
||||
|
Reference in New Issue
Block a user