From da07ef727f6b80676359239860c35ad11eb3dccc Mon Sep 17 00:00:00 2001 From: Edgar Aguilar Date: Thu, 4 May 2023 14:39:31 -0600 Subject: [PATCH 1/3] Fix issue when adding fstab entries with iso9660 This fs type has an issue in which the entries in mtab could describe a value for blocksize, however that's not recognized by fstab, there the name for this same option is 'block'. The issue can be seen from rule mount_option_nodev_nonroot_local_partitions, if there was a cdrom mounted manually, and then this rule was remediated. The system wouldn't be able to reboot Signed-off-by: Edgar Aguilar --- shared/macros/10-bash.jinja | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shared/macros/10-bash.jinja b/shared/macros/10-bash.jinja index 44642ab1ea8..f839a1d44f3 100644 --- a/shared/macros/10-bash.jinja +++ b/shared/macros/10-bash.jinja @@ -1586,6 +1586,10 @@ if ! grep "$mount_point_match_regexp" /etc/fstab; then previous_mount_opts=$(grep "$mount_point_match_regexp" /etc/mtab | head -1 | awk '{print $4}' \ | sed -E "s/(rw|defaults|seclabel|{{{ mount_opt }}})(,|$)//g;s/,$//") [ "$previous_mount_opts" ] && previous_mount_opts+="," + # In iso9660 filesystems mtab could describe a "blocksize" value, this should be reflected in fstab as "block" + if [ {{{ type }}} == "iso9660" ] ; then + previous_mount_opts=$(sed 's/blocksize=/block=/' <<< "$previous_mount_opts") + fi echo "{{{ fs_spec }}} {{{ mount_point }}} {{{ type }}} defaults,${previous_mount_opts}{{{ mount_opt }}} 0 0" >> /etc/fstab # If the mount_opt option is not already in the mount point's /etc/fstab entry, add it elif ! grep "$mount_point_match_regexp" /etc/fstab | grep "{{{ mount_opt }}}"; then From 46bf26975de3c7284a099cff271366b6a7ef4c86 Mon Sep 17 00:00:00 2001 From: Edgar Aguilar Date: Thu, 18 May 2023 11:59:32 -0600 Subject: [PATCH 2/3] Address Gate test issue on empty string Signed-off-by: Edgar Aguilar --- shared/macros/10-bash.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/macros/10-bash.jinja b/shared/macros/10-bash.jinja index f839a1d44f3..d0233f388ac 100644 --- a/shared/macros/10-bash.jinja +++ b/shared/macros/10-bash.jinja @@ -1587,7 +1587,7 @@ if ! grep "$mount_point_match_regexp" /etc/fstab; then | sed -E "s/(rw|defaults|seclabel|{{{ mount_opt }}})(,|$)//g;s/,$//") [ "$previous_mount_opts" ] && previous_mount_opts+="," # In iso9660 filesystems mtab could describe a "blocksize" value, this should be reflected in fstab as "block" - if [ {{{ type }}} == "iso9660" ] ; then + if [ "{{{ type }}}" == "iso9660" ] ; then previous_mount_opts=$(sed 's/blocksize=/block=/' <<< "$previous_mount_opts") fi echo "{{{ fs_spec }}} {{{ mount_point }}} {{{ type }}} defaults,${previous_mount_opts}{{{ mount_opt }}} 0 0" >> /etc/fstab From 4a1dc26e386d4e54c99d8104fbc1c29711479fac Mon Sep 17 00:00:00 2001 From: Edgar Aguilar Date: Thu, 25 May 2023 11:52:11 -0600 Subject: [PATCH 3/3] Update shared/macros/10-bash.jinja This address failing tests due to warnings Co-authored-by: Marcus Burghardt <2074099+marcusburghardt@users.noreply.github.com> --- shared/macros/10-bash.jinja | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shared/macros/10-bash.jinja b/shared/macros/10-bash.jinja index d0233f388ac..9df667b950f 100644 --- a/shared/macros/10-bash.jinja +++ b/shared/macros/10-bash.jinja @@ -1586,8 +1586,10 @@ if ! grep "$mount_point_match_regexp" /etc/fstab; then previous_mount_opts=$(grep "$mount_point_match_regexp" /etc/mtab | head -1 | awk '{print $4}' \ | sed -E "s/(rw|defaults|seclabel|{{{ mount_opt }}})(,|$)//g;s/,$//") [ "$previous_mount_opts" ] && previous_mount_opts+="," - # In iso9660 filesystems mtab could describe a "blocksize" value, this should be reflected in fstab as "block" - if [ "{{{ type }}}" == "iso9660" ] ; then + # In iso9660 filesystems mtab could describe a "blocksize" value, this should be reflected in + # fstab as "block". The next variable is to satisfy shellcheck SC2050. + fs_type="{{{ type }}}" + if [ "$fs_type" == "iso9660" ] ; then previous_mount_opts=$(sed 's/blocksize=/block=/' <<< "$previous_mount_opts") fi echo "{{{ fs_spec }}} {{{ mount_point }}} {{{ type }}} defaults,${previous_mount_opts}{{{ mount_opt }}} 0 0" >> /etc/fstab