|
| 1 | +#!/bin/bash |
| 2 | +# Fix for Warsaw binary compatibility issues |
| 3 | +# - Old versions (1.x) have no section headers - execstack doesn't work, use setarch |
| 4 | +# - New versions (2.x) work correctly with proper systemd Type=forking |
| 5 | +# - Remove conflicting service files from /etc/systemd/system/ |
| 6 | +# Bug reference: https://sourceware.org/bugzilla/show_bug.cgi?id=32653 |
| 7 | + |
| 8 | +OVERRIDE_DIR="/etc/systemd/system/warsaw.service.d" |
| 9 | +OVERRIDE_FILE="${OVERRIDE_DIR}/fix-glibc241.conf" |
| 10 | +CONFLICTING_SERVICE="/etc/systemd/system/warsaw.service" |
| 11 | + |
| 12 | +# Find Warsaw binary location (new version uses /usr/local/bin, old uses /usr/bin) |
| 13 | +WARSAW_BINARY="" |
| 14 | +if [[ -f /usr/local/bin/warsaw/core ]]; then |
| 15 | + WARSAW_BINARY="/usr/local/bin/warsaw/core" |
| 16 | +elif [[ -f /usr/bin/warsaw/core ]]; then |
| 17 | + WARSAW_BINARY="/usr/bin/warsaw/core" |
| 18 | +fi |
| 19 | + |
| 20 | +# Exit if no Warsaw binary found |
| 21 | +[[ -z "$WARSAW_BINARY" ]] && exit 0 |
| 22 | + |
| 23 | +# Remove conflicting service file in /etc/systemd/system if it exists |
| 24 | +# This file can override the correct service from the package |
| 25 | +if [[ -f "$CONFLICTING_SERVICE" ]]; then |
| 26 | + rm -f "$CONFLICTING_SERVICE" |
| 27 | +fi |
| 28 | + |
| 29 | +# Check if binary has section headers (old version doesn't) |
| 30 | +if ! readelf -S "$WARSAW_BINARY" &>/dev/null; then |
| 31 | + # Old version without section headers - needs setarch fix |
| 32 | + mkdir -p "$OVERRIDE_DIR" |
| 33 | + |
| 34 | + # Determine correct paths based on installation |
| 35 | + WSCERTMGR="" |
| 36 | + if [[ -f /usr/bin/warsaw/wscertmgr ]]; then |
| 37 | + WSCERTMGR="/usr/bin/warsaw/wscertmgr" |
| 38 | + fi |
| 39 | + |
| 40 | + cat > "$OVERRIDE_FILE" << EOF |
| 41 | +[Service] |
| 42 | +Type=forking |
| 43 | +$(if [[ -n "$WSCERTMGR" ]]; then echo "ExecStartPre="; echo "ExecStartPre=/usr/bin/setarch x86_64 --read-implies-exec $WSCERTMGR"; fi) |
| 44 | +ExecStart= |
| 45 | +ExecStart=/usr/bin/setarch x86_64 --read-implies-exec $WARSAW_BINARY |
| 46 | +EOF |
| 47 | +else |
| 48 | + # New version works correctly - remove any old override |
| 49 | + [[ -d "$OVERRIDE_DIR" ]] && rm -rf "$OVERRIDE_DIR" |
| 50 | +fi |
| 51 | + |
| 52 | +# Reload systemd configuration |
| 53 | +systemctl daemon-reload |
| 54 | + |
| 55 | +# Restart warsaw service if it's active |
| 56 | +if systemctl is-active --quiet warsaw; then |
| 57 | + systemctl restart warsaw |
| 58 | +fi |
0 commit comments