Skip to content

Commit 7e03557

Browse files
committed
grub2: Add GRUB2_PASSWORD support, source custom.cfg
user.cfg, despite his name, is usually used to store GRUB2_PASSWORD variable: - grub2-set-password utility overwrite the whole file - security scanners look at the content of user.cfg https://github.com/ComplianceAsCode/content/blob/47fd3bcded59116ade8ea09eb396f363e37813d4/linux_os/guide/system/bootloader-grub2/uefi/grub2_uefi_password/oval/shared.xml Copy the content of the legacy /etc/grub.d/01_users as 01_users.cfg, and add 41_custom.cfg to source custom.cfg for people in need of custom configs. This gets us closer to classic grub2-mkconfig behaviour.
1 parent fc3518c commit 7e03557

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ install:
4040
.PHONY: install-grub-static
4141
install-grub-static:
4242
install -m 644 -D -t ${DESTDIR}$(PREFIX)/lib/bootupd/grub2-static src/grub2/*.cfg
43-
install -m 755 -d ${DESTDIR}$(PREFIX)/lib/bootupd/grub2-static/configs.d
43+
install -m 644 -D -t ${DESTDIR}$(PREFIX)/lib/bootupd/grub2-static/configs.d src/grub2/configs.d/*.cfg
4444

4545
.PHONY: install-systemd-unit
4646
install-systemd-unit:

src/grub2/configs.d/01_users.cfg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Keep the comment for grub2-set-password
2+
### BEGIN /etc/grub.d/01_users ###
3+
if [ -f ${prefix}/user.cfg ]; then
4+
source ${prefix}/user.cfg
5+
if [ -n "${GRUB2_PASSWORD}" ]; then
6+
set superusers="root"
7+
export superusers
8+
password_pbkdf2 root ${GRUB2_PASSWORD}
9+
fi
10+
fi

src/grub2/configs.d/41_custom.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if [ -f $prefix/custom.cfg ]; then
2+
source $prefix/custom.cfg
3+
fi

src/grub2/grub-static-post.cfg

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,5 @@ else
77
set timeout=1
88
fi
99

10-
# Import user defined configuration
11-
# tracker: https://github.com/coreos/fedora-coreos-tracker/issues/805
12-
if [ -f $prefix/user.cfg ]; then
13-
source $prefix/user.cfg
14-
fi
15-
1610
blscfg
1711

0 commit comments

Comments
 (0)