inittab: Disable implicit controlling TTY.
authorMarkus Gothe <markus.gothe@genexis.eu>
Mon, 7 Oct 2024 11:30:46 +0000 (13:30 +0200)
committerJohn Crispin <john@phrozen.org>
Wed, 11 Dec 2024 11:09:18 +0000 (12:09 +0100)
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: https://github.com/openwrt/openwrt/issues/11306
Signed-off-by: Markus Gothe <markus.gothe@genexis.eu>
inittab.c
state.c
utils/utils.c

index 73a2174a97b6eb36778c1790e853c9ad18c000e8..46ca79685b60fc4907e7755c4d175915d47b25a9 100644 (file)
--- a/inittab.c
+++ b/inittab.c
@@ -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)
diff --git a/state.c b/state.c
index fb81248fd7e7bc7b588a82a5e667424af188cbab..cd64431b7930d82f7e8a6fc7ebbcd5ec392e87a2 100644 (file)
--- a/state.c
+++ b/state.c
@@ -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;
index 1939dbdcab72b02766f6fc04f306c33a64a14a0d..ba1426998425d5986d49e61bf38f143348c30635 100644 (file)
@@ -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";