Skip to content

Commit

Permalink
audits added and updated
Browse files Browse the repository at this point in the history
  • Loading branch information
chanakyavasantha committed Dec 20, 2023
1 parent 843944d commit 1ffc1a7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions audit/audit_dev_shm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

echo "Auditing the /dev/shm partition for 'nodev' option..."

if findmnt --kernel /dev/shm | grep -q "nodev"; then
echo "PASS: 'nodev' option is set for /dev/shm."
else
echo "FAIL: 'nodev' option is NOT set for /dev/shm."
fi
43 changes: 43 additions & 0 deletions audit/audit_time_sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

output=""
l_chrony=""
l_ntp=""
l_sdtd=""

# Check if chrony is installed
dpkg-query -W chrony > /dev/null 2>&1 && l_chrony="y"

# Check if ntp is installed
dpkg-query -W ntp > /dev/null 2>&1 && l_ntp="y"

# Check if systemd-timesyncd is enabled
if systemctl list-units --all --type=service | grep -q 'systemd-timesyncd.service'; then
if systemctl is-enabled systemd-timesyncd.service | grep -q 'enabled'; then
l_sdtd="y"
fi
fi

# Determine which time synchronization daemon is in use
if [[ "$l_chrony" = "y" && "$l_ntp" != "y" && "$l_sdtd" != "y" ]]; then
output="$output\n- chrony is in use on the system"
elif [[ "$l_chrony" != "y" && "$l_ntp" = "y" && "$l_sdtd" != "y" ]]; then
output="$output\n- ntp is in use on the system"
# Additional audit for ntp configuration
grep -P '^(\s*(server|pool)\s+\S+)' /etc/ntp.conf && echo "NTP configuration is correct."
ps -ef | awk '(/[n]tpd/ && $1!="ntp") { print $1 }' || echo "ntpd daemon is running as the user ntp."
grep -P '^(\s*RUNASUSER=ntp)' /etc/init.d/ntp && echo "RUNASUSER is set to ntp in /etc/init.d/ntp."
elif [[ "$l_chrony" != "y" && "$l_ntp" != "y" && "$l_sdtd" = "y" ]]; then
output="$output\n- systemd-timesyncd is in use on the system"
else
[[ "$l_chrony" = "y" && "$l_ntp" = "y" ]] && output="$output\n- both chrony and ntp are in use on the system"
[[ "$l_chrony" = "y" && "$l_sdtd" = "y" ]] && output="$output\n- both chrony and systemd-timesyncd are in use on the system"
[[ "$l_ntp" = "y" && "$l_sdtd" = "y" ]] && output="$output\n- both ntp and systemd-timesyncd are in use on the system"
fi

# Output results
if [ -n "$output" ]; then
echo -e "\n- PASS:\n$output\n"
else
echo -e "\n- FAIL:\nNo time synchronization service is active or properly configured.\n"
fi
Empty file added audit/audit_tmp.sh
Empty file.

0 comments on commit 1ffc1a7

Please sign in to comment.