Skip to content

Commit

Permalink
bugfix: mount_option: handle commented lines
Browse files Browse the repository at this point in the history
From fstab(5):
...
       Each filesystem is described on a separate line. Fields on each
       line are separated by tabs or spaces. Lines starting with '#' are
       comments. Blank lines are ignored.
...

Line like:
  # /var needs dev
should be ignored.

Add test for this issue.
  • Loading branch information
maage committed May 1, 2023
1 parent 3d9b19c commit ee5352b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion shared/templates/mount_option/oval.template
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<ind:textfilecontent54_object version="1"
id="object_{{{ local_id }}}_in_fstab">
<ind:filepath>/etc/fstab</ind:filepath>
<ind:pattern operation="pattern match">^[\s]*[\S]+[\s]+{{{ POINTREGEX }}}[\s]+[\S]+[\s]+([\S]+)</ind:pattern>
<ind:pattern operation="pattern match">^[\s]*(?!#)[\S]+[\s]+{{{ POINTREGEX }}}[\s]+[\S]+[\s]+([\S]+)</ind:pattern>
<ind:instance datatype="int">1</ind:instance>
</ind:textfilecontent54_object>

Expand Down
16 changes: 16 additions & 0 deletions shared/templates/mount_option/tests/fstab_comment.pass.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# platform = multi_platform_all
. $SHARED/partition.sh

clean_up_partition {{{ MOUNTPOINT }}}

create_partition

make_fstab_given_partition_line {{{ MOUNTPOINT }}} ext2 defaults
# comment last line added above to be ignored
sed -Ei '${s/^/#/}' /etc/fstab

make_fstab_given_partition_line {{{ MOUNTPOINT }}} ext2 {{{ MOUNTOPTION }}}

mount_partition {{{ MOUNTPOINT }}} || true

0 comments on commit ee5352b

Please sign in to comment.