-
Notifications
You must be signed in to change notification settings - Fork 72
Repair some pain points #546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,19 @@ critical_variables: | |||||||||||||||||||
| - device.class_code # PCI Class Code (e.g., 020000 for network devices) | ||||||||||||||||||||
| - device.subsys_vendor_id # PCI Subsystem Vendor ID | ||||||||||||||||||||
| - device.subsys_device_id # PCI Subsystem Device ID | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Timing configuration (MUST come from device profiling) | ||||||||||||||||||||
| # Using fallbacks would create fingerprintable patterns | ||||||||||||||||||||
| - timing_config.min_latency_cycles | ||||||||||||||||||||
| - timing_config.max_latency_cycles | ||||||||||||||||||||
| - timing_config.avg_latency_cycles | ||||||||||||||||||||
| - timing_config.min_read_latency | ||||||||||||||||||||
| - timing_config.max_read_latency | ||||||||||||||||||||
| - timing_config.avg_read_latency | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+26
to
+34
|
||||||||||||||||||||
| # Timing configuration (MUST come from device profiling) | |
| # Using fallbacks would create fingerprintable patterns | |
| - timing_config.min_latency_cycles | |
| - timing_config.max_latency_cycles | |
| - timing_config.avg_latency_cycles | |
| - timing_config.min_read_latency | |
| - timing_config.max_read_latency | |
| - timing_config.avg_read_latency | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,8 +26,8 @@ log_error() { | |
| check_files() { | ||
| local missing_files=() | ||
|
|
||
| if [ ! -f "pcileech-build-sudo" ]; then | ||
| missing_files+=("pcileech-build-sudo") | ||
| if [ ! -f "pcileech-sudo" ]; then | ||
| missing_files+=("pcileech-sudo") | ||
| fi | ||
|
|
||
| if [ ${#missing_files[@]} -ne 0 ]; then | ||
|
|
@@ -59,14 +59,18 @@ if ! check_files; then | |
| fi | ||
|
|
||
| # Copy the wrapper script to the installation directory | ||
| log_info "Installing pcileech-build-sudo..." | ||
| cp pcileech-build-sudo "$INSTALL_DIR/" | ||
| log_info "Installing pcileech-sudo..." | ||
| cp pcileech-sudo "$INSTALL_DIR/" | ||
| chmod +x "$INSTALL_DIR/pcileech-sudo" | ||
|
|
||
| # Also install as pcileech-build-sudo for backwards compatibility | ||
| ln -sf "$INSTALL_DIR/pcileech-sudo" "$INSTALL_DIR/pcileech-build-sudo" 2>/dev/null || \ | ||
| cp pcileech-sudo "$INSTALL_DIR/pcileech-build-sudo" | ||
|
Comment on lines
+67
to
+68
|
||
| chmod +x "$INSTALL_DIR/pcileech-build-sudo" | ||
|
|
||
| log_info "Installed pcileech sudo wrapper to $INSTALL_DIR" | ||
| log_info "You can now run builds with sudo using: pcileech-build-sudo build --bdf <device> --board <board>" | ||
| log_warning "Note: The wrapper now uses the unified pcileech.py entrypoint" | ||
| log_warning "Legacy usage is supported but consider using: sudo python3 pcileech.py build ..." | ||
| log_info "You can now run commands with sudo using: pcileech-sudo <command> [args]" | ||
| log_warning "Note: The wrapper uses the unified pcileech.py entrypoint" | ||
|
|
||
| # Add the directory to PATH if it's not already there | ||
| if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then | ||
|
|
@@ -106,9 +110,9 @@ fi | |
| log_info "Installation complete!" | ||
| log_info "" | ||
| log_info "Usage examples:" | ||
| log_info " pcileech-build-sudo build --bdf 0000:03:00.0 --board pcileech_35t325_x1" | ||
| log_info " pcileech-build-sudo tui" | ||
| log_info " pcileech-build-sudo check --device 0000:03:00.0" | ||
| log_info " pcileech-sudo build --bdf 0000:03:00.0 --board pcileech_35t325_x1" | ||
| log_info " pcileech-sudo check --device 0000:03:00.0" | ||
| log_info " pcileech-sudo tui" | ||
| log_info "" | ||
| log_info "Alternative (recommended):" | ||
| log_info "Alternative (from project directory):" | ||
| log_info " sudo python3 pcileech.py build --bdf 0000:03:00.0 --board pcileech_35t325_x1" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #!/bin/bash | ||
| # pcileech-sudo - Run pcileech commands with elevated privileges | ||
| # | ||
| # This wrapper script handles: | ||
| # 1. Automatic virtual environment detection | ||
| # 2. Running pcileech.py with sudo while preserving the Python environment | ||
| # | ||
| # Usage: pcileech-sudo <command> [args...] | ||
| # Example: pcileech-sudo build --bdf 0000:03:00.0 --board pcileech_35t325_x1 | ||
| # pcileech-sudo check --device 0000:03:00.0 | ||
| # pcileech-sudo tui | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Find the script directory (where pcileech.py is located) | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| # Check if pcileech.py exists in the script directory | ||
| if [ ! -f "$SCRIPT_DIR/pcileech.py" ]; then | ||
| # Try to find it relative to installed location | ||
| if [ -f "/app/pcileech.py" ]; then | ||
| SCRIPT_DIR="/app" | ||
| else | ||
| echo "Error: Could not find pcileech.py in $SCRIPT_DIR or /app" | ||
| echo "Please run this script from the PCILeechFWGenerator directory" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| # Determine the Python interpreter to use | ||
| PYTHON_CMD="" | ||
|
|
||
| # Check for active virtual environment first | ||
| if [ -n "${VIRTUAL_ENV:-}" ]; then | ||
| PYTHON_CMD="$VIRTUAL_ENV/bin/python3" | ||
| elif [ -f "$SCRIPT_DIR/.venv/bin/python3" ]; then | ||
| # Check for local .venv | ||
| PYTHON_CMD="$SCRIPT_DIR/.venv/bin/python3" | ||
| elif [ -f "$HOME/.pcileech-venv/bin/python3" ]; then | ||
| # Check for user-level venv | ||
| PYTHON_CMD="$HOME/.pcileech-venv/bin/python3" | ||
| else | ||
| # Fall back to system Python | ||
| PYTHON_CMD="python3" | ||
| fi | ||
|
|
||
| # Verify the Python interpreter exists | ||
| if [ ! -x "$PYTHON_CMD" ] && ! command -v "$PYTHON_CMD" &> /dev/null; then | ||
| echo "Error: Python interpreter not found: $PYTHON_CMD" | ||
| echo "Please ensure Python 3 is installed and accessible" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Execute pcileech.py with sudo, preserving the Python environment | ||
| # Using 'sudo -E' to preserve environment variables | ||
| cd "$SCRIPT_DIR" | ||
| exec sudo -E "$PYTHON_CMD" "$SCRIPT_DIR/pcileech.py" "$@" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,24 @@ | |
| sys.path.insert(0, str(project_root)) | ||
| sys.path.insert(0, str(project_root / "src")) | ||
|
|
||
| # Create pcileechfwgenerator namespace mapping for direct script execution | ||
| # This is needed because pyproject.toml maps pcileechfwgenerator -> src/ | ||
| # but that only works when the package is installed via pip | ||
| _src_path = project_root / "src" | ||
| if _src_path.exists() and "pcileechfwgenerator" not in sys.modules: | ||
| import importlib.util | ||
|
|
||
| # Check if package is already installed (editable or regular install) | ||
| _spec = importlib.util.find_spec("pcileechfwgenerator") | ||
| if _spec is None: | ||
| # Package not installed, create the namespace mapping manually | ||
| # This allows "from pcileechfwgenerator.x import y" to work as "from src.x import y" | ||
| import types | ||
|
||
| _pkg = types.ModuleType("pcileechfwgenerator") | ||
| _pkg.__path__ = [str(_src_path)] | ||
| _pkg.__file__ = str(_src_path / "__init__.py") | ||
| sys.modules["pcileechfwgenerator"] = _pkg | ||
|
|
||
|
|
||
| def get_version(): | ||
| """Get the current version from the centralized version resolver.""" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,9 @@ | |||||
| TimingPattern, | ||||||
| ) | ||||||
|
|
||||||
| # Import the module itself for patching purposes | ||||||
| from pcileechfwgenerator.device_clone import board_config | ||||||
|
|
||||||
|
Comment on lines
+25
to
+27
|
||||||
| # Import the module itself for patching purposes | |
| from pcileechfwgenerator.device_clone import board_config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
||operator in this RUN command will mask installation failures. If the editable install (pip3 install -e .) fails, the echo statement will succeed (exit code 0), and the subsequent regular install command will never execute because the||operator short-circuits on success. This should use||followed by the actual install command without the echo, or better yet, use; if [ $? -ne 0 ]; thento properly chain the fallback installation.