File: ubuntu.sh

package info (click to toggle)
scap-security-guide 0.1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 110,644 kB
  • sloc: xml: 241,883; sh: 73,777; python: 32,527; makefile: 27
file content (21 lines) | stat: -rw-r--r-- 621 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
# platform = Ubuntu 24.04
# check-import = stdout

filter_nodev=$(awk '/nodev/ { print $2 }' /proc/filesystems | paste -sd,)
readarray -t partitions < <(findmnt -n -l -k -it "${filter_nodev}" | awk '{ print $1 }')

# Ensure /tmp is also checked when tmpfs is used.
if grep -Pq "^tmpfs\h+/tmp" /proc/mounts; then
    partitions+=("/tmp")
fi

for partition in "${partitions[@]}"; do
    files=$(find "${partition}" -xdev -type f -nogroup)
    if [[ -n "${files}" ]]; then
        echo -e "Found ungroupowned files:\n${files}"
        exit "${XCCDF_RESULT_FAIL}"
    fi
done

exit "${XCCDF_RESULT_PASS}"