#!/bin/bash

NAGIOS_OK=0
NAGIOS_WARNING=1
NAGIOS_ERROR=2
NAGIOS_UNKNOWN=3

PAKITI_RESULT="pakiti_results"

if [ -f "$PAKITI_RESULT" ]; then
    cve=$(echo $0 | sed 's/.*check_//')
    grep -q "$cve" "$PAKITI_RESULT" 2>/dev/null
    if [ $? -eq 1 ]; then
        echo "No $cve vulnerability found, skipping the mitigation check"
        exit $NAGIOS_OK
    fi
fi
if [ "$(sysctl user.max_user_namespaces)" = "user.max_user_namespaces = 0" ] || [ "$(sysctl user.max_net_namespaces)" = "user.max_net_namespaces = 0" ]; then
    echo "user namespaces or net namespaces are disabled"
    exit $NAGIOS_OK
fi

echo "No mitigation found for CVE-2023-32233"
exit $NAGIOS_ERROR
