grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] unix: do not close stdin in grub_passwd_get


From: Vladimir 'phcoder' Serbinenko
Subject: Re: [PATCH] unix: do not close stdin in grub_passwd_get
Date: Wed, 18 Nov 2015 20:02:38 +0100

Go ahead.

Le 18 nov. 2015 7:52 PM, "Andrei Borzenkov" <address@hidden> a écrit :
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)

_______________________________________________
Grub-devel mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/grub-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]