forked from pool/grub2
95a1540f87
- Add 0001-unix-do-not-close-stdin-in-grub_passwd_get.patch Fix reading password by grub2-mkpasswd-pbdk2 without controlling tty, e.g. when called from Xfce menu (boo#954519) OBS-URL: https://build.opensuse.org/request/show/345115 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=188
43 lines
1.2 KiB
Diff
43 lines
1.2 KiB
Diff
From 6a46cbcc5c1c746562fd7181bf0f2337db065201 Mon Sep 17 00:00:00 2001
|
|
From: Andrei Borzenkov <arvidjaar@gmail.com>
|
|
Date: Wed, 18 Nov 2015 22:23:58 +0300
|
|
Subject: [PATCH] unix: do not close stdin in grub_passwd_get
|
|
|
|
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
|
|
---
|
|
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;
|
|
}
|
|
--
|
|
1.9.1
|
|
|