Skip to content

Commit

Permalink
Disable implicit controlling TTY.
Browse files Browse the repository at this point in the history
Disable the use of implicit controlling
TTYs. They will be enabled on demand.

This fixes a bug where 2 or more
consecutive Ctrl-C at the login prompt
triggers a reboot of the device.

Closes: openwrt/openwrt#11306

Signed-off-by: Markus Gothe <[email protected]>
  • Loading branch information
Markus Gothe committed Oct 8, 2024
1 parent f230c11 commit ae268eb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion inittab.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static int dev_exist(const char *dev)
if (dfd < 0)
return 0;

fd = openat(dfd, dev, O_RDONLY);
fd = openat(dfd, dev, O_RDONLY|O_NOCTTY);
close(dfd);

if (fd < 0)
Expand Down
2 changes: 1 addition & 1 deletion state.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void set_console(void)
return;
}
while (tty!=NULL) {
f = open(tty, O_RDONLY);
f = open(tty, O_RDONLY|O_NOCTTY);
if (f >= 0) {
close(f);
break;
Expand Down
2 changes: 2 additions & 0 deletions utils/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ int patch_fd(const char *device, int fd, int flags)
{
int dfd, nfd;

flags |= O_NOCTTY;

if (device == NULL)
device = "/dev/null";

Expand Down

0 comments on commit ae268eb

Please sign in to comment.