c789522
From 056a956aea898f9d3ee34ecad9660addc3f3108c Mon Sep 17 00:00:00 2001
9d15b4d
From: Robert Marshall <rmarshall@redhat.com>
9d15b4d
Date: Mon, 22 Feb 2016 15:30:05 -0500
31cddd6
Subject: [PATCH] Warn if grub password will not be read (#1290803)
9d15b4d
9d15b4d
It is possible for a system to have never run grub-mkconfig and add the
9d15b4d
section that reads the user.cfg file which contains a user set GRUB
9d15b4d
password. Users in that scenario will now be warned that grub-mkconfig
9d15b4d
must be run prior to their newly set password taking effect.
9d15b4d
9d15b4d
Resolves: rhbz#1290803
9d15b4d
---
9d15b4d
 util/grub-setpassword.in | 5 +++++
9d15b4d
 1 file changed, 5 insertions(+)
9d15b4d
9d15b4d
diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in
ec4acbb
index dd76f00fc0e..fb9d3a3b6f9 100644
9d15b4d
--- a/util/grub-setpassword.in
9d15b4d
+++ b/util/grub-setpassword.in
9d15b4d
@@ -121,3 +121,8 @@ fi
9d15b4d
 install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || :
9d15b4d
 chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || :
9d15b4d
 echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg"
9d15b4d
+
9d15b4d
+if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${grubdir}/grub.cfg"; then
9d15b4d
+    echo "WARNING: The current configuration lacks password support!"
9d15b4d
+    echo "Update your configuration with @grub_mkconfig@ to support this feature."
9d15b4d
+fi