-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.1.2.5.4.sh
More file actions
36 lines (30 loc) · 727 Bytes
/
Copy path1.1.2.5.4.sh
File metadata and controls
36 lines (30 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
# CIS 1.1.2.5.4 Ensure noexec option set on /var/tmp partition
TARGET="/var/tmp"
STATUS=""
REASON=""
# Step 1: Check if module exists on disk
if [ ! -d "$TARGET" ]; then
STATUS=Failed
REASON="/var/tmp does not exist"
echo "$STATUS | $REASON"
exit 1
fi
# Step 2: Check if module is loaded
if ! findmnt -kn "$TARGET" >/dev/null 2>&1; then
STATUS=Failed
REASON="/var/tmp is not mounted"
echo "$STATUS | $REASON"
exit 1
fi
# Step 3: Check configuration
if findmnt -kn /var/tmp -o OPTIONS | grep -vq noexec; then
STATUS=Failed
REASON="noexec option is not set on /var/tmp"
echo "$STATUS | $REASON"
exit 1
fi
# Final pass
STATUS=Passed
echo "$STATUS |"
exit 0