-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #879 from iankko/rpm_verify_permissions_remediation
[Enhancement] [RHEL/6] [RHEL/7] Add remediation for 'rpm_verify_permissions' rule
- Loading branch information
Showing
3 changed files
with
42 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# platform = multi_platform_rhel | ||
|
||
# Declare array to hold list of RPM packages we need to correct permissions for | ||
declare -a SETPERMS_RPM_LIST | ||
|
||
# Create a list of files on the system having permissions different from what | ||
# is expected by the RPM database | ||
FILES_WITH_INCORRECT_PERMS=($(rpm -Va | grep '^.M')) | ||
|
||
# For each file path from that list: | ||
# * Determine the RPM package the file path is shipped by, | ||
# * Include it into SETPERMS_RPM_LIST array | ||
|
||
for FILE_PATH in "${FILES_WITH_INCORRECT_PERMS[@]}" | ||
do | ||
RPM_PACKAGE=$(rpm -qf "$FILE_PATH") | ||
SETPERMS_RPM_LIST=("${SETPERMS_RPM_LIST[@]}" "$RPM_PACKAGE") | ||
done | ||
|
||
# Remove duplicate mention of same RPM in $SETPERMS_RPM_LIST (if any) | ||
SETPERMS_RPM_LIST=( $(echo "${SETPERMS_RPM_LIST[@]}" | sort -n | uniq) ) | ||
|
||
# For each of the RPM packages left in the list -- reset its permissions to the | ||
# correct values | ||
for RPM_PACKAGE in "${SETPERMS_RPM_LIST[@]}" | ||
do | ||
rpm --setperms "${RPM_PACKAGE}" | ||
done |