Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zz7p9-00027L-Tz for mharc-grub-devel@gnu.org; Wed, 18 Nov 2015 13:51:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zz7p7-00022K-1G for grub-devel@gnu.org; Wed, 18 Nov 2015 13:51:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zz7p3-0001cc-QV for grub-devel@gnu.org; Wed, 18 Nov 2015 13:51:16 -0500 Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]:33859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zz7p3-0001cX-JJ for grub-devel@gnu.org; Wed, 18 Nov 2015 13:51:13 -0500 Received: by lbbcs9 with SMTP id cs9so30047509lbb.1 for ; Wed, 18 Nov 2015 10:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=9u9gD9N0HwcVta9G2j4E1PLOToMm1TtUMMxdB1RNijQ=; b=RvbOG0TkX1poQAdDXd77cqTYcBf1gEgpa/YIB35H9SoGd34pfDjecuToQaRDfr4QLU U9zVxRQMZEZW2/ZLllaH93XFUzzDon6ZHE5vpOKFTtQDA6sg5eki+70yEGV2XmQ4PrJW 2LlUpDBDy7rKD1pDYhbpij23hbFYREVGO6eZogyZtCV3cKpBUS/P19s6LN9UYvVAbkuZ 93kVRtjLBsMoyLr7CInH9YJVapXthCMnGt8BDDdy2i1a26O3gMW552/GHih9tsv8Q4io qlXv/mqLGZdU8KJjJGKTEqEBs67zScr+nQVTpitOq5etrWiOZR6yKSn5+53DgoInTgyR Dy1A== X-Received: by 10.112.129.70 with SMTP id nu6mr460563lbb.88.1447872672750; Wed, 18 Nov 2015 10:51:12 -0800 (PST) Received: from localhost.localdomain (ppp91-76-25-247.pppoe.mtu-net.ru. [91.76.25.247]) by smtp.gmail.com with ESMTPSA id gh1sm619243lbc.19.2015.11.18.10.51.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Nov 2015 10:51:11 -0800 (PST) From: Andrei Borzenkov To: grub-devel@gnu.org Subject: [PATCH] unix: do not close stdin in grub_passwd_get Date: Wed, 18 Nov 2015 21:51:07 +0300 Message-Id: <1447872667-4652-1-git-send-email-arvidjaar@gmail.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22b X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2015 18:51:18 -0000 This makes it impossible to read from stdin without controlling tty: 10:/mnt # echo -e passwd\\npasswd | setsid ./grub-mkpasswd-pbkdf2 Enter password: Reenter password: ./grub-mkpasswd-pbkdf2: error: failure to read password. 10:/mnt --- Is there anything I missed and we *want* to close stdin under some conditions? grub-core/osdep/unix/password.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/unix/password.c b/grub-core/osdep/unix/password.c index 4b9507b..9996b24 100644 --- a/grub-core/osdep/unix/password.c +++ b/grub-core/osdep/unix/password.c @@ -54,7 +54,8 @@ grub_password_get (char buf[], unsigned buf_size) grub_memset (buf, 0, buf_size); if (!fgets (buf, buf_size, stdin)) { - fclose (in); + if (in != stdin) + fclose (in); return 0; } ptr = buf + strlen (buf) - 1; @@ -67,7 +68,8 @@ grub_password_get (char buf[], unsigned buf_size) grub_xputs ("\n"); grub_refresh (); - fclose (in); + if (in != stdin) + fclose (in); return 1; } -- tg: (50d6f38..) bnc/954519 (depends on: master)