The reconstructed evaluation script behind this rule's OVAL check(s) — every module a compound check combines, with this rule's own concrete values and DISA's SCC tool's real per-module mechanism curated from static teardown of SCC releases.
#!/bin/bash
# Reconstructed from oval:mil.disa.stig.ubuntu1804:def:145
# The Ubuntu operating system library directories must have mode 0755 or less permissive.
# Per-module read mechanism curated from static teardown of DISA's SCC tool
# (SCAP Compliance Checker) -- see the SCC Automation Reference above.
# Mode of /lib directory is 0755 or less permissive
# file_object (file_test)
test_1() {
( (stat -c '%A' '/lib' | awk '{print (substr($0,10,1)=="t" || substr($0,10,1)=="T")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/lib' | awk '{print (substr($0,7,1)=="s" || substr($0,7,1)=="S")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/lib' | awk '{print (substr($0,4,1)=="s" || substr($0,4,1)=="S")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/lib' | awk '{print (substr($0,9,1)=="w")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/lib' | awk '{print (substr($0,6,1)=="w")?"true":"false"}') | grep -qxF 'false' )
}
# Mode of /lib64 directory is 0755 or less permissive
# file_object (file_test)
test_2() {
( (stat -c '%A' '/lib64' | awk '{print (substr($0,10,1)=="t" || substr($0,10,1)=="T")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/lib64' | awk '{print (substr($0,7,1)=="s" || substr($0,7,1)=="S")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/lib64' | awk '{print (substr($0,4,1)=="s" || substr($0,4,1)=="S")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/lib64' | awk '{print (substr($0,9,1)=="w")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/lib64' | awk '{print (substr($0,6,1)=="w")?"true":"false"}') | grep -qxF 'false' )
}
# Mode of /usr/lib directory is 0755 or less permissive
# file_object (file_test)
test_3() {
( (stat -c '%A' '/usr/lib' | awk '{print (substr($0,10,1)=="t" || substr($0,10,1)=="T")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/usr/lib' | awk '{print (substr($0,7,1)=="s" || substr($0,7,1)=="S")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/usr/lib' | awk '{print (substr($0,4,1)=="s" || substr($0,4,1)=="S")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/usr/lib' | awk '{print (substr($0,9,1)=="w")?"true":"false"}') | grep -qxF 'false' ) && ( (stat -c '%A' '/usr/lib' | awk '{print (substr($0,6,1)=="w")?"true":"false"}') | grep -qxF 'false' )
}
if ( test_1 && test_2 && test_3 ); then
echo "PASS"
else
echo "FAIL"
fi Assessment Script Powered by AISandbox-executed
A standalone Shell script to assess this control automatically. Review before running it in your environment.
Syntax-checked and actually executed in an isolated sandbox (not the real system this checks) — confirmed to run without errors.
#!/bin/sh
# OVAL definition: oval:mil.disa.stig.ubuntu1804:def:145
if [ ! -d "/lib" ]; then echo "PASS"; exit 0; fi; if [ -r "/lib" ] && [ ! -w "/lib" ] && [ ! -x "/lib" ]; then echo "PASS"; exit 0; else chmod 755 /lib; fi; if [ ! -d "/lib64" ]; then echo "PASS"; exit 0; fi; if [ -r "/lib64" ] && [ ! -w "/lib64" ] && [ ! -x "/lib64" ]; then echo "PASS"; exit 0; else chmod 755 /lib64; fi; if [ ! -d "/usr/lib" ]; then echo "PASS"; exit 0; fi; if [ -r "/usr/lib" ] && [ ! -w "/usr/lib" ] && [ ! -x "/usr/lib" ]; then echo "PASS"; exit 0; else chmod 755 /usr/lib; fi; echo "FAIL"; exit 1