-
Notifications
You must be signed in to change notification settings - Fork 690
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
Move daemon.* to /var/log/messages #12433
Merged
jan-cerny
merged 2 commits into
ComplianceAsCode:master
from
Mab879:update_rsyslog_remote_access_monitoring
Oct 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 3 additions & 2 deletions
5
...ing/ensure_rsyslog_log_file_configuration/rsyslog_remote_access_monitoring/bash/shared.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 |
---|---|---|
@@ -1,25 +1,26 @@ | ||
# platform = multi_platform_all | ||
|
||
declare -A REMOTE_METHODS=( ['auth.*']='^[^#]*auth\.\*.*$' ['authpriv.*']='^[^#]*authpriv\.\*.*$' ['daemon.*']='^[^#]*daemon\.\*.*$' ) | ||
declare -A LOCATIONS=( ['auth.*']='/var/log/secure' ['authpriv.*']='/var/log/secure' ['daemon.*']='/var/log/messages' ) | ||
|
||
if [[ ! -f /etc/rsyslog.conf ]]; then | ||
# Something is not right, create the file | ||
touch /etc/rsyslog.conf | ||
fi | ||
|
||
APPEND_LINE=$(sed -rn '/^\S+\s+\/var\/log\/secure$/p' /etc/rsyslog.conf) | ||
|
||
# Loop through the remote methods associative array | ||
for K in "${!REMOTE_METHODS[@]}" | ||
do | ||
# Check to see if selector/value exists | ||
if ! grep -rq "${REMOTE_METHODS[$K]}" /etc/rsyslog.*; then | ||
APPEND_LINE=$(sed -rn "/^\S+\s+\${LOCATIONS[$K]}$/p" /etc/rsyslog.conf) | ||
# Make sure we have a line to insert after, otherwise append to end | ||
if [[ ! -z ${APPEND_LINE} ]]; then | ||
# Add selector to file | ||
sed -r -i "0,/^(\S+\s+\/var\/log\/secure$)/s//\1\n${K} \/var\/log\/secure/" /etc/rsyslog.conf | ||
else | ||
echo "${K} /var/log/secure" >> /etc/rsyslog.conf | ||
echo "${K} ${LOCATIONS[$K]}" >> /etc/rsyslog.conf | ||
fi | ||
fi | ||
done |
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
29 changes: 29 additions & 0 deletions
29
...slog_log_file_configuration/rsyslog_remote_access_monitoring/tests/differnt_files.pass.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,29 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_all | ||
|
||
declare -A REMOTE_METHODS=( ['auth.*']='^.*auth\.\*.*$' ['authpriv.*']='^.*authpriv\.\*.*$' ['daemon.*']='^.*daemon\.\*.*$' ) | ||
RSYSLOG_CONF='/etc/rsyslog.conf' | ||
RSYSLOG_D_FOLDER='/etc/rsyslog.d' | ||
RSYSLOG_D_FILES='/etc/rsyslog.d/*' | ||
|
||
|
||
# clean up .d conf files (if applicable) | ||
if [[ -d ${RSYSLOG_D_FOLDER} ]]; then | ||
for rsyslog_d_file in ${RSYSLOG_D_FILES} | ||
do | ||
for K in ${!REMOTE_METHODS[@]} | ||
do | ||
if grep -q "${REMOTE_METHODS[$K]}" ${rsyslog_d_file}; then | ||
sed -i "/${REMOTE_METHODS[$K]}/d" ${rsyslog_d_file} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The curly braces aren't needed if the variable isn't an array. |
||
fi | ||
done | ||
done | ||
fi | ||
|
||
if [[ ! -f /etc/rsyslog.conf ]]; then | ||
# Something is not right, create the file | ||
touch /etc/rsyslog.conf | ||
fi | ||
|
||
echo "auth.*,authpriv.* /var/log/secure" >> $RSYSLOG_CONF | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should there be a comma or a semicolon between the asterisk and a? The rule description has a semicolon and here you have a comma. |
||
echo "daemon.* /var/log/messages" >> $RSYSLOG_CONF |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in the test scenario file name