Skip to content

Commit

Permalink
lenses/fstab.aug: Allow individual mount options to be empty
Browse files Browse the repository at this point in the history
Mount allows mount-option fields to be empty (I think it ignores
them), but augeas gave an error.  Allow this to be parsed.  This does
not preserve the empty option on write, but that should not change the
meaning of the entry.

Example:
  /dev/mapper/vg00-vartmp /var/tmp xfs rw,,nodev,nosuid,noexec,relatime 0 0

Fixes: https://issues.redhat.com/browse/RHEL-77279
Fixes: #832
Signed-off-by: Richard W.M. Jones <[email protected]>
  • Loading branch information
rwmjones committed Feb 6, 2025
1 parent acd7fde commit fd361c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lenses/fstab.aug
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ module Fstab =
Build.opt_list lns comma

(* A mount option label can't contain comma, comment, equals, or space *)
let optlabel = /[^,#= \n\t]+/
let mntoptlabel = /[^,#= \n\t]+/

let comma_sep_list (l:string) =
let mntopt_list (l:string) =
let value = [ label "value" . Util.del_str "=" . ( store Rx.neg1 )? ] in
let lns = [ label l . store optlabel . value? ] in
Build.opt_list lns comma
let lns = [ label l . store mntoptlabel . value? ] in
Build.opt_list lns comma+

let record = [ seq "mntent" .
Util.indent .
[ label "spec" . store spec ] . sep_tab .
[ label "file" . store file ] . sep_tab .
vfstype_list "vfstype" .
(sep_tab . comma_sep_list "opt" .
(sep_tab . mntopt_list "opt" .
(sep_comma_tab . [ label "dump" . store /[0-9]+/ ] .
( sep_spc . [ label "passno" . store /[0-9]+/ ])? )? )?
. Util.comment_or_eol ]
Expand Down
12 changes: 12 additions & 0 deletions lenses/tests/test_fstab.aug
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ module Test_fstab =
{ "passno" = "0" }
}

(* RHEL-77279 - Allow empty option *)
test Fstab.lns get "/dev/mapper/foo-bar / xfs rw,,nodev 0 0\n" =
{ "1"
{ "spec" = "/dev/mapper/foo-bar" }
{ "file" = "/" }
{ "vfstype" = "xfs" }
{ "opt" = "rw" }
{ "opt" = "nodev" }
{ "dump" = "0" }
{ "passno" = "0" }
}

(* Local Variables: *)
(* mode: caml *)
(* End: *)

0 comments on commit fd361c7

Please sign in to comment.