Exploit databaseDownload repository ZIP
GH-5e2a2740ae5d32aabba34ee9076bb6cc
soliantconsulting/cve-2025-46295-fix-fms
Sources for CVE-2025-46295
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files11
soliantconsulting/cve-2025-46295-fix-fmsRevision c1816f9996d2
- ↑..Parent directory
- .gitkeep
- backup_restore.sh
- error_handling.sh
- filemaker_detection.sh
- fmsadmin_integration.sh
- installation.sh
- temporary_file_management.sh
- ubuntu_optimizations.sh
- update_download.sh
- user_interface.sh
- utilities.sh
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
scripts/ubuntu/modules/ubuntu_optimizations.sh
Shell · 26,271 bytes#!/bin/bash
# FileMaker Security Updater - Ubuntu Platform Optimizations Module
# Provides Ubuntu-specific features including notifications, sudo handling, and systemd integration
#region Ubuntu Notification System Integration
# Send a Ubuntu notification using the native notification system
# Usage: send_ubuntu_notification <title> <message> [type] [urgency]
send_ubuntu_notification() {
local title="$1"
local message="$2"
local type="${3:-Info}"
local urgency="${4:-normal}"
# Check if notify-send is available
if ! command -v notify-send >/dev/null 2>&1; then
write_log_entry "DEBUG" "UbuntuNotifications" "SendNotification" "notify-send not available for notifications"
return 1
fi
# Determine icon and urgency based on type
local icon="dialog-information"
local notification_urgency="normal"
case "$type" in
"Success")
icon="dialog-information"
notification_urgency="normal"
;;
"Warning")
icon="dialog-warning"
notification_urgency="normal"
;;
"Error")
icon="dialog-error"
notification_urgency="critical"
;;
*)
icon="dialog-information"
notification_urgency="normal"
;;
esac
# Use custom urgency if provided
if [ "$urgency" != "normal" ]; then
notification_urgency="$urgency"
fi
# Send notification using notify-send
if notify-send --icon="$icon" --urgency="$notification_urgency" --expire-time=5000 "$title" "$message" 2>/dev/null; then
write_log_entry "INFO" "UbuntuNotifications" "SendNotification" "Ubuntu notification sent successfully" "title:$title,type:$type,urgency:$notification_urgency"
return 0
else
write_log_entry "WARN" "UbuntuNotifications" "SendNotification" "Failed to send Ubuntu notification" "title:$title,error:notify-send failed"
# Fallback to console output with color
local color=""
case "$type" in
"Success") color="\033[32m" ;; # Green
"Warning") color="\033[33m" ;; # Yellow
"Error") color="\033[31m" ;; # Red
*) color="\033[37m" ;; # White
esac
echo -e "${color}NOTIFICATION: $title - $message\033[0m"
return 1
fi
}
# Send a notification about the FileMaker update process
# Usage: send_update_notification <phase> <status> [details]
send_update_notification() {
local phase="$1"
local status="$2"
local details="${3:-}"
local title="FileMaker Security Update"
local type="Info"
local urgency="normal"
case "$status" in
"Started")
type="Info"
urgency="low"
;;
"Completed")
type="Success"
urgency="normal"
;;
"Failed")
type="Error"
urgency="critical"
;;
esac
local message=""
case "$phase" in
"Detection")
case "$status" in
"Started") message="Scanning for FileMaker Server installations..." ;;
"Completed") message="FileMaker Server detected. $details" ;;
"Failed") message="Failed to detect FileMaker Server. $details" ;;
esac
;;
"Backup")
case "$status" in
"Started") message="Creating backup of FileMaker Server..." ;;
"Completed") message="Backup completed successfully. $details" ;;
"Failed") message="Backup creation failed. $details" ;;
esac
;;
"Download")
case "$status" in
"Started") message="Downloading security update..." ;;
"Completed") message="Security update downloaded and verified. $details" ;;
"Failed") message="Download failed. $details" ;;
esac
;;
"Installation")
case "$status" in
"Started") message="Installing security update..." ;;
"Completed") message="Security update installed successfully. $details" ;;
"Failed") message="Installation failed. $details" ;;
esac
;;
"Validation")
case "$status" in
"Started") message="Validating update installation..." ;;
"Completed") message="Update validation successful. CVE-2025-46295 resolved. $details" ;;
"Failed") message="Update validation failed. $details" ;;
esac
;;
"Completion")
case "$status" in
"Completed") message="FileMaker Server security update completed successfully. System is now protected against CVE-2025-46295." ;;
"Failed") message="FileMaker Server security update failed. Manual intervention required. $details" ;;
esac
;;
esac
send_ubuntu_notification "$title" "$message" "$type" "$urgency"
}
# Send a desktop notification with custom action buttons (if supported)
# Usage: send_enhanced_notification <title> <message> [type] [action_label] [action_command]
send_enhanced_notification() {
local title="$1"
local message="$2"
local type="${3:-Info}"
local action_label="$4"
local action_command="$5"
# Check if zenity is available for enhanced notifications
if command -v zenity >/dev/null 2>&1; then
local zenity_type="info"
case "$type" in
"Success") zenity_type="info" ;;
"Warning") zenity_type="warning" ;;
"Error") zenity_type="error" ;;
*) zenity_type="info" ;;
esac
# Show zenity dialog with action button if provided
if [ -n "$action_label" ] && [ -n "$action_command" ]; then
if zenity --"$zenity_type" --title="$title" --text="$message" --ok-label="$action_label" --cancel-label="Close" 2>/dev/null; then
# User clicked action button
eval "$action_command" &
fi
return 0
else
zenity --"$zenity_type" --title="$title" --text="$message" 2>/dev/null
return 0
fi
fi
# Fallback to standard notification
send_ubuntu_notification "$title" "$message" "$type"
}
#endregion
#region Sudo Privilege Escalation Handling
# Check if the current process has administrator privileges
# Usage: test_is_elevated
test_is_elevated() {
# Check if running as root
if [ "$EUID" -eq 0 ]; then
write_log_entry "DEBUG" "SudoHandler" "CheckElevation" "Running as root user" "{\"user\":\"$(whoami)\",\"euid\":\"$EUID\"}"
return 0
fi
# Check if user is in sudo group
if groups | grep -q sudo; then
write_log_entry "DEBUG" "SudoHandler" "CheckElevation" "User is in sudo group" "{\"user\":\"$(whoami)\",\"groups\":\"$(groups)\"}"
return 0
fi
# Check if user can sudo without password for specific commands
if sudo -n true 2>/dev/null; then
write_log_entry "DEBUG" "SudoHandler" "CheckElevation" "User has passwordless sudo access" "{\"user\":\"$(whoami)\"}"
return 0
fi
write_log_entry "DEBUG" "SudoHandler" "CheckElevation" "User does not have elevated privileges" "{\"user\":\"$(whoami)\",\"euid\":\"$EUID\"}"
return 1
}
# Request sudo privileges with proper prompting
# Usage: request_sudo_elevation [reason]
request_sudo_elevation() {
local reason="${1:-FileMaker Server security update requires administrator privileges}"
write_log_entry "INFO" "SudoHandler" "RequestElevation" "Requesting sudo elevation" "{\"reason\":\"$reason\"}"
# Send notification about privilege request
send_ubuntu_notification "FileMaker Security Updater" "Administrator privileges required. Please enter your password when prompted." "Warning" "normal"
echo "Administrator privileges are required for this operation."
echo "Reason: $reason"
echo ""
# Test sudo access with a simple command
if sudo -v; then
write_log_entry "INFO" "SudoHandler" "RequestElevation" "Sudo elevation granted successfully"
# Keep sudo session alive for the duration of the script
# This runs in the background and refreshes sudo every 5 minutes
while true; do
sleep 300 # 5 minutes
sudo -n true 2>/dev/null || break
done &
return 0
else
write_log_entry "ERROR" "SudoHandler" "RequestElevation" "Sudo elevation failed or cancelled"
send_ubuntu_notification "FileMaker Security Updater" "Administrator privileges are required to continue. Update cancelled." "Error" "critical"
echo "Administrator privileges are required to run this script."
echo "Please run the script with sudo or ensure your user account has administrator privileges."
return 1
fi
}
# Ensure the script has administrator privileges, requesting elevation if needed
# Usage: assert_administrator_privileges [reason]
assert_administrator_privileges() {
local reason="${1:-FileMaker Server security update operations require administrator privileges}"
if test_is_elevated; then
write_log_entry "INFO" "SudoHandler" "AssertPrivileges" "Administrator privileges confirmed"
return 0
fi
echo "Administrator privileges required. Requesting elevation..."
if request_sudo_elevation "$reason"; then
return 0
else
return 1
fi
}
# Execute a command with sudo if needed
# Usage: execute_with_sudo <command> [args...]
execute_with_sudo() {
local command="$1"
shift
if test_is_elevated; then
# Already elevated, run directly
"$command" "$@"
else
# Need sudo
sudo "$command" "$@"
fi
}
#endregion
#region Systemd Integration for Service Management
# Get systemd service status for FileMaker Server
# Usage: get_filemaker_systemd_services
get_filemaker_systemd_services() {
local services=()
# Common FileMaker Server service names on Ubuntu
local potential_services=(
"filemaker-server"
"fmserver"
"filemaker"
"claris-filemaker-server"
)
for service in "${potential_services[@]}"; do
if systemctl list-unit-files | grep -q "^${service}.service"; then
local status=$(systemctl is-active "$service" 2>/dev/null || echo "inactive")
local enabled=$(systemctl is-enabled "$service" 2>/dev/null || echo "disabled")
services+=("{\"name\":\"$service\",\"status\":\"$status\",\"enabled\":\"$enabled\"}")
write_log_entry "DEBUG" "SystemdIntegration" "ServiceDiscovery" "Found FileMaker service" "{\"service\":\"$service\",\"status\":\"$status\",\"enabled\":\"$enabled\"}"
fi
done
# Return services as JSON array
if [ ${#services[@]} -gt 0 ]; then
printf '[%s]' "$(IFS=','; echo "${services[*]}")"
else
echo "[]"
fi
}
# Stop FileMaker Server services using systemd
# Usage: stop_filemaker_services
stop_filemaker_services() {
local services_json=$(get_filemaker_systemd_services)
local service_count=$(echo "$services_json" | jq length)
if [ "$service_count" -eq 0 ]; then
write_log_entry "INFO" "SystemdIntegration" "StopServices" "No FileMaker services found to stop"
return 0
fi
local stopped_count=0
local failed_services=()
for ((i=0; i<service_count; i++)); do
local service_name=$(echo "$services_json" | jq -r ".[$i].name")
local service_status=$(echo "$services_json" | jq -r ".[$i].status")
if [ "$service_status" = "active" ]; then
write_log_entry "INFO" "SystemdIntegration" "StopService" "Stopping service: $service_name"
if execute_with_sudo systemctl stop "$service_name"; then
((stopped_count++))
write_log_entry "INFO" "SystemdIntegration" "StopService" "Service stopped successfully: $service_name"
else
failed_services+=("$service_name")
write_log_entry "ERROR" "SystemdIntegration" "StopService" "Failed to stop service: $service_name"
fi
else
write_log_entry "DEBUG" "SystemdIntegration" "StopService" "Service already inactive: $service_name"
fi
done
if [ ${#failed_services[@]} -gt 0 ]; then
write_log_entry "ERROR" "SystemdIntegration" "StopServices" "Failed to stop some services" "{\"failed_services\":$(printf '%s\n' "${failed_services[@]}" | jq -R . | jq -s .)}"
return 1
fi
write_log_entry "INFO" "SystemdIntegration" "StopServices" "All services stopped successfully" "{\"stopped_count\":$stopped_count}"
return 0
}
# Start FileMaker Server services using systemd
# Usage: start_filemaker_services
start_filemaker_services() {
local services_json=$(get_filemaker_systemd_services)
local service_count=$(echo "$services_json" | jq length)
if [ "$service_count" -eq 0 ]; then
write_log_entry "INFO" "SystemdIntegration" "StartServices" "No FileMaker services found to start"
return 0
fi
local started_count=0
local failed_services=()
for ((i=0; i<service_count; i++)); do
local service_name=$(echo "$services_json" | jq -r ".[$i].name")
local service_enabled=$(echo "$services_json" | jq -r ".[$i].enabled")
write_log_entry "INFO" "SystemdIntegration" "StartService" "Starting service: $service_name"
if execute_with_sudo systemctl start "$service_name"; then
((started_count++))
write_log_entry "INFO" "SystemdIntegration" "StartService" "Service started successfully: $service_name"
# Enable service if it was previously enabled
if [ "$service_enabled" = "enabled" ]; then
execute_with_sudo systemctl enable "$service_name" 2>/dev/null || true
fi
else
failed_services+=("$service_name")
write_log_entry "ERROR" "SystemdIntegration" "StartService" "Failed to start service: $service_name"
fi
done
if [ ${#failed_services[@]} -gt 0 ]; then
write_log_entry "ERROR" "SystemdIntegration" "StartServices" "Failed to start some services" "{\"failed_services\":$(printf '%s\n' "${failed_services[@]}" | jq -R . | jq -s .)}"
return 1
fi
write_log_entry "INFO" "SystemdIntegration" "StartServices" "All services started successfully" "{\"started_count\":$started_count}"
return 0
}
# Restart FileMaker Server services using systemd
# Usage: restart_filemaker_services
restart_filemaker_services() {
local services_json=$(get_filemaker_systemd_services)
local service_count=$(echo "$services_json" | jq length)
if [ "$service_count" -eq 0 ]; then
write_log_entry "INFO" "SystemdIntegration" "RestartServices" "No FileMaker services found to restart"
return 0
fi
local restarted_count=0
local failed_services=()
for ((i=0; i<service_count; i++)); do
local service_name=$(echo "$services_json" | jq -r ".[$i].name")
write_log_entry "INFO" "SystemdIntegration" "RestartService" "Restarting service: $service_name"
if execute_with_sudo systemctl restart "$service_name"; then
((restarted_count++))
write_log_entry "INFO" "SystemdIntegration" "RestartService" "Service restarted successfully: $service_name"
else
failed_services+=("$service_name")
write_log_entry "ERROR" "SystemdIntegration" "RestartService" "Failed to restart service: $service_name"
fi
done
if [ ${#failed_services[@]} -gt 0 ]; then
write_log_entry "ERROR" "SystemdIntegration" "RestartServices" "Failed to restart some services" "{\"failed_services\":$(printf '%s\n' "${failed_services[@]}" | jq -R . | jq -s .)}"
return 1
fi
write_log_entry "INFO" "SystemdIntegration" "RestartServices" "All services restarted successfully" "{\"restarted_count\":$restarted_count}"
return 0
}
# Get detailed systemd service information
# Usage: get_systemd_service_details <service_name>
get_systemd_service_details() {
local service_name="$1"
if ! systemctl list-unit-files | grep -q "^${service_name}.service"; then
echo "{\"exists\":false}"
return 1
fi
local status=$(systemctl is-active "$service_name" 2>/dev/null || echo "inactive")
local enabled=$(systemctl is-enabled "$service_name" 2>/dev/null || echo "disabled")
local main_pid=$(systemctl show "$service_name" --property=MainPID --value 2>/dev/null || echo "0")
local memory_usage=$(systemctl show "$service_name" --property=MemoryCurrent --value 2>/dev/null || echo "0")
local start_time=$(systemctl show "$service_name" --property=ActiveEnterTimestamp --value 2>/dev/null || echo "")
local service_details=$(jq -n \
--arg name "$service_name" \
--arg status "$status" \
--arg enabled "$enabled" \
--arg main_pid "$main_pid" \
--arg memory_usage "$memory_usage" \
--arg start_time "$start_time" \
'{
exists: true,
name: $name,
status: $status,
enabled: $enabled,
main_pid: ($main_pid | tonumber),
memory_usage: ($memory_usage | tonumber),
start_time: $start_time
}')
write_log_entry "DEBUG" "SystemdIntegration" "ServiceDetails" "Retrieved service details" "$service_details"
echo "$service_details"
}
#endregion
#region Ubuntu System Configuration
# Get Ubuntu system configuration relevant to FileMaker Server
# Usage: get_ubuntu_system_configuration
get_ubuntu_system_configuration() {
local system_config=""
# Ubuntu version information
local ubuntu_version="Unknown"
local ubuntu_codename="Unknown"
local ubuntu_description="Unknown"
if [ -f /etc/os-release ]; then
ubuntu_version=$(grep '^VERSION_ID=' /etc/os-release | cut -d'"' -f2)
ubuntu_codename=$(grep '^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2)
ubuntu_description=$(grep '^PRETTY_NAME=' /etc/os-release | cut -d'"' -f2)
fi
# Hardware information
local cpu_info=$(lscpu | grep "Model name" | cut -d: -f2 | xargs 2>/dev/null || echo "Unknown")
local memory_total=$(free -h | grep "^Mem:" | awk '{print $2}' 2>/dev/null || echo "Unknown")
local disk_usage=$(df -h / | tail -1 | awk '{print $5}' 2>/dev/null || echo "Unknown")
# System services
local systemd_version=$(systemctl --version 2>/dev/null | head -1 | awk '{print $2}' 2>/dev/null || echo "Unknown")
local firewall_status="Unknown"
# Check UFW firewall status
if command -v ufw >/dev/null 2>&1; then
if ufw status 2>/dev/null | grep -q "Status: active"; then
firewall_status="active"
else
firewall_status="inactive"
fi
fi
# Check AppArmor status
local apparmor_status="Unknown"
if command -v aa-status >/dev/null 2>&1; then
if aa-status --enabled 2>/dev/null; then
apparmor_status="enabled"
else
apparmor_status="disabled"
fi
fi
# Network configuration - sanitize output
local network_interfaces
if command -v ip >/dev/null 2>&1; then
network_interfaces=$(ip link show 2>/dev/null | grep -c "^[0-9]" 2>/dev/null || echo "0")
else
network_interfaces="0"
fi
# Ensure it's a single number without newlines
network_interfaces=$(echo "$network_interfaces" | tr -d '\n\r' | head -1)
# Package management
local apt_last_update="Unknown"
if [ -f /var/lib/apt/periodic/update-success-stamp ]; then
apt_last_update=$(stat -c %y /var/lib/apt/periodic/update-success-stamp 2>/dev/null | cut -d' ' -f1 2>/dev/null || echo "Unknown")
fi
# Create system configuration JSON
system_config=$(jq -n \
--arg ubuntu_version "$ubuntu_version" \
--arg ubuntu_codename "$ubuntu_codename" \
--arg ubuntu_description "$ubuntu_description" \
--arg cpu_info "$cpu_info" \
--arg memory_total "$memory_total" \
--arg disk_usage "$disk_usage" \
--arg systemd_version "$systemd_version" \
--arg firewall_status "$firewall_status" \
--arg apparmor_status "$apparmor_status" \
--arg network_interfaces "$network_interfaces" \
--arg apt_last_update "$apt_last_update" \
'{
ubuntu_version: $ubuntu_version,
ubuntu_codename: $ubuntu_codename,
ubuntu_description: $ubuntu_description,
cpu_info: $cpu_info,
memory_total: $memory_total,
disk_usage: $disk_usage,
systemd_version: $systemd_version,
firewall_status: $firewall_status,
apparmor_status: $apparmor_status,
network_interfaces: ($network_interfaces | tonumber),
apt_last_update: $apt_last_update
}')
write_log_entry "INFO" "SystemConfiguration" "GetSystemConfiguration" "Ubuntu system configuration retrieved" "$system_config"
echo "$system_config"
}
# Store update configuration in system for tracking
# Usage: set_update_system_entry <update_version> [update_date] [backup_location]
set_update_system_entry() {
local update_version="$1"
local update_date="${2:-$(date -u +"%Y-%m-%d %H:%M:%S")}"
local backup_location="$3"
local config_dir="/etc/filemaker-security-updater"
local config_file="$config_dir/update-history.json"
# Create configuration directory if it doesn't exist
execute_with_sudo mkdir -p "$config_dir"
# Create or update the configuration entry
local update_entry
if ! update_entry=$(jq -n \
--arg update_version "$update_version" \
--arg update_date "$update_date" \
--arg cve "CVE-2025-46295" \
--arg status "Applied" \
--arg backup_location "$backup_location" \
'{
update_version: $update_version,
update_date: $update_date,
cve: $cve,
status: $status,
backup_location: $backup_location
}' 2>/dev/null); then
write_log_entry "ERROR" "SystemConfiguration" "SetUpdateEntry" "Failed to create update entry JSON"
return 1
fi
# Read existing history or create new
local history="[]"
if [ -f "$config_file" ]; then
history=$(cat "$config_file" 2>/dev/null || echo "[]")
fi
# Add new entry to history
local updated_history
if ! updated_history=$(echo "$history" | jq --argjson entry "$update_entry" '. + [$entry]' 2>/dev/null); then
write_log_entry "ERROR" "SystemConfiguration" "SetUpdateEntry" "Failed to update history JSON"
return 1
fi
# Write updated history
if echo "$updated_history" | execute_with_sudo tee "$config_file" >/dev/null; then
execute_with_sudo chmod 644 "$config_file"
write_log_entry "INFO" "SystemConfiguration" "SetUpdateEntry" "Update system entry created" "{\"update_version\":\"$update_version\",\"update_date\":\"$update_date\",\"backup_location\":\"$backup_location\",\"config_file\":\"$config_file\"}"
return 0
else
write_log_entry "ERROR" "SystemConfiguration" "SetUpdateEntry" "Failed to create update system entry" "{\"error\":\"Failed to write config file\",\"config_file\":\"$config_file\"}"
return 1
fi
}
# Check if a specific security update has been applied based on system records
# Usage: test_security_update_applied <cve>
test_security_update_applied() {
local cve="$1"
local config_file="/etc/filemaker-security-updater/update-history.json"
if [ -f "$config_file" ]; then
local history=$(cat "$config_file" 2>/dev/null || echo "[]")
local matching_entries=$(echo "$history" | jq --arg cve "$cve" '[.[] | select(.cve == $cve and .status == "Applied")]')
local entry_count=$(echo "$matching_entries" | jq length)
if [ "$entry_count" -gt 0 ]; then
local latest_entry=$(echo "$matching_entries" | jq -r '.[-1]')
write_log_entry "INFO" "SystemConfiguration" "CheckUpdateStatus" "Security update found in system records" "{\"cve\":\"$cve\",\"latest_entry\":$latest_entry}"
return 0
fi
fi
write_log_entry "DEBUG" "SystemConfiguration" "CheckUpdateStatus" "Security update not found in system records" "{\"cve\":\"$cve\",\"config_file\":\"$config_file\"}"
return 1
}
#endregion
# Check for required dependencies specific to Ubuntu optimizations
check_ubuntu_dependencies() {
local missing_deps=()
local optional_deps=()
# Check for systemctl (should always be available on modern Ubuntu)
if ! command -v systemctl >/dev/null 2>&1; then
missing_deps+=("systemctl")
fi
# Check for optional notify-send
if ! command -v notify-send >/dev/null 2>&1; then
optional_deps+=("libnotify-bin")
fi
# Check for optional zenity
if ! command -v zenity >/dev/null 2>&1; then
optional_deps+=("zenity")
fi
if [ ${#missing_deps[@]} -gt 0 ]; then
echo "Error: Missing required dependencies: ${missing_deps[*]}"
return 1
fi
if [ ${#optional_deps[@]} -gt 0 ]; then
write_log_entry "INFO" "UbuntuOptimizations" "DependencyCheck" "Optional dependencies not found" "{\"optional_deps\":$(printf '%s\n' "${optional_deps[@]}" | jq -R . | jq -s .)}"
echo "Optional dependencies not found (enhanced features may be limited): ${optional_deps[*]}"
echo "Install with: sudo apt update && sudo apt install -y ${optional_deps[*]}"
fi
return 0
}