Add root privilege check and warning display

- Add startup check in app.py for root/sudo privileges
- Show warning in terminal if not running as root
- Add running_as_root flag to TSCM devices API response
- Display privilege warning in TSCM UI when not running as root
- Show command to run with sudo in the warning
- Add CSS styling for privilege warning banner

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-01-14 15:37:56 +00:00
parent ff7c768287
commit db2f46b46e
3 changed files with 83 additions and 1 deletions
+19 -1
View File
@@ -596,7 +596,25 @@ def get_tscm_devices():
except Exception as e:
logger.warning(f"Error detecting SDR devices: {e}")
return jsonify({'status': 'success', 'devices': devices})
# Check if running as root
import os
from flask import current_app
running_as_root = current_app.config.get('RUNNING_AS_ROOT', os.geteuid() == 0)
warnings = []
if not running_as_root:
warnings.append({
'type': 'privileges',
'message': 'Not running as root. WiFi monitor mode and some Bluetooth features require sudo.',
'action': 'Run with: sudo -E venv/bin/python intercept.py'
})
return jsonify({
'status': 'success',
'devices': devices,
'running_as_root': running_as_root,
'warnings': warnings
})
def _scan_wifi_networks(interface: str) -> list[dict]: