Skip to content

Conversation

@crobinso
Copy link

Fix the fstab lens to handle consecutive commas in mount options (e.g., "rw,,nodev"). This has been seen in the wild via libguestfs/ virt-v2v:

https://issues.redhat.com/browse/RHEL-77279

The fix changes the comma separator from matching a single comma to matching one or more consecutive commas.

🤖 Generated with Claude Code

@rwmjones
Copy link
Contributor

This works for me. However it doesn't parse:

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

saying:

/home/rjones/d/augeas/lenses/tests/test_fstab.aug:187.2-199.3:exception thrown in test
/home/rjones/d/augeas/lenses/tests/test_fstab.aug:187.7-.99:exception: Iterated lens matched less than it should
    Lens: /home/rjones/d/augeas/lenses/fstab.aug:36.12-.42:
      Last match: /home/rjones/d/augeas/lenses/fstab.aug:31.19-33.76:
      Not matching: /home/rjones/d/augeas/lenses/util.aug:111.22-.67:
    Error encountered at 1:68 (68 characters into string)
    <nodev,nosuid,noexec,relatime|=|,, 0 0\n>                   

Not sure whether we care.

@crobinso
Copy link
Author

This works for me. However it doesn't parse:

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

saying:

/home/rjones/d/augeas/lenses/tests/test_fstab.aug:187.2-199.3:exception thrown in test
/home/rjones/d/augeas/lenses/tests/test_fstab.aug:187.7-.99:exception: Iterated lens matched less than it should
    Lens: /home/rjones/d/augeas/lenses/fstab.aug:36.12-.42:
      Last match: /home/rjones/d/augeas/lenses/fstab.aug:31.19-33.76:
      Not matching: /home/rjones/d/augeas/lenses/util.aug:111.22-.67:
    Error encountered at 1:68 (68 characters into string)
    <nodev,nosuid,noexec,relatime|=|,, 0 0\n>                   

Not sure whether we care.

Good catch. I fixed the patch to test + address that now

@rwmjones
Copy link
Contributor

Looks fine to me. Note I'm unable to merge stuff in Augeas.

@twied
Copy link

twied commented Oct 16, 2025

Question for someone with more insight than me: Are empty mount options filtered out by mount, or are they visible to the mount.type helpers? If the latter is the case, it might be preferential to allow empty mount options instead of allowing consecutive commas.

@crobinso
Copy link
Author

In my testing, the multiple commas were ignored. Now looking at util-linux code the opstr parsing basically iterates over the string using ul_optstr_next: https://github.com/util-linux/util-linux/blob/master/lib/strutils.c#L1234

Option parsing stops at the first comma, and then next iteration strips all leading commas

Fix the fstab lens to handle consecutive commas in mount options
(e.g., "rw,,nodev"). This has been seen in the wild via libguestfs/
virt-v2v:

https://issues.redhat.com/browse/RHEL-77279

Handle multiple commas as separators.
Also handle multiple commas at the start and end of the option
line, all like mount does.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Cole Robinson <[email protected]>
@crobinso
Copy link
Author

Updated now to deal with leading commas too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants