Skip to content

Conversation

@PeetMcK
Copy link

@PeetMcK PeetMcK commented Nov 24, 2025

Summary

Replace single mesh binary download with tar.gz archive containing both mesh binary and .msh configuration file for macOS installations, with SHA256 verification for security.

This enables proper installation of a signed meshagent on macOS using the --copy-msh flag instead of embedded configuration, preventing invalid code signatures and gatekeeper blocking.

FixVenturaMesh() was removed, as it does not fix anything about the meshagent on macOS and actively breaks any fixes.

Changes

Agent Installation (agent/install.go)

For macOS (darwin) only:

  • Download tar.gz archive from TRMM server instead of single binary
  • NEW: Verify archive integrity using SHA256SUMS file
  • NEW: Dynamically discover actual mesh filenames from SHA256SUMS instead of hardcoded values
  • Extract archive to get both meshagent binary and meshagent.msh config file
  • Verify checksums of both files before installation
  • Run: meshagent -install --no-embedded="1" --copy-msh="1" --installPath=/opt/tacticalmesh
  • Clean up temporary archive and extracted files
  • NEW: Use random extraction directory names to prevent conflicts

Windows unchanged: Continues to use single binary download approach

Ventura Fix Removal

Removed the macOS Ventura workaround that renamed LaunchAgent plists, as it's no longer needed with proper .msh file usage:

  • Deleted agent/embed_darwin.go - Ventura fix implementation
  • Deleted agent/embed_stub.go - Non-macOS stub
  • Deleted agent/scripts/macos_fix_mesh_install.sh - Fix script
  • Removed macventurafix CLI mode from main.go
  • Removed automatic FixVenturaMesh() call from agent/svc.go

Service Cleanup (agent/svc.go)

  • Removed Darwin-specific block that auto-ran FixVenturaMesh() on startup

Technical Details

Installation Flow:

  1. Download: trmm{random}.tar.gz to temp directory
  2. Extract: trmm{random}_extracted_{random}/ containing meshagent{hash}, meshagent{hash}.msh, and SHA256SUMS
  3. Verify: Parse SHA256SUMS file to discover actual filenames and expected checksums
  4. Verify: Calculate SHA256 checksums of extracted files and compare against SHA256SUMS
  5. Install: meshagent{hash} -install --no-embedded="1" --copy-msh="1" --installPath=/opt/tacticalmesh
  6. Cleanup: Remove temp archive and extracted directory

Security Improvements:

  • SHA256 checksum verification ensures downloaded files haven't been tampered with
  • Dynamic filename discovery from SHA256SUMS supports hash-based filenames from server
  • Random extraction directory names prevent potential race conditions or conflicts

Server-Side Changes Required:
This requires corresponding changes in the tacticalrmm server to deliver the tar.gz archive with SHA256SUMS. See: amidaware/tacticalrmm#2348

Files Changed

  • agent/install.go - Modified Darwin mesh installation logic with verification (+99 lines, -9 lines)
  • agent/svc.go - Removed FixVenturaMesh() auto-execution (-4 lines)
  • main.go - Removed macventurafix CLI mode (-2 lines)
  • Deleted: embed_darwin.go, embed_stub.go, macos_fix_mesh_install.sh (-143 lines)

Net change: ~-60 lines (cleaner, more secure code)

Benefits

  • Reliability: Dynamic filename discovery supports server-side file renaming [REQUIRED for successful meshagent --copy-msh="1" install. The meshagent must not be named meshagent for --copy-msh="1" to succeed]
  • Safety: Random extraction directories prevent conflicts
  • Follows code-signing safe delivery of meshagent for installation (separate binary + .msh)
  • Removes Ventura-specific workaround and Eliminates LaunchAgent plist conflicts on macOS
  • macOS-specific; Windows behavior unchanged

Testing

  • Agent builds successfully for macOS ARM64 and AMD64
  • Universal binary created with lipo
  • Archive extraction using existing ExtractTarGz() function verified
  • SHA256 verification logic implemented and tested
  • Dynamic filename discovery from SHA256SUMS works correctly
  • File existence checks work correctly
  • Proper cleanup of temporary files

Related PRs

🤖 Generated with Claude Code. Read, tested, and edited by a human — I promise.

PeetMcK and others added 6 commits November 5, 2025 15:41
Implements comprehensive signing and notarization workflow for rmmagent:

- Core signing scripts (sign-macos.sh, notarize-macos.sh, build-pipeline-macos.sh)
- App bundle creation with Info.plist template
- Universal binary build script with optional signing integration
- Development testing script template in scripts/templates-for-bin/
- Personal wrapper templates (gitignored in bin/)

Key features:
- Modular design: each script has single responsibility
- Proper signing flow: build unsigned → create universal → sign all independently
- Keychain profile for secure notarization credentials
- Hardened Runtime and timestamping for long-term validity
- Privilege separation (sudo for launchd, user for builds/signing)
- Deploy path: /opt/tacticalagent/tacticalagent

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Replace single mesh binary download with tar.gz archive containing binary + .msh file
- Extract archive and run: meshagent -install --copy-msh="1" --installPath=/opt/tacticalmesh
- Remove macOS Ventura fix that renamed LaunchAgent plists (no longer needed)
- Changes only affect macOS (darwin) platform; Windows unchanged

Files changed:
- agent/install.go: Download tar.gz, extract, install with --copy-msh flag
- agent/svc.go: Remove FixVenturaMesh() auto-execution
- main.go: Remove macventurafix CLI mode
- Deleted: embed_darwin.go, embed_stub.go, macos_fix_mesh_install.sh

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Implement separate mesh binary + .msh installation for macOS

tested and verified working. 2025.11.12
Removing deprecated macOS build pipeline scripts that are no longer needed.

Files removed:
- scripts/macos/Info.plist.template
- scripts/macos/build-macos-universal.sh
- scripts/macos/build-pipeline-macos.sh
- scripts/macos/create-app-bundle.sh
- scripts/macos/notarize-macos.sh
- scripts/macos/sign-macos.sh
- scripts/templates-for-bin/sign-and-notarize-rmmagent-template.sh

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
… agent

Improves security and reliability of mesh agent installation by verifying checksums from SHA256SUMS file and dynamically discovering actual filenames instead of using hardcoded values. Also adds --no-embedded flag to mesh installation command and uses random extraction directories to prevent conflicts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant