Disables CCSM or XCSM debug logging with system restart.
Note : Run the script as Local System User
import subprocess
import os
def check_directory():
if os.path.exists("/Library/Application Support/COMODO/CCS"):
return "CCSM"
elif os.path.exists("/Library/Application Support/Xcitium Client - Security"):
return "XCSM"
else:
return "EM"
def reboot_mac():
try:
# Use the shutdown command with the -r (reboot) option
# "-r now" tells the system to reboot immediately.
subprocess.check_call(["sudo", "shutdown", "-r", "now"])
except subprocess.CalledProcessError as e:
print("Failed to reboot the device. Error:", e)
sys.exit(1)
product_type = check_directory()
print(product_type)
# Bash script to disable debug logging
bash_script = f"""#!/bin/bash
if [ {product_type} = "CCSM" ]; then
sudo defaults write com.comodo.FileAccessDaemon logLevel 4
elif [ {product_type} = "XCSM" ]; then
sudo /usr/libexec/PlistBuddy -c "Set :logLevel info" "/Library/Application Support/Xcitium Client - Security/settings.plist"
fi
"""
# Function to execute commands
def execute(arguments):
p = subprocess.Popen(arguments, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
output, error = p.communicate()
if output:
print(output)
# Write scripts to disk
script_path = f"/Library/Caches/Collect{product_type}enableLogs.sh"
with open(script_path, 'w') as f:
f.write(bash_script)
# Execute bash script to disable logging
execute(f"sh {script_path}")
os.remove(script_path)
print(f"{product_type} debug logging is disabled successfully")
print("Rebooting the device...")
reboot_mac()
Comments