-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend mount_option_nodev_nonroot_local_partitions
The OVAL check is extended to read also data directly from the `/etc/fstab` file. This is useful in environments where the mount points are not mounted and OVAL partition objects don't matech. For example, this happens in the Image Builder environment. Similar to: #10200 Resolves: RHEL-45018
- Loading branch information
Showing
5 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
.../permissions/partitions/mount_option_nodev_nonroot_local_partitions/tests/complex.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
cat >/etc/fstab <<ENDOF | ||
# | ||
# /etc/fstab | ||
# Created by anaconda on Wed Aug 7 08:51:34 2025 | ||
# | ||
# Accessible filesystems, by reference, are maintained under '/dev/disk/'. | ||
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. | ||
# | ||
# After editing this file, run 'systemctl daemon-reload' to update systemd | ||
# units generated from this file. | ||
# | ||
/dev/mapper/system-root / xfs defaults 0 0 | ||
UUID=07fc30bd-875f-48bd-8863-e62e49e42716 /boot xfs defaults,nosuid 0 0 | ||
/dev/mapper/system-home /home xfs defaults,noexec,nosuid 0 0 | ||
/dev/mapper/system-tmp /tmp xfs defaults,noexec,nosuid 0 0 | ||
/dev/mapper/system-var /var xfs defaults 0 0 | ||
/dev/mapper/system-varlog /var/log xfs defaults,noexec,nosuid 0 0 | ||
/dev/mapper/system-varlogaudit /var/log/audit xfs defaults,noexec,nosuid 0 0 | ||
/dev/mapper/system-vartmp /var/tmp xfs defaults,noexec,nosuid 0 0 | ||
/dev/mapper/system-swap none swap defaults 0 0 | ||
tmpfs /dev/shm tmpfs defaults,relatime,inode64,noexec,nosuid 0 0 | ||
ENDOF |
23 changes: 23 additions & 0 deletions
23
...ns/partitions/mount_option_nodev_nonroot_local_partitions/tests/no_nodev_in_fstab.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
. $SHARED/partition.sh | ||
|
||
# Add nodev option to all records in fstab to ensure that test will | ||
# run on environment where everything is set correctly for rule check. | ||
cp /etc/fstab /etc/fstab.backup | ||
sed -i -e '/^#/d' -e '/^$/d' -e 's/\bnodev\b/,/g' -e 's/,,//g' -e 's/\s,\s/defaults/g' /etc/fstab.backup | ||
awk '{$4 = $4",nodev"; print}' /etc/fstab.backup > /etc/fstab | ||
# Remount all partitions. (--all option can't be used because it doesn't | ||
# mount e.g. /boot partition | ||
declare -a partitions=( $(awk '{print $2}' /etc/fstab | grep "^/\w") ) | ||
for partition in ${partitions[@]}; do | ||
mount -o remount "$partition" | ||
done | ||
|
||
# partition intentionally not mounted to test /etc/fstab detection | ||
PARTITION="/dev/new_partition1"; create_partition | ||
make_fstab_given_partition_line "/tmp/partition1" ext2 defaults | ||
|
||
# partition intentionally not mounted to test /etc/fstab detection | ||
PARTITION="/dev/new_partition2"; create_partition | ||
make_fstab_given_partition_line "/tmp/partition2" ext2 defaults |