Commit 77a70b2
Fix HTTP body parsing bug in HostAPIService and use dynamic bundle IDs
This commit fixes a critical bug where remote exec and other POST endpoints
were failing, and makes GhostTools more resilient to bundle ID changes.
**HTTP Body Parsing Bug Fix (HostAPIService.swift)**:
- Fixed parseHTTPRequest to search for \r\n\r\n delimiter in raw bytes instead
of UTF-8 string
- Previous code used string character offsets as byte offsets into rawData,
causing misalignment that included header data in the body
- This caused JSON parsing to fail with errors like "Need command" or
"Need action" even when valid JSON was sent
- Fix: Use Data.range(of:) to search directly in rawData bytes
**Dynamic Bundle ID (GhostTools)**:
- Added bundleId computed property using Bundle.main.bundleIdentifier
- Replaced all hardcoded bundle ID references with dynamic property
- Affects: launch agent paths, launchctl commands, dispatch queue labels
- Makes code resilient to future bundle ID changes
**Enhanced Launch Agent Cleanup (GhostTools)**:
- Added -w flag to launchctl unload to persist disabled state
- Capture and log stderr from unload command
- Better error handling with try/catch for plist removal
- More detailed migration logging
Verified with: vmctl remote exec /bin/ls /Applications
Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>1 parent 5c679f8 commit 77a70b2
File tree
3 files changed
+36
-26
lines changed- GhostTools/Sources/GhostTools
- Server
- GhostVMHelper
3 files changed
+36
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | | - | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
507 | 510 | | |
508 | 511 | | |
509 | 512 | | |
510 | | - | |
| 513 | + | |
511 | 514 | | |
512 | 515 | | |
513 | 516 | | |
| |||
517 | 520 | | |
518 | 521 | | |
519 | 522 | | |
520 | | - | |
| 523 | + | |
| 524 | + | |
521 | 525 | | |
522 | | - | |
| 526 | + | |
523 | 527 | | |
524 | 528 | | |
525 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
526 | 534 | | |
527 | 535 | | |
528 | | - | |
529 | 536 | | |
530 | | - | |
531 | | - | |
532 | | - | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
533 | 552 | | |
534 | 553 | | |
535 | 554 | | |
| |||
547 | 566 | | |
548 | 567 | | |
549 | 568 | | |
550 | | - | |
| 569 | + | |
551 | 570 | | |
552 | 571 | | |
553 | 572 | | |
| |||
582 | 601 | | |
583 | 602 | | |
584 | 603 | | |
585 | | - | |
| 604 | + | |
586 | 605 | | |
587 | 606 | | |
588 | 607 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
185 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
186 | 188 | | |
187 | | - | |
| 189 | + | |
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
| |||
449 | 451 | | |
450 | 452 | | |
451 | 453 | | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | 454 | | |
463 | 455 | | |
464 | 456 | | |
465 | | - | |
466 | 457 | | |
467 | 458 | | |
468 | 459 | | |
| |||
0 commit comments