mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 19:09:43 +00:00
fix: Update firewall management to use socketfilterfw for improved reliability on macOS.
This commit is contained in:
@@ -260,8 +260,7 @@ ask_for_security_fixes() {
|
||||
}
|
||||
|
||||
apply_firewall_fix() {
|
||||
if sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 1; then
|
||||
sudo pkill -HUP socketfilterfw 2> /dev/null || true
|
||||
if sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on > /dev/null 2>&1; then
|
||||
echo -e " ${GREEN}${ICON_SUCCESS}${NC} Firewall enabled"
|
||||
FIREWALL_DISABLED=false
|
||||
return 0
|
||||
|
||||
@@ -113,10 +113,10 @@ check_filevault() {
|
||||
check_firewall() {
|
||||
# Check whitelist
|
||||
if command -v is_whitelisted > /dev/null && is_whitelisted "firewall"; then return; fi
|
||||
# Check firewall status
|
||||
# Check firewall status using socketfilterfw (more reliable than defaults on modern macOS)
|
||||
unset FIREWALL_DISABLED
|
||||
local firewall_status=$(defaults read /Library/Preferences/com.apple.alf globalstate 2> /dev/null || echo "0")
|
||||
if [[ "$firewall_status" == "1" || "$firewall_status" == "2" ]]; then
|
||||
local firewall_output=$(sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate 2> /dev/null || echo "")
|
||||
if [[ "$firewall_output" == *"State = 1"* ]] || [[ "$firewall_output" == *"State = 2"* ]]; then
|
||||
echo -e " ${GREEN}✓${NC} Firewall Network protection enabled"
|
||||
else
|
||||
echo -e " ${YELLOW}${ICON_WARNING}${NC} Firewall ${YELLOW}Network protection disabled${NC}"
|
||||
|
||||
@@ -132,7 +132,7 @@ perform_auto_fix() {
|
||||
# Fix Firewall
|
||||
if [[ -n "${FIREWALL_DISABLED:-}" && "${FIREWALL_DISABLED}" == "true" ]]; then
|
||||
echo -e "${BLUE}Enabling Firewall...${NC}"
|
||||
if sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 1 2> /dev/null; then
|
||||
if sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on > /dev/null 2>&1; then
|
||||
echo -e "${GREEN}✓${NC} Firewall enabled"
|
||||
((fixed_count++))
|
||||
fixed_items+=("Firewall enabled")
|
||||
|
||||
@@ -76,6 +76,7 @@ sudo() {
|
||||
echo "Installing Rosetta 2 stub output"
|
||||
return 0
|
||||
;;
|
||||
/usr/libexec/ApplicationFirewall/socketfilterfw) return 0 ;;
|
||||
*) return 0 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user