Skip to content

Commit

Permalink
Grub: support a password stanza inside a boot/title section
Browse files Browse the repository at this point in the history
The biggest change in this commit is changing the structure of lns: it now
says that boot sections have to come after the general menu_setting and
debian sections. Since 'password' is legal in both a top-level menu_setting
and in a boot section, that is necessary to keep the lens unambiguous.

Fixes hercules-team#229
  • Loading branch information
lutter committed May 22, 2015
1 parent 071175d commit 16c9bf2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lenses/grub.aug
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module Grub =
let kw_menu_arg (kw:regexp) = kw_arg kw "" " "

(* View: password_arg *)
let password_arg = [ key "password" .
let password_arg = [ command "password" "" .
(spc . [ switch "md5" ])? .
(spc . [ switch "encrypted" ])? .
spc . store (/[^ \t\n]+/ - /--[^ \t\n]+/) .
Expand Down Expand Up @@ -220,6 +220,7 @@ module Grub =
| map_line
| kw_pres "lock"
| kw_pres "makeactive"
| password_arg

(* View: boot *)
let boot =
Expand Down Expand Up @@ -281,7 +282,8 @@ module Grub =
*************************************************************************)

(* View: lns *)
let lns = (comment | empty | menu_setting | boot | debian)*
let lns = (comment | empty | menu_setting | debian)*
. (boot . (comment | empty | boot)*)?

(* View: filter *)
let filter = incl "/boot/grub/grub.conf"
Expand Down
17 changes: 17 additions & 0 deletions lenses/tests/test_grub.aug
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,20 @@ password --encrypted ^9^32kwzzX./3WISQ0C /boot/grub/custom.lst
{ "splash" = "silent" }
{ "showopts" } }
{ "initrd" = "(hd0,0)/initrd" } }

(* Password protected kernel, issue #229 *)
test Grub.lns get "title Password Protected Kernel
root (hd0,0)
kernel /vmlinuz ro root=/dev/mapper/root
initrd /initramfs
password --md5 secret\n" =
{ "title" = "Password Protected Kernel"
{ "root" = "(hd0,0)" }
{ "kernel" = "/vmlinuz"
{ "ro" }
{ "root" = "/dev/mapper/root" }
}
{ "initrd" = "/initramfs" }
{ "password" = "secret"
{ "md5" }
} }

0 comments on commit 16c9bf2

Please sign in to comment.