New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use only first occurence from /etc/mtab #4959
Use only first occurence from /etc/mtab #4959
Conversation
The mount options of the first entry will be used. If there are multiple lines in `/etc/mtab` that match the same mount point, the variable `_previous_mount_opts` contained newline characters. These newlines were propagated to `/etc/fstab`. As a result, an invalid entry in /etc/fstab was created, `mount` command hasn't been successful and the oscap scan after remediation returned false.
In what situation there are multiple lines with the same mountpoint? Does it make sense to have a test scenario for that? |
It happened to our team during RHEL7 installation with OSCAP Anaconda Addon with OSPP profile at the moment the Bash remediation for rule mount_option_dev_shm_noexec has been applied.
Yes. |
I have added a test scenario |
@jan-cerny My question was more about how it came to be that there are two entries for the same mount point. Are they identical? If not, is the first one the entry in effect? |
They're 3 items, first is different and the other 2 are identical. I don't know which one is in effect. It also doesn't happen for me on a VM, it happened during system installation. |
Can you post example of how the /etc/mtab looks like? It might be actually valid as shown here. |
|
I have run a new kickstart installation of RHEL 7 using ospp profile. The remediation for rule mount_option_dev_shm_noexec doesn't break /etc/fstab syntax anymore. However, the rules in the report are evaluated as error and also other rules testing mount options are evaluated as error. After reboot all mount_option.* rules pass. I think it can be a specialty of Anaconda installation environment. |
Great! @jan-cerny Thanks for the fix and investigation. |
Description:
The mount options of the first entry will be used.
Rationale:
If there are multiple lines in
/etc/mtab
that match the same mount point, the variable_previous_mount_opts
contained newline characters. These newlines were propagated to/etc/fstab
. As a result, an invalid entry in/etc/fstab
was created,mount
command hasn't been successful and the oscap scan after remediation returned false.Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1754553