From patchwork Tue Oct 8 11:38:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Gothe X-Patchwork-Id: 1994230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=NK+VvwJa; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XNDyB3qy9z1xsn for ; Tue, 8 Oct 2024 22:56:32 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:List-Help: Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:From:List-Post:List-Id: Message-ID:MIME-Version:Date:Subject:To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=GfHZKVH7ZlOuXWuF3QIaOxVudBN8Ll1WBWXIUMwePG4=; b=NK+VvwJac94LHkoqX4kEAHk9di HYA/TnWu+jLYe9DQLeZ9cntCCEqBpzmwRGrbTeH8LnBWlpGU6heYw+cN/s9jYiM4e8GCX5r236Q9E 9VtcfNrC2MFTno8Eyr+D74wiyRJmRbmiDzWlSZ7EJUzvwnjQt7EM5sSNbYGJ8qdGOdU3xxIYJgsCc dVIJsVOZA0T3UAxbc+MWNWPuve0/1B427SAldAZS0P3ZG/ZwQMotnYTFIJ2PtptZkXgvuAnnf8oBN coN7zRpGgM7BT/oeHpbmfYUGQ3dI6N7ox5JxUvwBNtrdQcl35EZh2fRhVYLGDTM88HR44UWv0wqFS Dwgr7bEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sy8nP-00000005iIR-2OPD; Tue, 08 Oct 2024 11:54:31 +0000 To: "openwrt-devel@lists.openwrt.org" Subject: [PATCH procd] Disable implicit controlling TTY. Date: Tue, 8 Oct 2024 11:38:02 +0000 MIME-Version: 1.0 Message-ID: List-Id: OpenWrt Development List List-Post: X-Patchwork-Original-From: Markus Gothe via openwrt-devel From: Markus Gothe Precedence: list X-Mailman-Version: 2.1.34 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Markus Gothe List-Help: Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. 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 ---  inittab.c     | 2 +-  state.c       | 2 +-  utils/utils.c | 2 ++  3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/inittab.c b/inittab.c index 73a2174..46ca796 100644 --- 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 fb81248..cd64431 100644 --- 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; diff --git a/utils/utils.c b/utils/utils.c index 1939dbd..ba14269 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -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";