From patchwork Tue Jul 18 13:04:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Smalley X-Patchwork-Id: 9848309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF54B602A7 for ; Tue, 18 Jul 2017 13:01:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF20926E96 for ; Tue, 18 Jul 2017 13:01:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3FE8285AF; Tue, 18 Jul 2017 13:01:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from ucol19pa13.eemsg.mail.mil (ucol19pa13.eemsg.mail.mil [214.24.24.86]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D587285B0 for ; Tue, 18 Jul 2017 13:01:16 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.40,377,1496102400"; d="scan'208";a="493429085" Received: from emsm-gh1-uea11.ncsc.mil ([214.29.60.3]) by ucol19pa13.eemsg.mail.mil with ESMTP; 18 Jul 2017 13:01:10 +0000 IronPort-PHdr: =?us-ascii?q?9a23=3ASdjR6RFmFf+kaQX7iSeqU51GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ76oc+wAkXT6L1XgUPTWs2DsrQf1LqQ7vurADFIyK3CmU5BWaQEbwUCh8?= =?us-ascii?q?QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnZBUin4YBF4?= =?us-ascii?q?IuXzB576k9W81+f0/YbaJQpPmmmTe7R3eS6qoB3Ru89euo5rLqI821OduXdTU/?= =?us-ascii?q?hHzmNvY1SIllDz4dnmr80ryDhZp/90r50Iaq79ZaltFbE=3D?= X-IPAS-Result: =?us-ascii?q?A2AJAgDHTEFZ/wHyM5BeGgEBAQECAQEBAQgBAQEBFQEBAQE?= =?us-ascii?q?CAQEBAQgBAQEBgwIrYnsSjwGpECsLiElXAQEBAQEBAQECAWoogjMigksCdgMDC?= =?us-ascii?q?QIXMQgDAWwFiAZPgUUNELA/JgKLQgWPCYETfYUnBZ5HhyyMGQ2LLYZcSJQyV4E?= =?us-ascii?q?KJwkCHwghD4UQgmJaAYc7gj8BAQE?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.NCSC.MIL with ESMTP; 18 Jul 2017 13:01:09 +0000 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id v6ID0nbF029954; Tue, 18 Jul 2017 09:00:55 -0400 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id v6ID0iKS199800 for ; Tue, 18 Jul 2017 09:00:44 -0400 Received: from moss-pluto.infosec.tycho.ncsc.mil (moss-pluto [192.168.25.131]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id v6ID0gJX029941; Tue, 18 Jul 2017 09:00:42 -0400 From: Stephen Smalley To: selinux@tycho.nsa.gov Date: Tue, 18 Jul 2017 09:04:53 -0400 Message-Id: <20170718130454.21079-1-sds@tycho.nsa.gov> X-Mailer: git-send-email 2.9.4 Subject: [PATCH 1/2] Revert "open_init_pty: Do not make stdin and stdout non-blocking" X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: Cc: Stephen Smalley Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP Making stdin/stdout non-blocking causes open_init_pty to hang if they are closed, ala ./open_init_pty bash -c 'echo hello; exec >&- 2>&- <&-; sleep 1; ' and per https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=474956#10 This reverts commit fb081eb64b36a9de5a43f3d69d9e628b6eb1afc7. Reported-by: Laurent Bigonville Signed-off-by: Stephen Smalley --- policycoreutils/run_init/open_init_pty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/policycoreutils/run_init/open_init_pty.c b/policycoreutils/run_init/open_init_pty.c index b37ae4d..6e25ea3 100644 --- a/policycoreutils/run_init/open_init_pty.c +++ b/policycoreutils/run_init/open_init_pty.c @@ -276,8 +276,10 @@ int main(int argc, char *argv[]) } } - /* Non blocking mode for the pty master. */ + /* Non blocking mode for all file descriptors. */ setfd_nonblock(pty_master); + setfd_nonblock(STDIN_FILENO); + setfd_nonblock(STDOUT_FILENO); if (isatty(STDIN_FILENO)) { if (tty_semi_raw(STDIN_FILENO) < 0) {